Skip to content

Commit

Permalink
add major
Browse files Browse the repository at this point in the history
  • Loading branch information
TeeGoood committed Jul 18, 2024
1 parent c2ddc47 commit 7efc419
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 47 deletions.
94 changes: 47 additions & 47 deletions src/context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -40,6 +41,7 @@ export const majorMap = {
'37': 'สหเวชศาสตร์',
'38': 'จิตวิทยา',
'39': 'วิทยาศาสตร์การกีฬา',
'40': 'สำนักวิชาทรัพยากรการเกษตร'
};

export const getMajorNameById = (id: string): string => {
Expand Down

0 comments on commit 7efc419

Please sign in to comment.