Skip to content

Commit

Permalink
Merge pull request #1105 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 25, 2024
2 parents 4260e79 + 28da722 commit 40632f0
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 155 deletions.
99 changes: 68 additions & 31 deletions packages/web/src/app/executive/register-member/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,82 @@
"use client";

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

const TemporaryNotFound = () => <NotFound />;
import { RegistrationDeadlineEnum } from "@sparcs-clubs/interface/common/enum/registration.enum";

export default TemporaryNotFound;
// 배포용 not found 페이지 (끝)
import Custom404 from "@sparcs-clubs/web/app/not-found";
import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary";
import LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";

// import React, { useEffect, useState } from "react";
import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";

// import Custom404 from "@sparcs-clubs/web/app/not-found";
// import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary";
// import LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";
// import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";
import { useGetRegistrationTerm } from "@sparcs-clubs/web/features/clubs/services/useGetRegistrationTerm";

// import ExecutiveRegisterMemberDetail from "@sparcs-clubs/web/features/executive/register-member/frames/ExecutiveRegisterMemberDetailFrame";
import ExecutiveRegisterMemberDetail from "@sparcs-clubs/web/features/executive/register-member/frames/ExecutiveRegisterMemberDetailFrame";

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

// useEffect(() => {
// if (isLoggedIn !== undefined || profile !== undefined) {
// setLoading(false);
// }
// }, [isLoggedIn, profile]);
const {
data: termData,
isLoading: isLoadingTerm,
isError: isErrorTerm,
} = useGetRegistrationTerm();

// if (loading) {
// return <AsyncBoundary isLoading={loading} isError />;
// }
const [isRegistrationPeriod, setIsRegistrationPeriod] = useState<boolean>();

// if (!isLoggedIn) {
// return <LoginRequired login={login} />;
// }
useEffect(() => {
if (termData) {
const now = new Date();
const currentEvents = termData.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);
}
}
}, [termData]);

// if (profile?.type !== "executive") {
// return <Custom404 />;
// }
useEffect(() => {
if (isLoggedIn !== undefined || profile !== undefined) {
setLoading(false);
}
}, [isLoggedIn, profile]);

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

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

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

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

return <ExecutiveRegisterMemberDetail />;
};

export default RegisterMember;
148 changes: 93 additions & 55 deletions packages/web/src/app/executive/register-member/page.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,95 @@
"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 Custom404 from "@sparcs-clubs/web/app/not-found";
// 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 LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";
// import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";
// import { ExecutiveRegisterMember } from "@sparcs-clubs/web/features/executive/register-member/frames/ExecutiveRegisterMemberFrame";

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

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

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

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

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

// return (
// <FlexWrapper direction="column" gap={20}>
// <PageHead
// items={[
// { name: "집행부원 대시보드", path: "/executive" },
// { name: "회원 등록 신청 내역", path: `/executive/register-member` },
// ]}
// title="회원 등록 신청 내역"
// />
// <ExecutiveRegisterMember />
// </FlexWrapper>
// );
// };

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

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

import Custom404 from "@sparcs-clubs/web/app/not-found";
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 LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";

import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";

import { useGetRegistrationTerm } from "@sparcs-clubs/web/features/clubs/services/useGetRegistrationTerm";

import { ExecutiveRegisterMember } from "@sparcs-clubs/web/features/executive/register-member/frames/ExecutiveRegisterMemberFrame";

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

const {
data: termData,
isLoading: isLoadingTerm,
isError: isErrorTerm,
} = useGetRegistrationTerm();

const [isRegistrationPeriod, setIsRegistrationPeriod] = useState<boolean>();

useEffect(() => {
if (termData) {
const now = new Date();
const currentEvents = termData.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);
}
}
}, [termData]);

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

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

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

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

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

return (
<FlexWrapper direction="column" gap={20}>
<PageHead
items={[
{ name: "집행부원 대시보드", path: "/executive" },
{ name: "회원 등록 신청 내역", path: `/executive/register-member` },
]}
title="회원 등록 신청 내역"
/>
<ExecutiveRegisterMember />
</FlexWrapper>
);
};

export default RegisterMember;
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const useGetMyMemberRegistration = () =>

switch (status) {
case 200:
case 304:
return apiReg006.responseBodyMap[200].parse(data);
default:
throw new UnexpectedAPIResponseError();
Expand Down
Loading

0 comments on commit 40632f0

Please sign in to comment.