From eb5bc8a10ac5f909ce3b06603272834cb7b71864 Mon Sep 17 00:00:00 2001 From: Primakov Alexandr Date: Mon, 15 Dec 2025 18:03:10 +0300 Subject: [PATCH] Update authUser mutation to accept optional workplaceNumber parameter and adjust login function accordingly. Enhance API logging for authentication requests to include workplaceNumber for better debugging. --- src/__data__/api/api.ts | 2 +- src/context/ChallengeContext.tsx | 5 ++++- stubs/api/index.js | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) 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) => {