diff --git a/frontend/src/hooks/queries/application/useGetApplication.ts b/frontend/src/hooks/queries/application/useGetApplication.ts index 28d8865c2..c376b9f7f 100644 --- a/frontend/src/hooks/queries/application/useGetApplication.ts +++ b/frontend/src/hooks/queries/application/useGetApplication.ts @@ -6,5 +6,6 @@ export const useGetApplication = (clubId: string) => { queryKey: ['applicationForm', clubId], queryFn: () => getApplication(clubId), retry: false, + enabled: !!clubId, }); }; diff --git a/frontend/src/hooks/useTrackPageView.ts b/frontend/src/hooks/useTrackPageView.ts index b64a7ddbb..66f70b2fd 100644 --- a/frontend/src/hooks/useTrackPageView.ts +++ b/frontend/src/hooks/useTrackPageView.ts @@ -39,7 +39,7 @@ const useTrackPageView = (pageName: string, clubName?: string) => { window.removeEventListener('beforeunload', trackPageDuration); document.removeEventListener('visibilitychange', trackPageDuration); }; - }, [location.pathname, clubName]); + }, [location.pathname]); }; export default useTrackPageView; diff --git a/frontend/src/pages/ApplicationFormPage/ApplicationFormPage.tsx b/frontend/src/pages/ApplicationFormPage/ApplicationFormPage.tsx index 2a71a683d..ecc3a4e56 100644 --- a/frontend/src/pages/ApplicationFormPage/ApplicationFormPage.tsx +++ b/frontend/src/pages/ApplicationFormPage/ApplicationFormPage.tsx @@ -3,6 +3,7 @@ import { PageContainer } from '@/styles/PageContainer.styles'; import Header from '@/components/common/Header/Header'; import { useNavigate, useParams } from 'react-router-dom'; import { useGetClubDetail } from '@/hooks/queries/club/useGetClubDetail'; +import useTrackPageView from '@/hooks/useTrackPageView'; import { useAnswers } from '@/hooks/useAnswers'; import QuestionAnswerer from '@/pages/ApplicationFormPage/components/QuestionAnswerer/QuestionAnswerer'; import { useGetApplication } from '@/hooks/queries/application/useGetApplication'; @@ -20,6 +21,19 @@ const ApplicationFormPage = () => { const questionRefs = useRef>([]); const [invalidQuestionIds, setInvalidQuestionIds] = useState([]); + const { data: clubDetail, error: clubError } = useGetClubDetail(clubId!); + const { + data: formData, + isLoading, + isError, + error: applicationError, + } = useGetApplication(clubId!); + + useTrackPageView( + 'ApplicationFormPage', + clubDetail?.name ?? `club:${clubId ?? 'unknown'}`, + ); + if (!clubId) return null; const STORAGE_KEY = `applicationAnswers_${clubId}`; @@ -32,14 +46,6 @@ const ApplicationFormPage = () => { answers, } = useAnswers(initialAnswers); - const { data: clubDetail, error: clubError } = useGetClubDetail(clubId); - const { - data: formData, - isLoading, - isError, - error: applicationError, - } = useGetApplication(clubId); - useEffect(() => { localStorage.setItem(STORAGE_KEY, JSON.stringify(answers)); }, [answers]); diff --git a/frontend/src/pages/ClubUnionPage/ClubUnionPage.tsx b/frontend/src/pages/ClubUnionPage/ClubUnionPage.tsx index b7dba7ef6..e7f01bf4a 100644 --- a/frontend/src/pages/ClubUnionPage/ClubUnionPage.tsx +++ b/frontend/src/pages/ClubUnionPage/ClubUnionPage.tsx @@ -1,10 +1,13 @@ import Header from '@/components/common/Header/Header'; import * as Styled from './ClubUnionPage.styles'; +import useTrackPageView from '@/hooks/useTrackPageView'; import { CLUB_UNION_MEMBERS } from '@/constants/CLUB_UNION_INFO'; import { PageContainer } from '@/styles/PageContainer.styles'; import Footer from '@/components/common/Footer/Footer'; const ClubUnionPage = () => { + useTrackPageView('ClubUnionPage'); + return ( <>