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

feat: 모집공고가 없을 시, 지원자 페이지에서 모집공고 생성 버튼 표시 #341

Merged
merged 1 commit into from
Jul 5, 2024
Merged
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
94 changes: 64 additions & 30 deletions src/Pages/Applicants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import { useApplicantsDetail } from '@/Hooks/study/useApplicantsDetail';
import { useCloseRecruitmentMutation } from '@/Hooks/recruitments/useCloseRecruitmentMutation';
import { RowDivider } from '@/Components/Common/Divider/RowDivider';
import Footer from '@/Components/Footer';
import { P, match } from 'ts-pattern';
import { useStudyDetail } from '@/Hooks/study/useStudyDetail';

export const ApplicantsPage = () => {
const studyId = Number(useParams().studyId);
const { user } = useUserStore();
const { data: ApplicantsDetail, isLoading } = useApplicantsDetail(studyId);
const { data: ApplicantsDetail, status } = useApplicantsDetail(studyId);
const { data: studyDetail, isSuccess } = useStudyDetail(studyId);

const study = ApplicantsDetail?.study;
const applicants: Applicant[] = ApplicantsDetail?.applicants;
const navigate = useNavigate();
Expand All @@ -35,35 +39,52 @@ export const ApplicantsPage = () => {
</Header>
<RowDivider />
<Main>
{isLoading ? (
<Loading />
) : (
<MainInner>
<ParentNav studyTitle={study.title} />
<InfoSection>
<InfoFields>
<InfoField title="현재 인원수" content={study.participantCount} flexDirection="column" />
<InfoField title="목표 인원수" content={study.participantLimit} flexDirection="column" />
</InfoFields>
<Applicants>
{applicants.map((applicant) => (
<ApplicantLi key={applicant.id}>
<ApplicantCard
studyId={studyId}
id={applicant.id}
title={study.title}
nickname={applicant.nickname}
email={applicant.email}
position={applicant.position}
isOwner={user?.id === study.owner.id}
reviewStatistics={applicant.reviewStatistics}
/>
</ApplicantLi>
))}
</Applicants>
</InfoSection>
</MainInner>
)}
{match([status, isSuccess])
.with(['pending', P._], () => <Loading />)
.with(['success', P._], () => (
<MainInner>
<ParentNav studyTitle={study.title} />
<InfoSection>
<InfoFields>
<InfoField title="현재 인원수" content={study.participantCount} flexDirection="column" />
<InfoField title="목표 인원수" content={study.participantLimit} flexDirection="column" />
</InfoFields>
<Applicants>
{applicants.map((applicant) => (
<ApplicantLi key={applicant.id}>
<ApplicantCard
studyId={studyId}
id={applicant.id}
title={study.title}
nickname={applicant.nickname}
email={applicant.email}
position={applicant.position}
isOwner={user?.id === study.owner.id}
reviewStatistics={applicant.reviewStatistics}
/>
</ApplicantLi>
))}
</Applicants>
</InfoSection>
</MainInner>
))
.with(['error', true], () => (
<MainInner>
<ParentNav studyTitle={studyDetail.study.title} />
<InfoSection>
<InfoFields>
<InfoField title="현재 인원수" content={studyDetail.study.participantCount} flexDirection="column" />
</InfoFields>
<PlaceHolder>
<PlaceHolderTitle>아직 스터디 모집 공고를 작성하지 않았어요!</PlaceHolderTitle>
<Button scheme="primary">
<Link to={`/studies/${studyDetail.study.id}/recruitments/create`}>모집공고 작성하기</Link>
</Button>
</PlaceHolder>
</InfoSection>
</MainInner>
))
.run()}
</Main>
{user?.id === study?.owner.id && (
<CloseSection>
Expand Down Expand Up @@ -288,3 +309,16 @@ const FooterSection = styled.div`
justify-content: center;
background: ${({ theme }) => theme.color.gray1};
`;

const PlaceHolder = styled.div`
padding: 72px 24px;
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
`;

const PlaceHolderTitle = styled.span`
color: ${({ theme }) => theme.color.black4};
${({ theme }) => theme.typo.ListLabel};
`;