Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/domain/Auth/hooks/useSigninMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
import { HTTPError } from 'ky';
import { useRouter } from 'next/navigation';

import { SigninResponse } from '@/domain/Auth/schemas/response';
import { signin } from '@/domain/Auth/services';
import { ROUTES } from '@/shared/constants/routes';
import { useToast } from '@/shared/hooks/useToast';
// import { useRoamReadyStore } from '@/shared/store';
import { useRoamReadyStore } from '@/shared/store';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Client 전용 훅이므로 'use client' 지시어 추가 권장.

useRouter, sessionStorage, Zustand 훅을 사용하므로 서버 컴포넌트에서 오용되는 것을 미연에 방지합니다. 기존 사용처가 모두 Client여도 안전망으로 추가하는 것을 권장합니다.

+ 'use client';
  import { useMutation, useQueryClient } from '@tanstack/react-query';
🤖 Prompt for AI Agents
In src/domain/Auth/hooks/useSigninMutation.ts around line 9, this is a
client-only hook (uses useRouter, sessionStorage, and a Zustand hook) so add the
"use client" directive as the very first line of the file; ensure the directive
appears before any imports and then keep the existing imports and code unchanged
so the hook cannot be used in a server component.


/**
* @function useSigninMutation
Expand All @@ -32,16 +33,15 @@ import { useToast } from '@/shared/hooks/useToast';
*/
export const useSigninMutation = () => {
const router = useRouter();
// const setUser = useRoamReadyStore((state) => state.setUser);
const setUser = useRoamReadyStore((state) => state.setUser);
const queryClient = useQueryClient();
const { showError } = useToast();

return useMutation({
mutationFn: signin,
onSuccess: () => {
// onSuccess: (data: SigninResponse) => {
onSuccess: (data: SigninResponse) => {
sessionStorage.removeItem('signup-form');
// setUser(data.user);
setUser(data.user);
queryClient.invalidateQueries({ queryKey: ['user', 'me'] });
// showSuccess('로그인 되었습니다. 환영합니다!');
router.push(ROUTES.ACTIVITIES.ROOT);
Expand Down