Skip to content

Commit f71c50a

Browse files
authored
Merge pull request #308 from WeGo-Together/somang-feat/group-details
[Feat] 모임신청 이후 대기중 버튼 작업
2 parents 1d904ea + c4682c3 commit f71c50a

File tree

9 files changed

+130
-70
lines changed

9 files changed

+130
-70
lines changed

src/app/group/[groupId]/page.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,14 @@ const GroupDetailPage = ({ params }: Props) => {
2222

2323
if (!data) return null;
2424

25-
const {
26-
images,
27-
status,
28-
joinPolicy,
29-
myMembership,
30-
joinedMembers,
31-
participantCount,
32-
maxParticipants,
33-
} = data;
25+
const { images, status, joinPolicy, myMembership, joinedMembers } = data;
3426

3527
return (
3628
<div>
3729
<GroupBannerImages images={images} />
3830
<GroupDescriptions descriptions={data} />
3931
<GroupMembers isHost={myMembership?.role === 'HOST'} members={joinedMembers} />
40-
<GroupButtons
41-
conditions={{
42-
isHost: myMembership?.role === 'HOST',
43-
isJoined: myMembership?.status === 'ATTEND',
44-
isPast: status === 'FINISHED',
45-
isPending: myMembership?.status === 'PENDING',
46-
isFreeGroup: joinPolicy === 'FREE',
47-
isAttendDisabled: participantCount >= maxParticipants || status === 'FINISHED',
48-
}}
49-
/>
32+
<GroupButtons statuses={{ status, myMembership, joinPolicy }} />
5033
</div>
5134
);
5235
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Button } from '@/components/ui';
2+
3+
export const FinishedButton = () => {
4+
return <Button disabled={true}>모임 마감</Button>;
5+
};
Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,34 @@
11
'use client';
22

3-
// import { useRouter } from 'next/navigation';
4-
5-
import { GroupModal } from '@/components/pages/group/group-modal';
6-
import { Button } from '@/components/ui/button';
7-
import { useModal } from '@/components/ui/modal';
3+
import { FinishedButton } from '@/components/pages/group/group-buttons/finished-button';
4+
import { JoiningButton } from '@/components/pages/group/group-buttons/joining-button';
5+
import { MembersButton } from '@/components/pages/group/group-buttons/members-button';
6+
import { PendingButton } from '@/components/pages/group/group-buttons/pending-button';
7+
import { GetGroupDetailsResponse } from '@/types/service/group';
88

99
interface Props {
10-
conditions: {
11-
isJoined: boolean;
12-
isHost: boolean;
13-
isPast: boolean;
14-
isPending: boolean;
15-
isAttendDisabled: boolean;
16-
isFreeGroup: boolean;
17-
};
10+
statuses: Pick<GetGroupDetailsResponse, 'status' | 'myMembership' | 'joinPolicy'>;
1811
}
1912

