Skip to content

Commit

Permalink
Fix: set member ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
kangsinbeom committed Jul 10, 2024
1 parent 99eadac commit c9c7e76
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pages/callback/hooks/usePostSocialLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import { LoginResponse } from '@/types/member';
import { useMutation } from '@tanstack/react-query';

const usePostSocialLogin = (sessionId: string | null) => {
const setMember = memberStore((state) => state.setMember);
const { setMember, setToken } = memberStore();
const navigate = useCustomNavigate();
const prevPath = sessionStorage.getItem('prev-path');
return useMutation({
mutationKey: ['socialLogin', sessionId],
mutationFn: () => postSocialLogin({ sessionId: sessionId as string }),
onSuccess: (data: LoginResponse) => {
setMember(data);
const { accessToken, ...member } = data;
setMember(member);
setToken(accessToken);
navigate(prevPath as string);
},
});
Expand Down

0 comments on commit c9c7e76

Please sign in to comment.