Skip to content

Commit

Permalink
#14 getPartyDetail sync
Browse files Browse the repository at this point in the history
  • Loading branch information
luckylooky2 committed Mar 19, 2023
1 parent 8f73ab3 commit e956e24
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions front/src/components/party/PartyDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,18 @@ 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;
};

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({
...response.data,
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화 하기
Expand Down

0 comments on commit e956e24

Please sign in to comment.