-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 40 additions & 38 deletions
78
app/frontend/src/components/MogacoDetail/DetailHeaderButtons.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,60 @@ | ||
import { Button } from '@/components'; | ||
|
||
const buttonComponents = { | ||
participating: ( | ||
<Button theme="primary" shape="fill" size="large"> | ||
참석하기 | ||
</Button> | ||
), | ||
participated: ( | ||
<> | ||
<Button theme="primary" shape="fill" size="large"> | ||
채팅 | ||
</Button> | ||
<Button theme="danger" shape="fill" size="large"> | ||
참석 취소 | ||
</Button> | ||
</> | ||
), | ||
hosted: ( | ||
<> | ||
<Button theme="primary" shape="line" size="large"> | ||
수정 | ||
</Button> | ||
<Button theme="danger" shape="line" size="large"> | ||
삭제 | ||
</Button> | ||
</> | ||
), | ||
closed: ( | ||
<Button theme="primary" shape="fill" size="large" disabled> | ||
마감 | ||
</Button> | ||
), | ||
}; | ||
import { mogaco } from '@/services'; | ||
|
||
type DetailHeaderButtonsProps = { | ||
id: string; | ||
userHosted: boolean; | ||
userParticipated: boolean; | ||
status: '모집 중' | '마감' | '종료'; | ||
}; | ||
|
||
export function DetailHeaderButtons({ | ||
id, | ||
userHosted, | ||
userParticipated, | ||
status, | ||
}: DetailHeaderButtonsProps) { | ||
const onClickJoin = async () => { | ||
await mogaco.join(id); | ||
}; | ||
|
||
const onClickQuit = async () => { | ||
await mogaco.quit(id); | ||
}; | ||
|
||
if (userHosted) { | ||
return buttonComponents.hosted; | ||
return ( | ||
<> | ||
<Button theme="primary" shape="line" size="large"> | ||
수정 | ||
</Button> | ||
<Button theme="danger" shape="line" size="large"> | ||
삭제 | ||
</Button> | ||
</> | ||
); | ||
} | ||
|
||
if (status === '모집 중') { | ||
return userParticipated | ||
? buttonComponents.participated | ||
: buttonComponents.participating; | ||
return userParticipated ? ( | ||
<> | ||
<Button theme="primary" shape="fill" size="large"> | ||
채팅 | ||
</Button> | ||
<Button theme="danger" shape="fill" size="large" onClick={onClickQuit}> | ||
참석 취소 | ||
</Button> | ||
</> | ||
) : ( | ||
<Button theme="primary" shape="fill" size="large" onClick={onClickJoin}> | ||
참석하기 | ||
</Button> | ||
); | ||
} | ||
|
||
return buttonComponents.closed; | ||
return ( | ||
<Button theme="primary" shape="fill" size="large" disabled> | ||
마감 | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,16 @@ export function MogacoDetailPage({ | |
const [participantList, setParticipantList] = useState<Participant[] | null>( | ||
null, | ||
); | ||
const [user] = useUserAtom(); | ||
const [user, setUser] = useUserAtom(); | ||
|
||
if (!user) | ||
setUser({ | ||
providerId: '1', | ||
nickname: '지승', | ||
profilePicture: | ||
'https://avatars.githubusercontent.com/u/50646827?s=40&v=4', | ||
email: '[email protected]', | ||
}); | ||
|
||
const userHosted = user?.providerId === memberId; | ||
const userParticipated = participantList | ||
|
@@ -50,6 +59,7 @@ export function MogacoDetailPage({ | |
<div className={styles.wrapper}> | ||
<div className={styles.container}> | ||
<DetailHeader | ||
id={id} | ||
title={title} | ||
status={status} | ||
memberId={memberId} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters