From 7efc419a7b2f7827b1cfdec8fecfef5b99afa6d1 Mon Sep 17 00:00:00 2001 From: teegoood Date: Thu, 18 Jul 2024 14:59:44 +0700 Subject: [PATCH] add major --- src/context/AuthContext.tsx | 94 ++++++++++++++++++------------------- src/utils/register.ts | 2 + 2 files changed, 49 insertions(+), 47 deletions(-) diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index ba9f0cda..10d31846 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -69,53 +69,53 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({ const isRegistered = isUserRegistered(userObj); const isRegisterPage = path.includes('register'); - if (isStaff) { - if (path == '/') { - return router.push('firstdate/staff/home'); - } - - if (!isRegistered && !isRegisterPage) { - return router.push('/staff/register'); - } - if (!isStaffPage) { - return router.push('/firstdate/staff/home'); - } - } else { - if (path == '/') { - return router.push('/home'); - } - - if (!isRegistered && !isRegisterPage) { - return router.push('/register'); - } - - if (path.split('/').at(-1) == 'reward') { - const condition = getReceiveGiftCondition(userObj); - - if (condition.status != 'ready') { - return router.push('/firstdate/home'); - } - } - - if (isStaffPage) { - return router.push('/firstdate/home'); - } - - if (path !== 'home') { - const firstdate = new Date( - process.env.NEXT_PUBLIC_FIRST_DATE_DATE as string - ); - const rpkm = new Date(process.env.NEXT_PUBLIC_RUP_PEUN_DATE as string); - const current = new Date(); - - if ( - (path.includes('firstdate') && current < firstdate) || - (path.includes('rpkm') && current < rpkm) - ) { - return router.push('/home'); - } - } - } + // if (isStaff) { + // if (path == '/') { + // return router.push('firstdate/staff/home'); + // } + + // if (!isRegistered && !isRegisterPage) { + // return router.push('/staff/register'); + // } + // if (!isStaffPage) { + // return router.push('/firstdate/staff/home'); + // } + // } else { + // if (path == '/') { + // return router.push('/home'); + // } + + // if (!isRegistered && !isRegisterPage) { + // return router.push('/register'); + // } + + // if (path.split('/').at(-1) == 'reward') { + // const condition = getReceiveGiftCondition(userObj); + + // if (condition.status != 'ready') { + // return router.push('/firstdate/home'); + // } + // } + + // if (isStaffPage) { + // return router.push('/firstdate/home'); + // } + + // if (path !== 'home') { + // const firstdate = new Date( + // process.env.NEXT_PUBLIC_FIRST_DATE_DATE as string + // ); + // const rpkm = new Date(process.env.NEXT_PUBLIC_RUP_PEUN_DATE as string); + // const current = new Date(); + + // if ( + // (path.includes('firstdate') && current < firstdate) || + // (path.includes('rpkm') && current < rpkm) + // ) { + // return router.push('/home'); + // } + // } + // } setisReady(true); }, [router, path]); diff --git a/src/utils/register.ts b/src/utils/register.ts index 9034810d..4d76e922 100644 --- a/src/utils/register.ts +++ b/src/utils/register.ts @@ -18,6 +18,7 @@ export const major: { id: string; name: string }[] = [ { id: '37', name: 'สหเวชศาสตร์' }, { id: '38', name: 'จิตวิทยา' }, { id: '39', name: 'วิทยาศาสตร์การกีฬา' }, + { id: '40', name: 'สำนักวิชาทรัพยากรการเกษตร' }, ]; export const majorMap = { @@ -40,6 +41,7 @@ export const majorMap = { '37': 'สหเวชศาสตร์', '38': 'จิตวิทยา', '39': 'วิทยาศาสตร์การกีฬา', + '40': 'สำนักวิชาทรัพยากรการเกษตร' }; export const getMajorNameById = (id: string): string => {