Skip to content

Commit

Permalink
Merge pull request #1081 from academic-relations/dev
Browse files Browse the repository at this point in the history
Merge dev into main
  • Loading branch information
pbc1017 authored Sep 19, 2024
2 parents caed2aa + fbad069 commit ff3c491
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default class ActivityRepository {
name: contents.name,
activityStatusEnumId: Number(contents.activityTypeEnumId),
location: contents.location,
purpose: contents.location,
purpose: contents.purpose,
detail: contents.detail,
evidence: contents.evidence,
activityDId: contents.activityDId,
Expand Down
146 changes: 69 additions & 77 deletions packages/web/src/app/manage-club/members/page.tsx
Original file line number Diff line number Diff line change
@@ -1,79 +1,71 @@
"use client";

// 배포용 not found 페이지 (시작) - 회원 등록
import NotFound from "@sparcs-clubs/web/app/not-found";

const TemporaryNotFound = () => <NotFound />;

export default TemporaryNotFound;
// 배포용 not found 페이지 (끝)

// import React, { useEffect, useState } from "react";

// import { RegistrationDeadlineEnum } from "@sparcs-clubs/interface/common/enum/registration.enum";

// import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary";
// import LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";
// import NoManageClub from "@sparcs-clubs/web/common/frames/NoManageClub";
// import NotRegistrationPeriod from "@sparcs-clubs/web/common/frames/NotRegistrationPeriod";
// import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";
// import { useGetRegistrationTerm } from "@sparcs-clubs/web/features/clubs/services/useGetRegistrationTerm";
// import ManageClubMembers from "@sparcs-clubs/web/features/manage-club/members/frames/ManageClubMembersFrame";

// const Members = () => {
// const { isLoggedIn, login, profile } = useAuth();
// const [loading, setLoading] = useState(true);

// useEffect(() => {
// if (isLoggedIn !== undefined || profile !== undefined) {
// setLoading(false);
// }
// }, [isLoggedIn, profile]);

// const { data, isLoading, isError } = useGetRegistrationTerm();
// const [isRegistrationPeriod, setIsRegistrationPeriod] =
// useState<boolean>(false);

// useEffect(() => {
// if (data) {
// const now = new Date();
// const currentEvents = data.events.filter(
// event => now >= event.startTerm && now <= event.endTerm,
// );
// if (currentEvents.length === 0) {
// setIsRegistrationPeriod(false);
// return;
// }
// const registrationEvent = currentEvents.filter(
// event =>
// event.registrationEventEnumId ===
// RegistrationDeadlineEnum.StudentRegistrationApplication,
// );
// if (registrationEvent.length > 0) {
// setIsRegistrationPeriod(true);
// } else {
// setIsRegistrationPeriod(false);
// }
// }
// }, [data]);

// if (loading || isLoading) {
// return <AsyncBoundary isLoading={loading || isLoading} isError={isError} />;
// }

// if (!isRegistrationPeriod) {
// return <NotRegistrationPeriod />;
// }

// if (!isLoggedIn) {
// return <LoginRequired login={login} />;
// }

// if (profile?.type !== "undergraduate") {
// return <NoManageClub />;
// }

// return <ManageClubMembers />;
// };

// export default Members;
import React, { useEffect, useState } from "react";

import { RegistrationDeadlineEnum } from "@sparcs-clubs/interface/common/enum/registration.enum";

import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary";
import LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";
import NoManageClub from "@sparcs-clubs/web/common/frames/NoManageClub";
import NotRegistrationPeriod from "@sparcs-clubs/web/common/frames/NotRegistrationPeriod";
import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";
import { useGetRegistrationTerm } from "@sparcs-clubs/web/features/clubs/services/useGetRegistrationTerm";
import ManageClubMembers from "@sparcs-clubs/web/features/manage-club/members/frames/ManageClubMembersFrame";

const Members = () => {
const { isLoggedIn, login, profile } = useAuth();
const [loading, setLoading] = useState(true);

useEffect(() => {
if (isLoggedIn !== undefined || profile !== undefined) {
setLoading(false);
}
}, [isLoggedIn, profile]);

const { data, isLoading, isError } = useGetRegistrationTerm();
const [isRegistrationPeriod, setIsRegistrationPeriod] =
useState<boolean>(false);

useEffect(() => {
if (data) {
const now = new Date();
const currentEvents = data.events.filter(
event => now >= event.startTerm && now <= event.endTerm,
);
if (currentEvents.length === 0) {
setIsRegistrationPeriod(false);
return;
}
const registrationEvent = currentEvents.filter(
event =>
event.registrationEventEnumId ===
RegistrationDeadlineEnum.StudentRegistrationApplication,
);
if (registrationEvent.length > 0) {
setIsRegistrationPeriod(true);
} else {
setIsRegistrationPeriod(false);
}
}
}, [data]);

if (loading || isLoading) {
return <AsyncBoundary isLoading={loading || isLoading} isError={isError} />;
}

if (!isRegistrationPeriod) {
return <NotRegistrationPeriod />;
}

if (!isLoggedIn) {
return <LoginRequired login={login} />;
}

if (profile?.type !== "undergraduate") {
return <NoManageClub />;
}

return <ManageClubMembers />;
};

export default Members;
3 changes: 2 additions & 1 deletion packages/web/src/common/services/getUserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const useGetUserProfile = () =>
switch (status) {
case 200:
case 304:
return apiUsr001.responseBodyMap[200].parse(data);
// return apiUsr001.responseBodyMap[200].parse(data);
return data;
default:
throw new UnexpectedAPIResponseError();
}
Expand Down
6 changes: 2 additions & 4 deletions packages/web/src/constants/manageClubMembers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { getDate, getHours, getMinutes, getMonth, getYear } from "date-fns";
import { formatDateTime } from "../utils/Date/formatDate";

const newMemberListSectionInfoText = (semester: string, deadline: Date) =>
`현재는 ${semester}학기 동아리 신청 기간입니다
(신청 마감 : ${getYear(deadline)}${getMonth(deadline)}${getDate(deadline)}
${getHours(deadline)}:${getMinutes(deadline)})`;
`현재는 ${semester}학기 동아리 신청 기간입니다 (신청 마감 : ${formatDateTime(deadline)})`;

export { newMemberListSectionInfoText };
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const ClubInfoTitle = styled(ClubInfoItemInner)`
font-size: 14px;
line-height: 20px;
}
white-space: nowrap;
justify-content: center;
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface PersonInfoCardProps {

const StyledCard = styled(Card)`
width: fit-content;
min-width: 300px;
max-width: 100%;
padding: 16px 20px !important;
gap: 40px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import apiReg006 from "@sparcs-clubs/interface/api/registration/endpoint/apiReg0

import { useQuery } from "@tanstack/react-query";

import { mockMemberRegister } from "@sparcs-clubs/web/features/my/services/_mock/mockMyRegister";

import {
axiosClientWithAuth,
defineAxiosMock,
UnexpectedAPIResponseError,
} from "@sparcs-clubs/web/lib/axios";

import mockupRegistraion from "./_mock/mockupRegistraion";

import type { ApiReg006ResponseOk } from "@sparcs-clubs/interface/api/registration/endpoint/apiReg006";

export const useGetMyMemberRegistration = () =>
Expand All @@ -32,5 +32,5 @@ export const useGetMyMemberRegistration = () =>
});

