diff --git a/next.config.ts b/next.config.ts index 46abc39..0f94eca 100644 --- a/next.config.ts +++ b/next.config.ts @@ -25,6 +25,16 @@ const nextConfig: NextConfig = { hostname: "t1.kakaocdn.net", pathname: "/**", }, + { + protocol: "https", + hostname: "k.kakaocdn.net", + pathname: "/**", + }, + { + protocol: "http", + hostname: "k.kakaocdn.net", + pathname: "/**", + }, ], }, webpack(config: Configuration) { diff --git a/src/entities/home/hooks/homeHooks.ts b/src/entities/home/hooks/homeHooks.ts index d792ca1..85364ed 100644 --- a/src/entities/home/hooks/homeHooks.ts +++ b/src/entities/home/hooks/homeHooks.ts @@ -100,28 +100,33 @@ export const useGlobalPageNation = ({ }); }; +const recommendedFetchedKey = (userId: string) => `home-recommended-fetched:${userId ?? "anon"}`; + export const useRecommendedNotice = () => { + const { userName } = useOAuthStore(); + const isBrowser = typeof window !== "undefined"; + + const fetched = + isBrowser && !!userName + ? sessionStorage.getItem(recommendedFetchedKey(userName)) === "query" + : false; + return useInfiniteQuery, Error>({ - queryKey: ["HOME_RECOMMENDED"], + queryKey: ["HOME_RECOMMENDED", userName], initialPageParam: 1, retry: false, + enabled: isBrowser && !!userName && !fetched, + staleTime: Infinity, + gcTime: Infinity, queryFn: async ({ pageParam }) => { - try { - return await getNoticeByPinPoint>({ - url: HOME_RECOMMENDED_ENDPOINT, - params: { page: Number(pageParam), offSet: 10 }, - }); - } catch (e) { - if (axios.isAxiosError(e)) { - const message = e.response?.data?.message ?? e.response?.data?.error ?? e.message; - toast.error(message); - throw new Error(message); - } - throw e instanceof Error ? e : new Error("Unknown error"); - } - }, - getNextPageParam: lastPage => { - return lastPage.hasNext ? lastPage.pages + 1 : undefined; + const data = await getNoticeByPinPoint>({ + url: HOME_RECOMMENDED_ENDPOINT, + params: { page: Number(pageParam), offSet: 10 }, + }); + + sessionStorage.setItem(recommendedFetchedKey(userName), "query"); + return data; }, + getNextPageParam: lastPage => (lastPage.hasNext ? lastPage.pages + 1 : undefined), }); }; diff --git a/src/features/home/index.ts b/src/features/home/index.ts index feecdcb..97d2772 100644 --- a/src/features/home/index.ts +++ b/src/features/home/index.ts @@ -1,5 +1,5 @@ export * from "./ui/homeContentsCard"; -export * from "./ui/homeActionCardList"; +export * from "./ui/homeAction/homeActionCardList"; export * from "./ui/homeContentsCard"; export * from "./ui/homeHeader"; export * from "./ui/homeHero"; diff --git a/src/features/home/ui/homeAction/homeActionCardList.tsx b/src/features/home/ui/homeAction/homeActionCardList.tsx new file mode 100644 index 0000000..2e5acba --- /dev/null +++ b/src/features/home/ui/homeAction/homeActionCardList.tsx @@ -0,0 +1,15 @@ +"use client"; +import { useHomeActionCard } from "@/src/features/home/ui/homeUseHooks/homeUseHooks"; +import { PinpointStandard } from "@/src/features/home/ui/homeAction/pinpointStandard"; +import { QualificationDiagnosis } from "@/src/features/home/ui/homeAction/qualificationdiagnosis"; + +export const ActionCardList = () => { + const { onListingsPageMove, onEligibilityPageMove } = useHomeActionCard(); + + return ( +
+ + +
+ ); +}; diff --git a/src/features/home/ui/homeAction/pinpointStandard.tsx b/src/features/home/ui/homeAction/pinpointStandard.tsx new file mode 100644 index 0000000..7af9f87 --- /dev/null +++ b/src/features/home/ui/homeAction/pinpointStandard.tsx @@ -0,0 +1,35 @@ +import { ArrowUpRight } from "@/src/assets/icons/button/arrowUpRight"; +import { useNoticeCount } from "@/src/entities/home/hooks/homeHooks"; +import { useOAuthStore } from "@/src/features/login/model"; +import { useInfiniteQuery } from "@tanstack/react-query"; +import { SliceResponse } from "@/src/entities/home/model/type"; +import { ListingItem } from "@/src/entities/listings/model/type"; +import { getNoticeByPinPoint } from "@/src/entities/home/interface/homeInterface"; +import { HOME_RECOMMENDED_ENDPOINT } from "@/src/shared/api"; + +type PinpointStandardProps = { + onListingsPageMove: () => void; +}; + +export const PinpointStandard = ({ onListingsPageMove }: PinpointStandardProps) => { + const { data } = useNoticeCount(); + const count = data?.count; + console.log(count); + return ( +
+
+

+ 핀포인트 기준 +

+
+ +
+
+ +

{count}건

+
+ ); +}; diff --git a/src/features/home/ui/homeAction/qualificationdiagnosis.tsx b/src/features/home/ui/homeAction/qualificationdiagnosis.tsx new file mode 100644 index 0000000..a103141 --- /dev/null +++ b/src/features/home/ui/homeAction/qualificationdiagnosis.tsx @@ -0,0 +1,38 @@ +import { ArrowUpRight } from "@/src/assets/icons/button/arrowUpRight"; +import { useRecommendedNotice } from "@/src/entities/home/hooks/homeHooks"; + +type QualificationDiagnosisProps = { + onEligibilityPageMove: () => void; +}; +export const QualificationDiagnosis = ({ onEligibilityPageMove }: QualificationDiagnosisProps) => { + const { data: recommend } = useRecommendedNotice(); + const count = recommend?.pages[0]?.totalCount; + + return ( +
+
+

+ 자격진단 기준 +

+ +
+ +
+
+ +
+

{count ? count : "0"}건

+ +

0% 완료

+
+
+
+ ); +};