From 2afe91f851f6d965f6b83e0d1cfc938fd6f11594 Mon Sep 17 00:00:00 2001 From: luckylooky2 Date: Mon, 20 Mar 2023 04:50:37 +0900 Subject: [PATCH] #14 fix : done --- front/src/components/party/PartyDetail.tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/front/src/components/party/PartyDetail.tsx b/front/src/components/party/PartyDetail.tsx index 5b687eb..fcb8d86 100644 --- a/front/src/components/party/PartyDetail.tsx +++ b/front/src/components/party/PartyDetail.tsx @@ -50,13 +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; - }; - const getPartyDetail = async () => { const response = await PartyService.getPartyDetail(id); // 없는 페이지일 경우 404를 받도록? setDetail({ @@ -64,16 +57,19 @@ const PartyDetail = (): JSX.Element => { due_date: new Date(response.data.due_date), create_at: new Date(response.data.create_at), }); - if (intraId === detail.writer) setIsWriter(true); + if (intraId === response.data.writer) setIsWriter(true); else setIsWriter(false); - if (isParticipant(intraId)) setIsCheck(true); - else setIsCheck(false); + for (const index in response.data.participator) { + if (response.data.participator[index] === intraId) + return setIsCheck(true); + } + return setIsCheck(false); }; // async화 하기 useEffect(() => { getPartyDetail(); - }, []); + }, [isCheck]); return ( <>