diff --git a/frontend/components/applicant/applicantNode/CustomResource.component.tsx b/frontend/components/applicant/applicantNode/CustomResource.component.tsx index ac47efa0..ce057872 100644 --- a/frontend/components/applicant/applicantNode/CustomResource.component.tsx +++ b/frontend/components/applicant/applicantNode/CustomResource.component.tsx @@ -1,10 +1,5 @@ import Txt from "@/components/common/Txt.component"; -import { - ApplicantReq, - getApplicantState, - getApplicantStateRes, - patchApplicantState, -} from "@/src/apis/applicant"; +import { ApplicantReq, patchApplicantState } from "@/src/apis/applicant"; import { applicantDataFinder } from "@/src/functions/finder"; import Portfolio from "./Portfolio"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; @@ -13,6 +8,8 @@ import KanbanCardApplicantStatusLabel from "@/components/kanban/card/CardApplica import { useAtomValue } from "jotai"; import { KanbanSelectedButtonNumberState } from "@/src/stores/kanban/Navbar.atoms"; import { getMyInfo } from "@/src/apis/interview"; +import { findApplicantState } from "@/src/utils/applicant"; +import { ApplicantPassState, getKanbanCards } from "@/src/apis/kanban"; interface ApplicantResourceProps { data: ApplicantReq[]; @@ -36,7 +33,12 @@ const ApplicantResource = ({ isError, } = useQuery({ queryKey: ["applicantState", applicantId, navbarId], - queryFn: () => getApplicantState(navbarId, `${applicantId}`, generation), + queryFn: async () => + findApplicantState( + await getKanbanCards(navbarId, generation), + `${applicantId}` + ), + staleTime: 3000, }); const { @@ -57,7 +59,7 @@ const ApplicantResource = ({ navbarId, ]); - const snapshotState = queryClient.getQueryData([ + const snapshotState = queryClient.getQueryData([ "applicantState", applicantId, navbarId, diff --git a/frontend/src/apis/applicant/index.ts b/frontend/src/apis/applicant/index.ts index 6bc7655d..355e65dc 100644 --- a/frontend/src/apis/applicant/index.ts +++ b/frontend/src/apis/applicant/index.ts @@ -147,16 +147,3 @@ export const patchApplicantState = async ( return data; }; - -export type getApplicantStateRes = ApplicantPassState | undefined; - -export const getApplicantState = async ( - navigationId: string, - applicantId: string, - generation: string -): Promise => { - const cardsData = await getKanbanCards(navigationId, generation); - - return cardsData.find((card) => card.applicantId === applicantId)?.state - .passState; -}; diff --git a/frontend/src/utils/applicant/index.ts b/frontend/src/utils/applicant/index.ts new file mode 100644 index 00000000..3210c4aa --- /dev/null +++ b/frontend/src/utils/applicant/index.ts @@ -0,0 +1,9 @@ +import { KanbanCardReq } from "@/src/apis/kanban"; + +export const findApplicantState = ( + cardsData: KanbanCardReq[], + applicantId: string +) => { + return cardsData.find((card) => card.applicantId === applicantId)?.state + .passState; +};