-
Notifications
You must be signed in to change notification settings - Fork 8
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 #1576 from 42organization/agenda
[Feat] 7기 agenda 기능 main 통합
- Loading branch information
Showing
998 changed files
with
16,733 additions
and
2,050 deletions.
There are no files selected for viewing
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { usePathname } from 'next/navigation'; | ||
import AdminReject from 'components/admin/AdminReject'; | ||
import AdminLayout from 'components/admin/Layout'; | ||
import AgendaModalProvider from 'components/agenda/modal/AgendaModalProvider'; | ||
import ModalProvider from 'components/takgu/modal/ModalProvider'; | ||
import { useUser } from 'hooks/agenda/Layout/useUser'; | ||
|
||
type AdminLayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
function AdminAppLayout({ children }: AdminLayoutProps) { | ||
const user = useUser(); | ||
const presentPath = usePathname(); | ||
|
||
// 사용자 정보가 없거나 관리자가 아닐 경우 | ||
if (!user || !user.intraId) return null; | ||
|
||
if (!user.isAdmin) return <AdminReject />; | ||
|
||
// 모달 제공자 결정 | ||
let ModalProviderComponent; | ||
if (presentPath.includes('admin/takgu')) { | ||
ModalProviderComponent = ModalProvider; | ||
} else if (presentPath.includes('admin/agenda')) { | ||
ModalProviderComponent = AgendaModalProvider; | ||
} | ||
|
||
return ( | ||
<> | ||
<AdminLayout>{children}</AdminLayout> | ||
{ModalProviderComponent && <ModalProviderComponent />} | ||
</> | ||
); | ||
} | ||
|
||
export default AdminAppLayout; |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { instanceInAgenda } from 'utils/axios'; | ||
import AgendaHeader from 'components/agenda/Layout/AgendaHeader'; | ||
import AgendaModalProvider from 'components/agenda/modal/AgendaModalProvider'; | ||
import Footer from 'components/takgu/Layout/Footer'; | ||
import { useUser } from 'hooks/agenda/Layout/useUser'; | ||
import useAxiosWithToast from 'hooks/useAxiosWithToast'; | ||
import styles from 'styles/agenda/Layout/Layout.module.scss'; | ||
|
||
type AgendaLayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
function AgendaAppLayout({ children }: AgendaLayoutProps) { | ||
useAxiosWithToast(instanceInAgenda); // API의 성공 실패 스낵바로 알리는 기능 | ||
|
||
const user = useUser(); | ||
|
||
if (!user || !user.intraId) return null; | ||
|
||
const scrollToTop = () => { | ||
window.scrollTo({ top: 0, behavior: 'smooth' }); | ||
}; | ||
|
||
return ( | ||
<> | ||
<AgendaHeader /> | ||
<div className={styles.background}></div> | ||
<div className={styles.app}> | ||
{children} | ||
<Footer /> | ||
</div> | ||
<button onClick={scrollToTop} className={styles.floatingButton}> | ||
↑ | ||
</button> | ||
<AgendaModalProvider /> | ||
</> | ||
); | ||
} | ||
|
||
export default AgendaAppLayout; |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useRecoilValue } from 'recoil'; | ||
import { loginState } from 'utils/recoil/login'; | ||
import AdminAppLayout from 'Layout/AdminLayout'; | ||
import AgendaAppLayout from 'Layout/AgendaLayout'; | ||
import TakguAppLayout from 'Layout/TakguLayout'; | ||
import { usePathname } from 'hooks/agenda/Layout/usePathname'; | ||
import useAxiosAgendaError from 'hooks/useAxiosAgendaError'; | ||
import useAxiosResponse from 'hooks/useAxiosResponse'; | ||
|
||
type LayoutProviderProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
// 현재 페이지가 어떤 레이아웃을 사용할지 결정 | ||
// 로그인 스테이트 등은 각 레이아웃에서 확인 | ||
const LayoutProvider = ({ children }: LayoutProviderProps) => { | ||
useRecoilValue(loginState); | ||
useAxiosResponse(); // takgu axios response interceptor | ||
useAxiosAgendaError(); // agenda axios response interceptor | ||
|
||
const app = usePathname(); | ||
switch (app) { | ||
case '': | ||
case 'agenda': | ||
return <AgendaAppLayout>{children}</AgendaAppLayout>; | ||
case 'takgu': | ||
return <TakguAppLayout>{children}</TakguAppLayout>; | ||
case 'admin': | ||
return <AdminAppLayout>{children}</AdminAppLayout>; | ||
default: | ||
return <>{children}</>; | ||
} | ||
}; | ||
|
||
export default LayoutProvider; |
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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { useRouter } from 'next/router'; | ||
import { useRecoilValue } from 'recoil'; | ||
import { openCurrentMatchState } from 'utils/recoil/takgu/match'; | ||
import CurrentMatch from 'components/takgu/Layout/CurrentMatch'; | ||
import Footer from 'components/takgu/Layout/Footer'; | ||
import Header from 'components/takgu/Layout/Header'; | ||
import HeaderStateContext from 'components/takgu/Layout/HeaderContext'; | ||
import MainPageProfile from 'components/takgu/Layout/MainPageProfile'; | ||
import Megaphone from 'components/takgu/Layout/MegaPhone'; | ||
import RecruitLayout from 'components/takgu/recruit/RecruitLayout'; | ||
import Statistics from 'pages/takgu/statistics'; | ||
import { usePathname } from 'hooks/agenda/Layout/usePathname'; | ||
import useAnnouncementCheck from 'hooks/takgu/Layout/useAnnouncementCheck'; | ||
import useGetUserSeason from 'hooks/takgu/Layout/useGetUserSeason'; | ||
import useLiveCheck from 'hooks/takgu/Layout/useLiveCheck'; | ||
import useSetAfterGameModal from 'hooks/takgu/Layout/useSetAfterGameModal'; | ||
import { useUser } from 'hooks/takgu/Layout/useUser'; | ||
import styles from 'styles/takgu/Layout/Layout.module.scss'; | ||
import PlayButton from '../components/takgu/Layout/PlayButton'; | ||
import UserLayout from '../components/takgu/Layout/UserLayout'; | ||
import ModalProvider from '../components/takgu/modal/ModalProvider'; | ||
import CustomizedSnackbars from '../components/toastmsg/toastmsg'; | ||
|
||
type TakguLayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const TakguLayout = ({ children }: TakguLayoutProps) => { | ||
const user = useUser(); | ||
const presentPath = usePathname(); | ||
const path = useRouter().pathname; | ||
const openCurrentMatch = useRecoilValue(openCurrentMatchState); | ||
|
||
useGetUserSeason(presentPath); | ||
useSetAfterGameModal(); | ||
useLiveCheck(presentPath); | ||
useAnnouncementCheck(presentPath); | ||
|
||
if (!user || !user.intraId) return null; | ||
|
||
const renderContent = () => { | ||
if (path.includes('takgu/recruit')) { | ||
return <RecruitLayout>{children}</RecruitLayout>; | ||
} | ||
|
||
if (path.includes('takgu/statistics') && user.isAdmin) { | ||
return ( | ||
<UserLayout> | ||
<Statistics /> | ||
</UserLayout> | ||
); | ||
} | ||
|
||
if (presentPath.includes('takgu')) { | ||
return ( | ||
<> | ||
<UserLayout> | ||
<HeaderStateContext> | ||
<Header /> | ||
</HeaderStateContext> | ||
<PlayButton /> | ||
<div className={styles.topInfo}> | ||
<Megaphone /> | ||
{openCurrentMatch ? <CurrentMatch /> : ''} | ||
{presentPath === '/' ? <MainPageProfile /> : ''} | ||
</div> | ||
{children} | ||
<Footer /> | ||
</UserLayout> | ||
<ModalProvider /> | ||
</> | ||
); | ||
} | ||
return <>{children}</>; | ||
}; | ||
|
||
return renderContent(); | ||
}; | ||
|
||
{ | ||
/* UserLayout : 배경색 제공 */ | ||
/* LoginChecker : 미로그인시 에러 던짐 */ | ||
/* ErrorChecker : 에러 리코일 체크해서 에러 페이지로 던짐 */ | ||
} | ||
const TakguAppLayout = ({ children }: TakguLayoutProps) => { | ||
return ( | ||
<> | ||
<TakguLayout>{children}</TakguLayout> | ||
<CustomizedSnackbars /> | ||
</> | ||
); | ||
}; | ||
|
||
export default TakguAppLayout; |
Oops, something went wrong.