Skip to content

Commit

Permalink
#14 fix : done
Browse files Browse the repository at this point in the history
  • Loading branch information
luckylooky2 committed Mar 19, 2023
1 parent 7a98078 commit 2afe91f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions front/src/components/party/PartyDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,26 @@ const PartyDetail = (): JSX.Element => {
const [isCheck, setIsCheck] = useState<boolean>(false);
const [isWriter, setIsWriter] = useState<boolean>(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({
...response.data,
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 (
<>
Expand Down

0 comments on commit 2afe91f

Please sign in to comment.