Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKRF-464 fix: 신청이 아닐 경우에 대한 예외처리 #222

Merged
merged 2 commits into from
Dec 1, 2023
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
9 changes: 6 additions & 3 deletions src/components/UserApplyButton/UserApplyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import { getEventDetailResponse } from '@/types/api/getEventDetail';
import { useRef } from 'react';

interface UserApplyButton {
isToken: boolean;
eventId: string;
eventDetail: getEventDetailResponse;
applyModalOpen: () => void;
}

const UserApplyButton = ({ eventId, eventDetail, applyModalOpen }: UserApplyButton) => {
const UserApplyButton = ({ isToken, eventId, eventDetail, applyModalOpen }: UserApplyButton) => {
const bookmarkRef = useRef<HTMLDivElement>(null);
const { isBookmarked } = useIsBookmarkedQuery({ eventId });
const { category, hasAlreadyApplied, eventInfo, formInfo } = eventDetail ?? {};
Expand All @@ -33,8 +34,10 @@ const UserApplyButton = ({ eventId, eventDetail, applyModalOpen }: UserApplyButt
return EVENT_DETAIL_BUTTON.APPLY.APPLICANT;
} else if (category !== 'RECRUITMENT' && applicants >= capacity) {
return EVENT_DETAIL_BUTTON.APPLY.SOLD_OUT;
} else if (isEnded || isAbleToApply) {
} else if (isEnded) {
return EVENT_DETAIL_BUTTON.APPLY.DEADLINE;
} else if (!isAbleToApply) {
return EVENT_DETAIL_BUTTON.APPLY.NOT_PERIOD;
} else {
return EVENT_DETAIL_BUTTON.APPLY.POSSIBLE;
}
Expand All @@ -59,7 +62,7 @@ const UserApplyButton = ({ eventId, eventDetail, applyModalOpen }: UserApplyButt
>
{getApplyButtonText()}
</ApplyButton>
<BookmarkButton reverse bold onClick={() => bookmarkRef.current?.click()}>
<BookmarkButton reverse bold disabled={!isToken} onClick={() => bookmarkRef.current?.click()}>
<BookMark bookmarked={isBookmarked!} eventId={eventId} ref={bookmarkRef} />
</BookmarkButton>
</ButtonWrapper>
Expand Down
1 change: 1 addition & 0 deletions src/constants/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const EVENT_DETAIL_BUTTON = {
DELETE: '삭제하기',
APPLY: {
COMPLETED: '신청 완료',
NOT_PERIOD: '신청 기간이 아닙니다.',
SOLD_OUT: 'SOLD OUT',
DEADLINE: '신청 마감',
APPLICANT: '인원 마감',
Expand Down
5 changes: 5 additions & 0 deletions src/pages/event/EventDetailPage/EventDetailPage.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const ApplicantButton = styled(SemiPurpleButton)<{ capacity: boolean; isDisabled
const ApplyButton = styled(SemiPurpleButton)<{ capacity: boolean }>`
width: 30%;
min-width: 10rem;
padding: 0;
border-top-left-radius: ${({ capacity }) => capacity && '0'};
border-bottom-left-radius: ${({ capacity }) => capacity && '0'};
font-size: ${Theme.fontSize.mediumContent};
Expand All @@ -98,6 +99,10 @@ const ApplyButton = styled(SemiPurpleButton)<{ capacity: boolean }>`
const BookmarkButton = styled(SemiPurpleButton)`
margin-left: 0.5rem;
padding: 0 1.5rem;

&:disabled {
cursor: not-allowed;
}
`;

const EventContentWrapper = styled.div`
Expand Down
1 change: 1 addition & 0 deletions src/pages/event/EventDetailPage/EventDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const EventDetailPage = () => {
<DetailContentWrapper>
<CategoryDetailForm data={eventDetail!} />
<UserApplyButton
isToken={Boolean(token)}
eventId={eventId}
eventDetail={eventDetail!}
applyModalOpen={applyModalOpen}
Expand Down
Loading