defineAxiosMock(mock => {
mock.onGet(apiReg006.url()).reply(() => [200, mockupRegistraion]);
mock.onGet(apiReg006.url()).reply(() => [200, mockMemberRegister]);
});
45 changes: 37 additions & 8 deletions packages/web/src/features/manage-club/frames/ManageClubFrame.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,54 @@
"use client";

import React from "react";
import React, { useEffect, useState } from "react";

import { ClubDelegateEnum } from "@sparcs-clubs/interface/common/enum/club.enum";

import { RegistrationDeadlineEnum } from "@sparcs-clubs/interface/common/enum/registration.enum";

import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary";
import FlexWrapper from "@sparcs-clubs/web/common/components/FlexWrapper";
import PageHead from "@sparcs-clubs/web/common/components/PageHead";
import NoManageClub from "@sparcs-clubs/web/common/frames/NoManageClub";
// import ActivityManageFrame from "@sparcs-clubs/web/features/manage-club/frames/ActivityManageFrame";
import { useGetRegistrationTerm } from "@sparcs-clubs/web/features/clubs/services/useGetRegistrationTerm";
import InfoManageFrame from "@sparcs-clubs/web/features/manage-club/frames/InfoManageFrame";
// import MembersManageFrame from "@sparcs-clubs/web/features/manage-club/frames/MembersManageFrame";
import MembersManageFrame from "@sparcs-clubs/web/features/manage-club/frames/MembersManageFrame";
// import ServiceManageFrame from "@sparcs-clubs/web/features/manage-club/frames/ServiceManageFrame";
import { useCheckManageClub } from "@sparcs-clubs/web/hooks/checkManageClub";