20-
export const GroupButtons = ({
21-
conditions: { isJoined, isHost, isPast, isFreeGroup, isAttendDisabled },
22-
}: Props) => {
23-
const { open } = useModal();
24-
// const { push } = useRouter();
13+
export const GroupButtons = ({ statuses: { status, myMembership, joinPolicy } }: Props) => {
14+
const isMember = myMembership?.status === 'ATTEND' && status !== 'FINISHED';
15+
16+
const isPending = myMembership?.status === 'PENDING' && status !== 'FINISHED';
17+
18+
const isFinished = status === 'FINISHED';
2519

26-
// 그룹 채팅방 아이디 추가해야됨
27-
const onEnterChatClick = () => {
28-
alert('채팅 파업');
29-
// push('/message/id');
30-
};
20+
const canJoin = !isMember && !isPending && !isFinished;
3121

3222
return (
3323
<div className='sticky bottom-[56px] border-t-1 border-gray-200 bg-white px-4 py-3'>
34-
{isJoined ? (
35-
<div className='flex gap-[10px]'>
36-
<Button
37-
className='flex-[1.2]'
38-
disabled={isPast}
39-
variant='tertiary'
40-
onClick={() => open(<GroupModal type={isHost ? 'delete' : 'leave'} />)}
41-
>
42-
{isHost ? '모임 취소' : '모임 탈퇴'}
43-
</Button>
44-
<Button className='flex-2' disabled={isPast} onClick={onEnterChatClick}>
45-
채팅 입장
46-
</Button>
47-
</div>
48-
) : (
49-
<Button
50-
disabled={isAttendDisabled}
51-
onClick={() => open(<GroupModal type={isFreeGroup ? 'attend' : 'approval'} />)}
52-
>
53-
{isFreeGroup ? '참여하기' : '참여 신청하기'}
54-
</Button>
24+
{canJoin && (
25+
<JoiningButton
26+
conditions={{ isGroupFull: status === 'FULL', isFreeGroup: joinPolicy === 'FREE' }}
27+
/>
5528
)}
29+
{isPending && <PendingButton />}
30+
{isMember && <MembersButton conditions={{ isHost: myMembership.role === 'HOST' }} />}
31+
{isFinished && <FinishedButton />}
5632
</div>
5733
);
5834
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { GroupModal } from '@/components/pages/group/group-modal';
2+
import { Button } from '@/components/ui';
3+
import { useModal } from '@/components/ui';
4+
5+
interface Props {
6+
conditions: {
7+
isGroupFull: boolean;
8+
isFreeGroup: boolean;
9+
};
10+
}
11+
12+
export const JoiningButton = ({ conditions: { isGroupFull, isFreeGroup } }: Props) => {
13+
const { open } = useModal();
14+
15+
return (
16+
<Button
17+
disabled={isGroupFull}
18+
onClick={() => open(<GroupModal type={isFreeGroup ? 'attend' : 'approval'} />)}
19+
>
20+
{isFreeGroup ? '참여하기' : '참여 신청하기'}
21+
</Button>
22+
);
23+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// import { useRouter } from 'next/navigation';
2+
3+
import { GroupModal } from '@/components/pages/group/group-modal';
4+
import { Button, useModal } from '@/components/ui';
5+
6+
interface Props {
7+
conditions: {
8+
isHost: boolean;
9+
};
10+
}
11+
12+
export const MembersButton = ({ conditions: { isHost } }: Props) => {
13+
const { open } = useModal();
14+
// const { push } = useRouter();
15+
16+
// 그룹 채팅방 아이디 추가해야됨
17+
const onEnterChatClick = () => {
18+
alert('채팅 파업');
19+
// push('/message/id');
20+
};
21+
22+
return (
23+
<div className='flex gap-[10px]'>
24+
<Button
25+
className='flex-[1.2]'
26+
variant='tertiary'
27+
onClick={() => open(<GroupModal type={isHost ? 'delete' : 'leave'} />)}
28+
>
29+
{isHost ? '모임 취소' : '모임 탈퇴'}
30+
</Button>
31+
<Button className='flex-2' onClick={onEnterChatClick}>
32+
채팅 입장
33+
</Button>
34+
</div>
35+
);
36+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { GroupModal } from '@/components/pages/group/group-modal';
2+
import { Button } from '@/components/ui';
3+
import { useModal } from '@/components/ui';
4+
5+
export const PendingButton = () => {
6+
const { open } = useModal();
7+
8+
return (
9+
<div className='flex gap-[10px]'>
10+
<Button
11+
className='flex-[1.2]'
12+
variant='tertiary'
13+
onClick={() => open(<GroupModal type='pending' />)}
14+
>
15+
신청 취소
16+
</Button>
17+
<Button className='flex-2' disabled={true}>
18+
대기중
19+
</Button>
20+
</div>
21+
);
22+
};

src/components/pages/group/group-descriptions/description-sections/description-profile/index.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import Link from 'next/link';
22

33
import { ImageWithFallback } from '@/components/ui';
4+
import { PendingBadge } from '@/components/ui';
45
import { GetGroupDetailsResponse } from '@/types/service/group';
56

67
interface Props {
78
hostInfo: GetGroupDetailsResponse['createdBy'];
9+
groupId: number;
810
conditions: {
911
isHost: boolean;
10-
isPast: boolean;
12+
isPending: boolean;
13+
isFinished: boolean;
1114
};
12-
groupId: number;
1315
}
1416

1517
export const DescriptionProfile = ({
1618
hostInfo: { userId, nickName, profileImage, profileMessage },
17-
conditions: { isHost, isPast },
19+
conditions: { isHost, isPending, isFinished },
1820
groupId,
1921
}: Props) => {
22+
const isEditable = isHost && !isFinished;
23+
2024
return (
2125
<div className='flex-between w-full select-none'>
2226
<Link href={`/profile/${userId}`} className='flex gap-3'>
@@ -33,8 +37,9 @@ export const DescriptionProfile = ({
3337
{profileMessage && <p className='text-text-xs-regular text-gray-600'>{profileMessage}</p>}
3438
</div>
3539
</Link>
36-
{isPast && <p className='text-text-xs-semibold pr-1 text-gray-500'>모임 마감</p>}
37-
{isHost && !isPast && (
40+
{isFinished && <p className='text-text-xs-semibold pr-1 text-gray-500'>모임 마감</p>}
41+
{isPending && <PendingBadge children={'대기중'} variant='md' />}
42+
{isEditable && (
3843
<Link
3944
href={`/create-group/${groupId}`}
4045
className='text-text-xs-semibold text-mint-500 pr-1'

src/components/pages/group/group-descriptions/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ export const GroupDescriptions = ({
4545
return (
4646
<section className='bg-white px-5 pt-6 pb-4'>
4747
<DescriptionProfile
48-
conditions={{ isHost: myMembership?.role === 'HOST', isPast: status === 'FINISHED' }}
48+
conditions={{
49+
isHost: myMembership?.role === 'HOST',
50+
isPending: myMembership?.status === 'PENDING',
51+
isFinished: status === 'FINISHED',
52+
}}
4953
groupId={id}
5054
hostInfo={createdBy}
5155
/>

src/components/pages/group/group-modal/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useKickGroupMember } from '@/hooks/use-group/use-group-kick';
1111
import { useLeaveGroup } from '@/hooks/use-group/use-group-leave';
1212
import { AttendGroupPayload } from '@/types/service/group';
1313

14-
type ModalType = 'attend' | 'approval' | 'leave' | 'delete' | 'kick';
14+
type ModalType = 'attend' | 'approval' | 'pending' | 'leave' | 'delete' | 'kick';
1515

1616
interface BaseProps {
1717
type: Exclude<ModalType, 'kick'>;
@@ -46,6 +46,7 @@ export const GroupModal = (props: Props) => {
4646
const mutateByType = {
4747
attend: () => attendMutate(undefined),
4848
approval: (message: AttendGroupPayload) => attendMutate(message),
49+
pending: () => leaveMutate(),
4950
leave: () => leaveMutate(),
5051
delete: async () => {
5152
await deleteMutate();
@@ -88,6 +89,11 @@ const MODAL_CONTENTS = {
8889
description: '참여 신청 메세지',
8990
confirmMessage: '신청하기',
9091
}),
92+
pending: () => ({
93+
title: '참여 신청을 취소하시겠어요?',
94+
description: '조금만 더 기다려 보는건 어떨까요?',
95+
confirmMessage: '취소하기',
96+
}),
9197
leave: () => ({
9298
title: '모임을 정말 탈퇴하시겠어요?',
9399
description: '탈퇴 시 그룹채팅과 모임 활동이 종료돼요.',

0 commit comments

Comments
 (0)