Skip to content

Commit

Permalink
feat: 쿼리훅 쿠키 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
bottlewook committed Feb 29, 2024
1 parent 455e8c6 commit 179f933
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/hooks/useLoggedOut.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { useCookies } from 'react-cookie';

import { useQueryClient } from '@tanstack/react-query';
import { useRouter } from 'next/navigation';

import { useAppDispatch } from '@stores/hooks';
import { clearUserId } from '@stores/slices/userSlice';
import { removeCookie } from '@utils/cookies';

function useLoggedOut() {
const router = useRouter();
const dispatch = useAppDispatch();
const query = useQueryClient();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cookies, removeCookie] = useCookies(['token']);

const logout = (redirectPath = '/') => {
dispatch(clearUserId());
Expand Down
7 changes: 2 additions & 5 deletions src/remote/queries/auth/useLogin.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { useCookies } from 'react-cookie';

import { useMutation } from '@tanstack/react-query';
import { useRouter } from 'next/navigation';

import { login } from '@remote/api/requests/auth/auth.post.api';
import { UserInfoType } from '@remote/api/types/auth';
import { useAppDispatch } from '@stores/hooks';
import { setUserId } from '@stores/slices/userSlice';
import { setCookie } from '@utils/cookies';

function useLogin() {
const router = useRouter();
const dispatch = useAppDispatch();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cookies, setCookie] = useCookies(['token']);

const onSuccess = (data : UserInfoType) => {
const onSuccess = (data: UserInfoType) => {
const { id, jwtToken } = data.value;
const cookieOptions = { path: '/', maxAge: 60 * 15 };

Expand Down

0 comments on commit 179f933

Please sign in to comment.