Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/app/schedule/_components/current.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export default function Current() {
const { items, error, fetchNextPage, hasNextPage, isFetchingNextPage, completedMessage } =
useInfiniteScroll<GroupListItemResponse, ['myGroups', 'current']>({
queryFn: async ({ cursor, size }) => {
return await API.groupService.getMyGroups({ type: 'current', cursor, size });
return await API.groupService.getMyGroups({
type: 'current',
cursor,
size,
myStatuses: ['ATTEND', 'PENDING'],
});
},
queryKey: ['myGroups', 'current'],
pageSize: 10,
Expand Down
3 changes: 3 additions & 0 deletions src/app/schedule/_components/meeting-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ export const MeetingList = ({
dateTime={formatDateTime(meeting.startTime)}
images={meeting.images}
isFinished={meeting.status === 'FINISHED'}
isHost={meeting.myMembership?.role === 'HOST'}
isPending={meeting.myMembership?.status === 'PENDING'}
joinPolicy={meeting.joinPolicy}
leaveAndChatActions={
showActions
? {
Expand Down
21 changes: 20 additions & 1 deletion src/components/shared/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type CardProps = {
tabType?: 'current' | 'myPost' | 'past';
isPending?: boolean;
isFinished?: boolean;
joinPolicy?: 'FREE' | 'APPROVAL_REQUIRED';
isHost?: boolean;
};

const calculateProgress = (count: number, max: number): number => {
Expand All @@ -39,6 +41,22 @@ const convertToCardTags = (tags: string[]): CardTag[] => {
return tags.map((tag, index) => ({ id: index, label: tag }));
};

const getLeaveButtonText = (
tabType?: 'current' | 'myPost' | 'past',
isHost?: boolean,
isPending?: boolean,
): string => {
if (tabType === 'myPost' || (tabType === 'current' && isHost)) {
return '모임 취소';
}

if (tabType === 'current' && isPending) {
return '신청 취소';
}

return '모임 탈퇴';
};

const Card = ({
title,
images,
Expand All @@ -54,12 +72,13 @@ const Card = ({
tabType,
isPending,
isFinished,
isHost,
}: CardProps) => {
const thumbnail = images?.[0];
const cardTags = convertToCardTags(tags);
const progress = calculateProgress(participantCount, maxParticipants);
const shouldShowButtons = leaveAndChatActions && tabType !== 'past';
const leaveButtonText = tabType === 'myPost' ? '모임 취소' : '모임 탈퇴';
const leaveButtonText = getLeaveButtonText(tabType, isHost, isPending);

return (
<div
Expand Down