diff --git a/src/__data__/api/api.ts b/src/__data__/api/api.ts index 03e889b..76c542e 100644 --- a/src/__data__/api/api.ts +++ b/src/__data__/api/api.ts @@ -33,7 +33,7 @@ export const api = createApi({ }), tagTypes: ['Chains', 'Chain', 'UserStats', 'SystemStats', 'Submissions', 'Queue'], endpoints: (builder) => ({ - authUser: builder.mutation({ + authUser: builder.mutation({ query: (body) => ({ url: '/auth', method: 'POST', diff --git a/src/context/ChallengeContext.tsx b/src/context/ChallengeContext.tsx index 8d375dd..5a319f4 100644 --- a/src/context/ChallengeContext.tsx +++ b/src/context/ChallengeContext.tsx @@ -160,7 +160,10 @@ export const ChallengeProvider = ({ children }: PropsWithChildren) => { const login = useCallback( async (nicknameValue: string, workplaceNumberValue: string) => { - const response = await authUser({ nickname: nicknameValue }).unwrap() + const response = await authUser({ + nickname: nicknameValue, + workplaceNumber: workplaceNumberValue || undefined + }).unwrap() setUserId(response.userId) setNickname(nicknameValue) setWorkplaceNumber(workplaceNumberValue) diff --git a/stubs/api/index.js b/stubs/api/index.js index b03aa43..0fd2577 100644 --- a/stubs/api/index.js +++ b/stubs/api/index.js @@ -24,7 +24,13 @@ router.use((req, res, next) => { // Challenge API endpoints router.post('/challenge/auth', (req, res) => { - res.json(readJson('auth.json')) + const { nickname, workplaceNumber } = req.body + const response = readJson('auth.json') + + // Логируем для отладки + console.log('Auth request:', { nickname, workplaceNumber }) + + res.json(response) }) router.get('/challenge/chains', (req, res) => {