-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1105 from academic-relations/dev
Merge dev into main
- Loading branch information
Showing
7 changed files
with
237 additions
and
155 deletions.
There are no files selected for viewing
99 changes: 68 additions & 31 deletions
99
packages/web/src/app/executive/register-member/[id]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
148
packages/web/src/app/executive/register-member/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.