Skip to content

Commit

Permalink
fix: 유형 검사 완료할 경우 response로 type 받아와 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
nim-od committed Aug 19, 2024
1 parent 263e435 commit 4fa7277
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/user/src/hooks/query/useSubmitTeamTypeQuizAnswers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ServerCategoryEnum } from '@softeer/common/types';
import { useMutation } from '@tanstack/react-query';
import serverTeamEnumToClient from 'src/constants/serverMapping.ts';
import useAuth from 'src/hooks/useAuth.ts';
import { queryClient } from 'src/libs/query/index.tsx';
import http from 'src/services/api/index.ts';
import QUERY_KEYS from 'src/services/api/queryKey.ts';
import type { User } from 'src/types/user.d.ts';

export type SubmitQuizAnswersRequest = { id: number; answer: number }[];

Expand All @@ -14,13 +14,17 @@ export interface SubmitQuizAnswersResponse {
}

export default function useSubmitTeamTypeQuizAnswers() {
const { setAuthData } = useAuth();
const { user, setAuthData } = useAuth();

const mutation = useMutation<SubmitQuizAnswersResponse, Error, SubmitQuizAnswersRequest>({
mutationFn: (data) => http.post('/personality-test', data),
onSuccess: ({ accessToken }) => {
setAuthData({ accessToken });
queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.USER_INFO] });
onSuccess: ({ accessToken, team }) => {
const userData = {
...(user as User),
type: serverTeamEnumToClient[team],
};

setAuthData({ accessToken, userData });
},
});

Expand Down

0 comments on commit 4fa7277

Please sign in to comment.