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',