From 18f35e145ee742bb897a9cbaf2ccd477b0c32141 Mon Sep 17 00:00:00 2001 From: bluetree7878 Date: Fri, 3 Jan 2025 15:34:23 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20BugFix(#79):=20auth=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=ED=82=A4=20=EC=88=98=EC=A0=95,=20Ranking=20?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=EC=97=90=20createdAt=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/auth/apis.ts | 1 + src/features/auth/queries.ts | 12 +++++++----- src/pages/ranking/Ranking.tsx | 31 +++++++++++++++++++++++++------ src/store/useUserStore.ts | 1 + tsconfig.app.tsbuildinfo | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/features/auth/apis.ts b/src/features/auth/apis.ts index 9120a9a..844b118 100644 --- a/src/features/auth/apis.ts +++ b/src/features/auth/apis.ts @@ -6,6 +6,7 @@ const authApis = { const response = await api.get('/auth/verify'); return response.data; }, + logout: async (): Promise => { await api.post('/auth/logout'); }, diff --git a/src/features/auth/queries.ts b/src/features/auth/queries.ts index 0342231..e24c386 100644 --- a/src/features/auth/queries.ts +++ b/src/features/auth/queries.ts @@ -1,24 +1,26 @@ -import { useMutation, useQuery } from '@tanstack/react-query'; +import { useQuery, useMutation } from '@tanstack/react-query'; import authApis from '@features/auth/apis'; const authKeys = { - verify: ['auth', 'verify'] as const, - logout: ['auth', 'logout'] as const, + all: ['auth'] as const, + verify: () => [...authKeys.all, 'verify'] as const, + logout: () => [...authKeys.all, 'logout'] as const, }; export const authQuery = { verify: () => { return useQuery({ - queryKey: authKeys.verify, + queryKey: authKeys.verify(), queryFn: authApis.verify, staleTime: 0, gcTime: 0, retry: false, }); }, + logout: () => { return useMutation({ - mutationKey: authKeys.logout, + mutationKey: authKeys.logout(), mutationFn: authApis.logout, }); }, diff --git a/src/pages/ranking/Ranking.tsx b/src/pages/ranking/Ranking.tsx index 5fdadac..d95c25e 100644 --- a/src/pages/ranking/Ranking.tsx +++ b/src/pages/ranking/Ranking.tsx @@ -12,12 +12,30 @@ export default function Ranking() { const [selectedOption, setSelectedOption] = useState('포인트 보유순'); const dummyUsers = [ - { id: 2, name: 'gwgw2', level: 4, point: 200 }, - { id: 3, name: 'gwgwgw3', level: 2, point: 5000 }, - { id: 4, name: 'gwgwgwgw4', level: 3, point: 160 }, - { id: 5, name: 'gwgwgwgwgw5', level: 10, point: 190 }, - { id: 6, name: 'gwgwgwgwgwgw6', level: 12, point: 230 }, - { id: 7, name: 'gwgwgwgwgwgwgw7', level: 1, point: 3000 }, + { id: 2, name: 'gwgw2', level: 4, point: 200, createdAt: '2021-10-01' }, + { id: 3, name: 'gwgwgw3', level: 2, point: 5000, createdAt: '2021-10-02' }, + { id: 4, name: 'gwgwgwgw4', level: 3, point: 160, createdAt: '2021-10-03' }, + { + id: 5, + name: 'gwgwgwgwgw5', + level: 10, + point: 190, + createdAt: '2021-10-04', + }, + { + id: 6, + name: 'gwgwgwgwgwgw6', + level: 12, + point: 230, + createdAt: '2021-10-05', + }, + { + id: 7, + name: 'gwgwgwgwgwgwgw7', + level: 1, + point: 3000, + createdAt: '2021-10-06', + }, ]; const myRank = { @@ -26,6 +44,7 @@ export default function Ranking() { level: 10, point: 190, rank: 4, + createdAt: '2021-10-04', }; return ( diff --git a/src/store/useUserStore.ts b/src/store/useUserStore.ts index c99d559..46c535c 100644 --- a/src/store/useUserStore.ts +++ b/src/store/useUserStore.ts @@ -4,6 +4,7 @@ import type { User } from '@features/user/types'; interface State { user: User | null; } + interface Actions { setUser: (user: User) => void; clearUser: () => void; diff --git a/tsconfig.app.tsbuildinfo b/tsconfig.app.tsbuildinfo index 0a7c96d..9d99587 100644 --- a/tsconfig.app.tsbuildinfo +++ b/tsconfig.app.tsbuildinfo @@ -1 +1 @@ -{"root":["./src/app.tsx","./src/modalportal.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/axios/instance.ts","./src/axios/interceptor.ts","./src/axios/statuscode.ts","./src/common/layout/cokologo.tsx","./src/common/layout/header.tsx","./src/common/layout/menubar.tsx","./src/common/layout/modal.tsx","./src/common/layout/style.ts","./src/common/ui/headeritem.tsx","./src/common/ui/menuitem.tsx","./src/common/ui/style.ts","./src/features/auth/apis.ts","./src/features/auth/queries.ts","./src/features/auth/service/handlelogin.ts","./src/features/auth/service/handlelogout.ts","./src/features/auth/ui/login.tsx","./src/features/auth/ui/loginprompt.tsx","./src/features/auth/ui/styles.ts","./src/features/learn/apis.ts","./src/features/learn/constants.ts","./src/features/learn/queries.ts","./src/features/learn/types.ts","./src/features/learn/service/getpartgridposition.ts","./src/features/learn/ui/keycapadventureintro.tsx","./src/features/learn/ui/navigationcontrol.tsx","./src/features/learn/ui/sectionnavigatecontainer.tsx","./src/features/learn/ui/selectsection.tsx","./src/features/learn/ui/styles.ts","./src/features/progress/style.ts","./src/features/progress/ui/progressbar.tsx","./src/features/quest/types.ts","./src/features/quest/ui/dailyquest.tsx","./src/features/quest/ui/mainquest.tsx","./src/features/quest/ui/questsection.tsx","./src/features/quest/ui/styles.ts","./src/features/quiz/apis.ts","./src/features/quiz/constants.ts","./src/features/quiz/queries.ts","./src/features/quiz/types.ts","./src/features/quiz/service/hooks.ts","./src/features/quiz/service/quizutils.ts","./src/features/quiz/ui/combination.tsx","./src/features/quiz/ui/multiplechoice.tsx","./src/features/quiz/ui/oxselector.tsx","./src/features/quiz/ui/partnavcontainer.tsx","./src/features/quiz/ui/question.tsx","./src/features/quiz/ui/quizsection.tsx","./src/features/quiz/ui/result.tsx","./src/features/quiz/ui/shortanswer.tsx","./src/features/quiz/ui/textblock.tsx","./src/features/quiz/ui/styles.ts","./src/features/ranking/constant.ts","./src/features/ranking/ui/myrank.tsx","./src/features/ranking/ui/rankingcontainer.tsx","./src/features/ranking/ui/sortdropdown.tsx","./src/features/ranking/ui/styles.ts","./src/features/store/types.ts","./src/features/store/ui/cartlist.tsx","./src/features/store/ui/itemcontainer.tsx","./src/features/store/ui/storeitem.tsx","./src/features/store/ui/styles.ts","./src/features/user/apis.ts","./src/features/user/constants.ts","./src/features/user/queries.ts","./src/features/user/types.ts","./src/features/user/service/authutils.ts","./src/features/user/ui/badgecontainer.tsx","./src/features/user/ui/mycharacter.tsx","./src/features/user/ui/partclear.tsx","./src/features/user/ui/profileimage.tsx","./src/features/user/ui/totalresults.tsx","./src/features/user/ui/styles.ts","./src/hooks/usebeforeunload.ts","./src/hooks/usefunnel.tsx","./src/hooks/usemodal.ts","./src/hooks/useoutsideclick.ts","./src/hooks/usepopover.ts","./src/hooks/usepreloadimages.ts","./src/hooks/usescrollvisibility.ts","./src/pages/learn/learn.tsx","./src/pages/learn/style.ts","./src/pages/profile/profile.tsx","./src/pages/profile/styles.ts","./src/pages/quest/quest.tsx","./src/pages/quest/styles.ts","./src/pages/quiz/quiz.tsx","./src/pages/quiz/styles.ts","./src/pages/ranking/ranking.tsx","./src/pages/ranking/styles.ts","./src/pages/store/store.tsx","./src/pages/store/styles.ts","./src/route/router.tsx","./src/store/useclientquizstore.ts","./src/store/usedndstore.ts","./src/store/useuserstore.ts","./src/style/globalstyle.ts","./src/style/layout.ts","./src/style/media.ts","./src/style/style.ts","./src/types/layout.ts","./src/utils/compact.ts","./src/utils/componentmap.tsx","./src/utils/getimageurl.ts","./src/utils/handlepage.ts","./src/utils/isequalarray.ts"],"version":"5.6.2"} \ No newline at end of file +{"root":["./src/app.tsx","./src/modalportal.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/axios/instance.ts","./src/axios/interceptor.ts","./src/axios/statuscode.ts","./src/common/layout/cokologo.tsx","./src/common/layout/header.tsx","./src/common/layout/menubar.tsx","./src/common/layout/modal.tsx","./src/common/layout/style.ts","./src/common/ui/headeritem.tsx","./src/common/ui/menuitem.tsx","./src/common/ui/style.ts","./src/features/auth/apis.ts","./src/features/auth/queries.ts","./src/features/auth/service/handlelogin.ts","./src/features/auth/service/handlelogout.ts","./src/features/auth/ui/login.tsx","./src/features/auth/ui/loginprompt.tsx","./src/features/auth/ui/styles.ts","./src/features/learn/apis.ts","./src/features/learn/constants.ts","./src/features/learn/queries.ts","./src/features/learn/types.ts","./src/features/learn/service/getpartgridposition.ts","./src/features/learn/ui/keycapadventureintro.tsx","./src/features/learn/ui/navigationcontrol.tsx","./src/features/learn/ui/sectionnavigatecontainer.tsx","./src/features/learn/ui/selectsection.tsx","./src/features/learn/ui/styles.ts","./src/features/progress/style.ts","./src/features/progress/ui/progressbar.tsx","./src/features/quest/types.ts","./src/features/quest/ui/dailyquest.tsx","./src/features/quest/ui/mainquest.tsx","./src/features/quest/ui/questsection.tsx","./src/features/quest/ui/styles.ts","./src/features/quiz/apis.ts","./src/features/quiz/constants.ts","./src/features/quiz/queries.ts","./src/features/quiz/types.ts","./src/features/quiz/service/hooks.ts","./src/features/quiz/service/quizutils.ts","./src/features/quiz/ui/combination.tsx","./src/features/quiz/ui/multiplechoice.tsx","./src/features/quiz/ui/oxselector.tsx","./src/features/quiz/ui/partnavcontainer.tsx","./src/features/quiz/ui/question.tsx","./src/features/quiz/ui/quizsection.tsx","./src/features/quiz/ui/result.tsx","./src/features/quiz/ui/shortanswer.tsx","./src/features/quiz/ui/textblock.tsx","./src/features/quiz/ui/styles.ts","./src/features/ranking/constant.ts","./src/features/ranking/ui/myrank.tsx","./src/features/ranking/ui/rankingcontainer.tsx","./src/features/ranking/ui/sortdropdown.tsx","./src/features/ranking/ui/styles.ts","./src/features/store/types.ts","./src/features/store/ui/cartlist.tsx","./src/features/store/ui/itemcontainer.tsx","./src/features/store/ui/storeitem.tsx","./src/features/store/ui/styles.ts","./src/features/user/apis.ts","./src/features/user/constants.ts","./src/features/user/queries.ts","./src/features/user/types.ts","./src/features/user/service/authutils.ts","./src/features/user/ui/badgecontainer.tsx","./src/features/user/ui/mycharacter.tsx","./src/features/user/ui/partclear.tsx","./src/features/user/ui/profileimage.tsx","./src/features/user/ui/totalresults.tsx","./src/features/user/ui/styles.ts","./src/hooks/usebeforeunload.ts","./src/hooks/usefunnel.tsx","./src/hooks/usemodal.ts","./src/hooks/useoutsideclick.ts","./src/hooks/usepopover.ts","./src/hooks/usepreloadimages.ts","./src/hooks/usescrollvisibility.ts","./src/pages/learn/learn.tsx","./src/pages/learn/style.ts","./src/pages/profile/profile.tsx","./src/pages/profile/styles.ts","./src/pages/quest/quest.tsx","./src/pages/quest/styles.ts","./src/pages/quiz/quiz.tsx","./src/pages/quiz/styles.ts","./src/pages/ranking/ranking.tsx","./src/pages/ranking/styles.ts","./src/pages/store/store.tsx","./src/pages/store/styles.ts","./src/route/router.tsx","./src/store/useclientquizstore.ts","./src/store/usedndstore.ts","./src/store/useuserstore.ts","./src/style/globalstyle.ts","./src/style/layout.ts","./src/style/media.ts","./src/style/style.ts","./src/types/layout.ts","./src/utils/compact.ts","./src/utils/componentmap.tsx","./src/utils/formatdate.ts","./src/utils/getimageurl.ts","./src/utils/handlepage.ts","./src/utils/isequalarray.ts"],"version":"5.6.2"} \ No newline at end of file