const ManageClubFrame: React.FC = () => {
const { delegate, isLoading } = useCheckManageClub();

if (isLoading) {
return <AsyncBoundary isLoading={isLoading} isError />;
const { data, isLoading: termIsLoading } = useGetRegistrationTerm();
const [isRegistrationPeriod, setIsRegistrationPeriod] =
useState<boolean>(false);

useEffect(() => {
if (data) {
const now = new Date();
const currentEvents = data.events.filter(
event => now >= event.startTerm && now <= event.endTerm,
);
if (currentEvents.length === 0) {
setIsRegistrationPeriod(false);
return;
}
const registrationEvent = currentEvents.filter(
event =>
event.registrationEventEnumId ===
RegistrationDeadlineEnum.StudentRegistrationApplication,
);
if (registrationEvent.length > 0) {
setIsRegistrationPeriod(true);
} else {
setIsRegistrationPeriod(false);
}
}
}, [data]);

if (isLoading || termIsLoading) {
return <AsyncBoundary isLoading={isLoading || termIsLoading} isError />;
}

if (delegate === undefined) {
Expand All @@ -34,10 +64,9 @@ const ManageClubFrame: React.FC = () => {
<InfoManageFrame
isRepresentative={delegate === ClubDelegateEnum.Representative}
/>
{/* TODO: 회원 등록 배포 때 MembersManageFrame 주석 해제 */}
{/* <ActivityManageFrame />
<MembersManageFrame />
<ServiceManageFrame /> */}
{/* <ActivityManageFrame /> */}
{isRegistrationPeriod && <MembersManageFrame />}
{/* <ServiceManageFrame /> */}
</FlexWrapper>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ const MembersManageFrame: React.FC = () => {
).length;
const totalCount = memberData && memberData.applies.length;

const title = `2024년 봄학기 (신청 ${appliedCount}명, 승인 ${approvedCount}명, 반려 ${rejectedCount}명 / 총 ${totalCount}명)`;
const mobileTitle = `2024년 봄학기`;
const title = `2024년 가을학기 (신청 ${appliedCount}명, 승인 ${approvedCount}명, 반려 ${rejectedCount}명 / 총 ${totalCount}명)`;
const mobileTitle = `2024년 가을학기`;
// TODO: 학기 받아올 수 있도록 수정

const theme = useTheme();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { newMemberListSectionInfoText } from "@sparcs-clubs/web/constants/manage

import RegisterMemberList from "../components/RegisterMemberList";

import { mockDeadline, mockSemester } from "./_mock/mockMembers";

const RegisterMemberListWrapper = styled.div`
display: flex;
flex-direction: column;
Expand All @@ -19,7 +17,8 @@ const RegisterMemberListWrapper = styled.div`
const RegisterMemberListFrame = () => (
<FoldableSectionTitle title="신청 회원 명단" childrenMargin="20px">
<RegisterMemberListWrapper>
<Info text={newMemberListSectionInfoText(mockSemester, mockDeadline)} />
{/* TODO: 실제 신청기간 보여주기 */}
<Info text={newMemberListSectionInfoText("2024년 가을", new Date())} />
<RegisterMemberList />
</RegisterMemberListWrapper>
</FoldableSectionTitle>
Expand Down
24 changes: 13 additions & 11 deletions packages/web/src/features/my/components/MyMemberTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";

import { ApiReg006ResponseOk } from "@sparcs-clubs/interface/api/registration/endpoint/apiReg006";

import {
createColumnHelper,
getCoreRowModel,
Expand All @@ -18,15 +20,15 @@ import {
import { getTagDetail } from "@sparcs-clubs/web/utils/getTagDetail";

interface MyMemberTableProps {
memberRegisterList: typeof mockMemberRegister;
memberRegisterList: ApiReg006ResponseOk;
}

const columnHelper =
createColumnHelper<(typeof mockMemberRegister)["applies"][number]>();

const columns = [
columnHelper.accessor("applyStatusEnum", {
id: "applyStatusEnum",
columnHelper.accessor("applyStatusEnumId", {
id: "applyStatusEnumId",
header: "상태",
cell: info => {
const { color, text } = getTagDetail(
Expand All @@ -37,26 +39,26 @@ const columns = [
},
size: 10,
}),
columnHelper.accessor("clubType", {
id: "clubType",
columnHelper.accessor("type", {
id: "type",
header: "구분",
cell: info => (
<Tag
color={getTagColorFromClubType(
info.getValue().type,
info.getValue().isPermanent,
info.row.original.type,
info.row.original.isPermanent,
)}
>
{getTagContentFromClubType(
info.getValue().type,
info.getValue().isPermanent,
info.row.original.type,
info.row.original.isPermanent,
)}
</Tag>
),
size: 10,
}),
columnHelper.accessor("clubDivision", {
id: "clubDivision",
columnHelper.accessor("divisionName", {
id: "divisionName",
header: "분과",
cell: info => (
<Tag color={getTagColorFromDivision(info.getValue())}>
Expand Down
Loading

0 comments on commit ff3c491

Please sign in to comment.