From 06b7349fa42688dc8f2f879e6c8eff6c71454c47 Mon Sep 17 00:00:00 2001 From: KANGYONGSU23 Date: Thu, 14 Dec 2023 09:58:06 +0900 Subject: [PATCH] =?UTF-8?q?feat=20::=20=EB=B6=81=EB=A7=88=ED=81=AC=20useSt?= =?UTF-8?q?ate=EB=A1=9C=20=EA=B4=80=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recruitments/RecruitmentsCard.tsx | 123 +++++++++--------- 1 file changed, 64 insertions(+), 59 deletions(-) diff --git a/src/components/recruitments/RecruitmentsCard.tsx b/src/components/recruitments/RecruitmentsCard.tsx index 866b68d..d4850f4 100644 --- a/src/components/recruitments/RecruitmentsCard.tsx +++ b/src/components/recruitments/RecruitmentsCard.tsx @@ -2,11 +2,12 @@ import { useSetBookmarks } from "@/apis/bookmarks"; import { useGetRecruitmentsList } from "@/apis/recruitments"; +import { RecruitmentsListType } from "@/apis/recruitments/type"; import { money_regex } from "@/util/regex"; import { Icon } from "@team-return/design-system"; import Image from "next/image"; import { useSearchParams } from "next/navigation"; -import React from "react"; +import React, { useState } from "react"; import HoverPrefetchLink from "../common/HoverPrefetchLink"; import RecruitmentSkelton from "../common/Skelton/SkeltonElement"; @@ -17,70 +18,74 @@ interface PropsType { export default function RecruitmentsCard({ maxLength = 12 }: PropsType) { const getParams = useSearchParams(); - const { data: recruitmentsList, isLoading } = useGetRecruitmentsList(getParams.toString()); - - const { mutate: SetBookmarksMutate } = useSetBookmarks(); + const { data: recruitmentsList, isLoading } = useGetRecruitmentsList( + getParams.toString() + ); return (
{isLoading && } {recruitmentsList?.recruitments .filter((_, idx) => idx < maxLength) - .map( - ( - { - company_profile_url, - company_name, - train_pay, - hiring_jobs, - bookmarked, - id, - military_support, - }, - index - ) => ( - -
-
- -
-
-

- {hiring_jobs} -

-

- {company_name} -

-
-
실습수당 {money_regex(train_pay)}원
- {military_support &&
병역특례
} -
- -
-
-
- ) - )} + .map((item) => { + return ; + })}
); } + +function RecruitmentsItem({ + company_profile_url, + company_name, + train_pay, + hiring_jobs, + bookmarked, + id, + military_support, +}: RecruitmentsListType) { + const { mutate: SetBookmarksMutate } = useSetBookmarks(); + const [localBookmarked, setLocalBookmarked] = useState( + bookmarked || false + ); + + return ( + +
+
+ +
+
+

+ {hiring_jobs} +

+

+ {company_name} +

+
+
실습수당 {money_regex(train_pay)}원
+ {military_support &&
병역특례
} +
+ +
+
+
+ ); +}