Skip to content

Commit

Permalink
refactor: getApplicantState 함수를 유틸함수로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
smb0123 committed Sep 18, 2024
1 parent cc6dae1 commit e2d85e0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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[];
Expand All @@ -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 {
Expand All @@ -57,7 +59,7 @@ const ApplicantResource = ({
navbarId,
]);

const snapshotState = queryClient.getQueryData<getApplicantStateRes>([
const snapshotState = queryClient.getQueryData<ApplicantPassState>([
"applicantState",
applicantId,
navbarId,
Expand Down
13 changes: 0 additions & 13 deletions frontend/src/apis/applicant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<getApplicantStateRes> => {
const cardsData = await getKanbanCards(navigationId, generation);

return cardsData.find((card) => card.applicantId === applicantId)?.state
.passState;
};
9 changes: 9 additions & 0 deletions frontend/src/utils/applicant/index.ts
Original file line number Diff line number Diff line change
@@ -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;
};

0 comments on commit e2d85e0

Please sign in to comment.