From e956e249493ca78ca54c2a778180f23f90dc97bc Mon Sep 17 00:00:00 2001 From: luckylooky2 Date: Mon, 20 Mar 2023 01:42:45 +0900 Subject: [PATCH] #14 getPartyDetail sync --- front/src/components/party/PartyDetail.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/front/src/components/party/PartyDetail.tsx b/front/src/components/party/PartyDetail.tsx index 1400961..65f34a0 100644 --- a/front/src/components/party/PartyDetail.tsx +++ b/front/src/components/party/PartyDetail.tsx @@ -50,17 +50,6 @@ const PartyDetail = (): JSX.Element => { const [isCheck, setIsCheck] = useState(false); const [isWriter, setIsWriter] = useState(false); - const isParticipant = (user: string): boolean => { - for (const index in detail.participator) { - if (detail.participator[index] === user) return true; - } - return false; - }; - - if (intraId === detail.writer) setIsWriter(true); - else if (isParticipant(intraId)) setIsCheck(true); - else setIsCheck(false); - const getPartyDetail = async () => { const response = await PartyService.getPartyDetail(id); // 없는 페이지일 경우 404를 받도록? setDetail({ @@ -68,6 +57,11 @@ const PartyDetail = (): JSX.Element => { due_date: new Date(response.data.due_date), create_at: new Date(response.data.create_at), }); + if (intraId === response.data.writer) setIsWriter(true); + else { + for (const index in response.data.participator) + if (response.data.participator[index] === intraId) setIsCheck(true); + } }; // async화 하기