From 724f61f028bf86440200dbeff22f294c8c1a770c Mon Sep 17 00:00:00 2001 From: "SeungJu, Lee" <84257439+SeungJL@users.noreply.github.com> Date: Sun, 9 Jun 2024 16:15:14 +0900 Subject: [PATCH] fix location cache issue #161 (#162) --- pageTemplates/home/HomeStudySection.tsx | 1 - pageTemplates/study/StudyHeader.tsx | 8 ++++++-- pages/study/[id]/[date]/index.tsx | 6 +++--- utils/convertUtils/convertTypes.ts | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pageTemplates/home/HomeStudySection.tsx b/pageTemplates/home/HomeStudySection.tsx index 432e0cdae..e61345d1f 100644 --- a/pageTemplates/home/HomeStudySection.tsx +++ b/pageTemplates/home/HomeStudySection.tsx @@ -40,7 +40,6 @@ export default function HomeStudySection() { const date = searchParams.get("date"); const locationEn = searchParams.get("location") as LocationEn; const location = convertLocationLangTo(locationEn, "kr"); - const myUid = session?.user.uid; const setSortedStudyCardList = useSetRecoilState(sortedStudyCardListState); diff --git a/pageTemplates/study/StudyHeader.tsx b/pageTemplates/study/StudyHeader.tsx index 12bb51927..04963b222 100644 --- a/pageTemplates/study/StudyHeader.tsx +++ b/pageTemplates/study/StudyHeader.tsx @@ -1,11 +1,13 @@ import dayjs from "dayjs"; import { useParams } from "next/navigation"; import { useRouter } from "next/router"; +import { useSession } from "next-auth/react"; import KakaoShareBtn from "../../components/atoms/Icons/KakaoShareBtn"; import Header from "../../components/layouts/Header"; import { PLACE_TO_LOCATION } from "../../constants/serviceConstants/studyConstants/studyLocationConstants"; import { WEB_URL } from "../../constants/system"; +import { convertLocationLangTo } from "../../utils/convertUtils/convertDatas"; import { dayjsToFormat } from "../../utils/dateTimeUtils"; interface IStudyHeader { brand: string; @@ -15,14 +17,16 @@ interface IStudyHeader { } function StudyHeader({ brand, fullname, locationDetail, coverImage }: IStudyHeader) { + const { data: session } = useSession(); const { id, date } = useParams<{ id: string; date: string }>(); - const location = PLACE_TO_LOCATION?.[id]; + const location = PLACE_TO_LOCATION?.[id] || session?.user.location; + const locationEn = convertLocationLangTo(location, "en"); const router = useRouter(); const url = WEB_URL + router?.asPath; return ( -
+
{brand !== "자유 신청" && ( { diff --git a/utils/convertUtils/convertTypes.ts b/utils/convertUtils/convertTypes.ts index c76cb1840..2e3719336 100644 --- a/utils/convertUtils/convertTypes.ts +++ b/utils/convertUtils/convertTypes.ts @@ -15,6 +15,7 @@ export const getUrlWithLocationAndDate = ( userLocation: ActiveLocation = "수원", ) => { const location = locationParam || convertLocationLangTo(userLocation || "suw", "en"); + const locationBaseUrl = `/home?location=${location}`; const dateQuery = !dateParam ? `&date=${getStudyStandardDate()}` : "";