From 0ce6c21f7aa4a799459ed2e801ba7c28a5f4b6c1 Mon Sep 17 00:00:00 2001 From: nimod7890 Date: Thu, 22 Aug 2024 15:54:29 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=8B=9C=ED=81=AC=EB=A6=BF=20=ED=83=AD?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EA=B3=B5=EC=9C=A0=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?=EC=B9=B4=EC=9A=B4=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=A4=91=EB=B3=B5=20=EC=9A=94=EC=B2=AD=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hooks/query/useUpdateShareLinkClickCount.ts | 15 --------------- packages/user/src/routes/loader/share-redirect.ts | 9 ++++++--- packages/user/src/services/api/queryKey.ts | 1 - 3 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 packages/user/src/hooks/query/useUpdateShareLinkClickCount.ts diff --git a/packages/user/src/hooks/query/useUpdateShareLinkClickCount.ts b/packages/user/src/hooks/query/useUpdateShareLinkClickCount.ts deleted file mode 100644 index 946d8ba6..00000000 --- a/packages/user/src/hooks/query/useUpdateShareLinkClickCount.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { useQuery } from '@tanstack/react-query'; -import http from 'src/services/api/index.ts'; -import QUERY_KEYS from 'src/services/api/queryKey.ts'; - -export default function useUpdateShareLinkClickCount(id: string | undefined) { - const queries = useQuery(clickCountQueryOptions(id)); - - return queries; -} - -export const clickCountQueryOptions = (id: string | undefined) => ({ - queryKey: [QUERY_KEYS.UPDATE_SHARE_COUNT, id], - queryFn: () => http.get(`/share-link/${id}`), - enabled: Boolean(id), -}); diff --git a/packages/user/src/routes/loader/share-redirect.ts b/packages/user/src/routes/loader/share-redirect.ts index 58b197dc..36448e75 100644 --- a/packages/user/src/routes/loader/share-redirect.ts +++ b/packages/user/src/routes/loader/share-redirect.ts @@ -1,12 +1,15 @@ import { LoaderFunction, redirect } from 'react-router-dom'; import RoutePaths from 'src/constants/routePath.ts'; -import { clickCountQueryOptions } from 'src/hooks/query/useUpdateShareLinkClickCount.ts'; -import { queryClient } from 'src/libs/query/index.tsx'; +import http from 'src/services/api/index.ts'; const shareRedirectLoader: LoaderFunction = async ({ params }) => { const { id } = params; - await queryClient.fetchQuery(clickCountQueryOptions(id)); + try { + await http.get(`/share-link/${id}`); + } catch (error) { + return redirect(RoutePaths.Home); + } return redirect(RoutePaths.Home); }; diff --git a/packages/user/src/services/api/queryKey.ts b/packages/user/src/services/api/queryKey.ts index 593cf7ae..a5414987 100644 --- a/packages/user/src/services/api/queryKey.ts +++ b/packages/user/src/services/api/queryKey.ts @@ -1,7 +1,6 @@ const QUERY_KEYS = { EVENT_DURATION: 'event-duration', GET_LINK_SHARE_COUNT: 'get-link-share-count', - UPDATE_SHARE_COUNT: 'update-link-share-count', TEAM_TYPE_QUIZ: 'team-type-quiz', FCFS_QUIZ: 'fcfs-quiz', USER_INFO: 'user-info',