Skip to content

Commit

Permalink
fix location cache issue #161 (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeungJL authored Jun 9, 2024
1 parent 5c0944e commit 724f61f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion pageTemplates/home/HomeStudySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions pageTemplates/study/StudyHeader.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 (
<Header title={brand} url={`/home/?location=${location}&date=${date}`}>
<Header title={brand} url={`/home/?location=${locationEn}&date=${date}`}>
{brand !== "자유 신청" && (
<KakaoShareBtn
type="study"
Expand Down
6 changes: 3 additions & 3 deletions pages/study/[id]/[date]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export default function Page() {

const setMyStudy = useSetRecoilState(myStudyState);

const location = PLACE_TO_LOCATION[id];
const location = PLACE_TO_LOCATION[id] || data?.user.location;

const isPrivateStudy = id === ALL_스터디인증;

const { data: studyAll } = useStudyVoteQuery(date, location, {
const { data: studyAll, isLoading } = useStudyVoteQuery(date, location, {
enabled: (!!location || isPrivateStudy) && !!date,
});

console.log(isLoading, date, location);
const [studyDateStatus, setStudyDateStatus] = useRecoilState(studyDateStatusState);

useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions utils/convertUtils/convertTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}` : "";

Expand Down

0 comments on commit 724f61f

Please sign in to comment.