From f691d3400837f4caecf3098b4f76727f452c259c Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 28 Jul 2024 12:07:39 +0700 Subject: [PATCH 01/10] remove BaanProvider from main folder layout --- src/app/(main)/layout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/(main)/layout.tsx b/src/app/(main)/layout.tsx index 94d4d662..ff5d195d 100644 --- a/src/app/(main)/layout.tsx +++ b/src/app/(main)/layout.tsx @@ -9,7 +9,7 @@ const layout = ({ }>) => { return (
- {children} + {children}
); From caeceff2843626500491cc098cd6fb38e0db7f49 Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 28 Jul 2024 12:08:15 +0700 Subject: [PATCH 02/10] fix: CustomButton rpkm logic --- src/components/(main)/home/CustomButton.tsx | 81 +++++++++++---------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/src/components/(main)/home/CustomButton.tsx b/src/components/(main)/home/CustomButton.tsx index 549ccc12..fed9e512 100644 --- a/src/components/(main)/home/CustomButton.tsx +++ b/src/components/(main)/home/CustomButton.tsx @@ -1,4 +1,3 @@ -import { useBaan } from '@/context/BaanContext'; import { cn } from '@/lib/utils'; import { createEbookCount } from '@/utils/count'; import { useRouter } from 'next/navigation'; @@ -34,71 +33,77 @@ const CustomButton: React.FC = ({ setJoinModal, }) => { const router = useRouter(); - const { isConfirmed } = useBaan(); + const firstdate = async () => { let firstDateDate = currentDate; const firstDate = process.env.NEXT_PUBLIC_FIRST_DATE_DATE; + if (firstDate) { firstDateDate = new Date(firstDate); } - console.log(currentDate.toISOString(), firstDateDate.toISOString()); - if (currentDate >= firstDateDate) { - if (registered) { - router.push('/firstdate/home'); - } else { - router.push('/register'); - } - } else if (setWaitModal && setEvent) { - setEvent('first-date'); - setWaitModal(true); + + if (currentDate < firstDateDate) { + setEvent && setEvent('first-date'); + setWaitModal && setWaitModal(true); + return; + } + + if (registered) { + router.push('/firstdate/home'); + } else { + router.push('/register'); } }; + const rubpeun = async () => { let rupPeunDate = currentDate; let closedSelectionDate = currentDate; let baanAnnounceDate = currentDate; + const rupPeun = process.env.NEXT_PUBLIC_RUP_PEUN_DATE; const closedSelection = process.env.NEXT_PUBLIC_CLOSED_BAAN_SELECTION_DATE; const announce = process.env.NEXT_PUBLIC_BAAN_ANNOUCE_DATE; + if (rupPeun) { rupPeunDate = new Date(rupPeun); } - if (closedSelection && announce) { + if (closedSelection) { closedSelectionDate = new Date(closedSelection); + } + + if (announce) { baanAnnounceDate = new Date(announce); } - console.log( - currentDate.toISOString(), - rupPeunDate.toISOString(), - closedSelectionDate.toISOString(), - baanAnnounceDate.toISOString() - ); + if (currentDate >= baanAnnounceDate) { - if (setJoinModal && setAnnounce && setBaanResultModal) { - if (isCheckedIn) { - if (baanResult) { - router.push('/rpkm/activities/home'); - } else { - setAnnounce(true); - setBaanResultModal(true); - } - } else { - setAnnounce(true); - setJoinModal(true); - } + if (!setJoinModal || !setAnnounce || !setBaanResultModal) { + return; + } + + if (!isCheckedIn) { + setAnnounce(true); + setJoinModal(true); + return; + } + + if (!baanResult) { + setAnnounce(true); + setBaanResultModal(true); + return; } + + router.push('/rpkm/activities/home'); } else if ( currentDate >= closedSelectionDate && currentDate < baanAnnounceDate ) { - if (!isConfirmed) { + if (isCheckedIn) { router.push('/rpkm/activities/home'); - } else if (setJoinModal) { - if (isCheckedIn) { - router.push('/rpkm/activities/home'); - } else { - setJoinModal(true); - } + return; + } + + if (setJoinModal) { + setJoinModal(true); } } else if ( currentDate >= rupPeunDate && From 5ca47400d36c13fb5d8e09b7d88a98367d8b4bd0 Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 28 Jul 2024 12:08:50 +0700 Subject: [PATCH 03/10] fix: remove unknown text from navbar --- src/components/rpkm/Navbar.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/rpkm/Navbar.tsx b/src/components/rpkm/Navbar.tsx index f17f3735..ab991669 100644 --- a/src/components/rpkm/Navbar.tsx +++ b/src/components/rpkm/Navbar.tsx @@ -75,7 +75,6 @@ function Navbar() { /> )} - dv {content} From cd6eeae97800894bfc68bf3b393c6d20338c9f79 Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 28 Jul 2024 12:09:41 +0700 Subject: [PATCH 04/10] refactor: AuthContext --- src/context/AuthContext.tsx | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index d522fa9e..c1916acd 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -119,44 +119,32 @@ const AuthProvider: React.FC<{ children: ReactNode }> = ({ const freshyNight = new Date( process.env.NEXT_PUBLIC_FRESHY_NIGHT_DATE as string ); - const now = (await getCurrentTime()).currentTime; - - console.log( - 'now', - now, - 'firstdate', - firstdate, - 'startRPKM', - startRPKM, - 'endBannSelect', - endBannSelect, - 'freshyNight', - freshyNight - ); + + const currentTime = (await getCurrentTime()).currentTime; + //firstdate if (path.includes('firstdate')) { - if (now < firstdate) { + if (currentTime < firstdate) { return router.push('/home'); } } //RPKM if (path.includes('rpkm')) { - if (now < startRPKM) { + if (currentTime < startRPKM) { return router.push('/home'); } // end baan select if (path.includes('rpkm/baan')) { - if (now > endBannSelect) { + if (currentTime > endBannSelect) { return router.push('/rpkm/activities/home'); } } // start freshy night if (path.includes('/freshy-night')) { - console.log(now, freshyNight); - if (now < freshyNight) { + if (currentTime < freshyNight) { return router.push('/rpkm/activities/home'); } } From 1681f067bbb51d1544946035f735d5ac45cda5c9 Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 28 Jul 2024 13:01:14 +0700 Subject: [PATCH 05/10] remove unused console.log --- src/app/(main)/home/page.tsx | 2 +- src/components/firstdate/MenuList.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/(main)/home/page.tsx b/src/app/(main)/home/page.tsx index 4c43c9e6..39af42e5 100644 --- a/src/app/(main)/home/page.tsx +++ b/src/app/(main)/home/page.tsx @@ -67,7 +67,7 @@ export default function Home() { throw new Error(''); } } catch (e) { - console.log('fetch check in', e); + console.log('error fetch checkin', e); } }; diff --git a/src/components/firstdate/MenuList.tsx b/src/components/firstdate/MenuList.tsx index 7885bccc..77e93557 100644 --- a/src/components/firstdate/MenuList.tsx +++ b/src/components/firstdate/MenuList.tsx @@ -53,7 +53,6 @@ export default function MenuList({ isRewardPage }: TwoCircleMenuProps) { ); }, [giftCondition, isRewardPage]); - console.log(giftCondition); return (
From fc5f357c9a84fc1509917cf492f4de1c3a75771a Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 28 Jul 2024 13:01:23 +0700 Subject: [PATCH 06/10] fix: don't show line when baan have no line --- .../(main)/home/BaanResultModal.tsx | 32 +++++++++---------- src/components/rpkm/Modal/BaanFullModal.tsx | 3 -- src/components/rpkm/Sidebar/UserInfo.tsx | 5 +-- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/components/(main)/home/BaanResultModal.tsx b/src/components/(main)/home/BaanResultModal.tsx index d7b8bdbd..ca0f8aa7 100644 --- a/src/components/(main)/home/BaanResultModal.tsx +++ b/src/components/(main)/home/BaanResultModal.tsx @@ -10,7 +10,6 @@ import InstagramIcon from '@public/rpkm/instagram-icon.svg'; import { baanInfos } from '@/components/rpkm/Baan/baanInfos'; import BaseModal from '@/components/rpkm/Modal/BaseModal'; import { cn } from '@/lib/utils'; -import { useBaan } from '@/context/BaanContext'; import { useAuth } from '@/context/AuthContext'; interface BaanResultModalProps { @@ -26,7 +25,6 @@ const BaanResultModal: React.FC = ({ }) => { const router = useRouter(); const [mode, setMode] = useState<'th' | 'en'>('th'); - const { isConfirmed } = useBaan(); const { user } = useAuth(); const HandleOnClick = () => { @@ -43,7 +41,7 @@ const BaanResultModal: React.FC = ({ return (
- {isConfirmed && !!baan ? ( + {!!baan ? ( = ({ {baan.ig}
-
- lineIcon -
line group:
- - {baan.line} - -
+ {baan.line && ( +
+ lineIcon +
line group:
+ + {baan.line} + +
+ )}
diff --git a/src/components/rpkm/Modal/BaanFullModal.tsx b/src/components/rpkm/Modal/BaanFullModal.tsx index b4dc107b..2cb056aa 100644 --- a/src/components/rpkm/Modal/BaanFullModal.tsx +++ b/src/components/rpkm/Modal/BaanFullModal.tsx @@ -15,9 +15,6 @@ interface BaanFullModalProps { * @param setOpen - function */ export default function FullBannModal({ open, setOpen }: BaanFullModalProps) { - useEffect(() => { - console.log('KJINKJIHKOJI', open); - }, [open]); return (

- {isShowBaan && user?.baan} + {isShowBaan && + baanInfos.find((baan) => baan.name.en == user?.baan)?.name.th}

- {baan ? ( + {baan?.line ? (
Date: Sun, 28 Jul 2024 13:04:42 +0700 Subject: [PATCH 07/10] lint fix --- src/app/(main)/home/page.tsx | 2 +- src/app/(main)/layout.tsx | 1 - src/components/(main)/home/BaanResultModal.tsx | 2 +- src/components/firstdate/MenuList.tsx | 1 - src/components/rpkm/Modal/BaanFullModal.tsx | 2 -- src/components/rpkm/Navbar.tsx | 2 +- 6 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/app/(main)/home/page.tsx b/src/app/(main)/home/page.tsx index 39af42e5..c855a63e 100644 --- a/src/app/(main)/home/page.tsx +++ b/src/app/(main)/home/page.tsx @@ -72,7 +72,7 @@ export default function Home() { }; checkedIn(); - }, []); + }, [user]); const checkInConfirm = async () => { if (!user) { diff --git a/src/app/(main)/layout.tsx b/src/app/(main)/layout.tsx index ff5d195d..8ba72ec3 100644 --- a/src/app/(main)/layout.tsx +++ b/src/app/(main)/layout.tsx @@ -1,5 +1,4 @@ import Footer from '@/components/(main)/Footer'; -import BaanProvider from '@/context/BaanContext'; import React from 'react'; const layout = ({ diff --git a/src/components/(main)/home/BaanResultModal.tsx b/src/components/(main)/home/BaanResultModal.tsx index ca0f8aa7..5e165a81 100644 --- a/src/components/(main)/home/BaanResultModal.tsx +++ b/src/components/(main)/home/BaanResultModal.tsx @@ -41,7 +41,7 @@ const BaanResultModal: React.FC = ({ return (
- {!!baan ? ( + {baan ? ( {giftCondition && isShowReward && ( diff --git a/src/components/rpkm/Modal/BaanFullModal.tsx b/src/components/rpkm/Modal/BaanFullModal.tsx index 2cb056aa..3f0eda66 100644 --- a/src/components/rpkm/Modal/BaanFullModal.tsx +++ b/src/components/rpkm/Modal/BaanFullModal.tsx @@ -1,5 +1,3 @@ -import { useEffect } from 'react'; - import BaseModal from '@/components/rpkm/Modal/BaseModal'; import ModalButton from '@/components/rpkm/Modal/ModalButton'; import modalStyles from '@/components/rpkm/Modal/ModalStyle'; diff --git a/src/components/rpkm/Navbar.tsx b/src/components/rpkm/Navbar.tsx index ab991669..c6bc5042 100644 --- a/src/components/rpkm/Navbar.tsx +++ b/src/components/rpkm/Navbar.tsx @@ -54,7 +54,7 @@ function Navbar() { /> ); - }, []); + }, [currentPath]); return (
From 05ae359426fdb174d0a1929e8ba01fa5d05cb69d Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 28 Jul 2024 13:22:49 +0700 Subject: [PATCH 08/10] fix: show baan's line on announce time --- src/components/rpkm/Sidebar/UserInfo.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/rpkm/Sidebar/UserInfo.tsx b/src/components/rpkm/Sidebar/UserInfo.tsx index 214aeebd..7a13adf3 100644 --- a/src/components/rpkm/Sidebar/UserInfo.tsx +++ b/src/components/rpkm/Sidebar/UserInfo.tsx @@ -67,7 +67,7 @@ function UserInfo() { {isShowBaan && baanInfos.find((baan) => baan.name.en == user?.baan)?.name.th} - {baan?.line ? ( + {isShowBaan && baan?.line ? (
Date: Sun, 28 Jul 2024 13:24:24 +0700 Subject: [PATCH 09/10] baan annouce dev 13.00 From c245dee7df9098cbbf2987f3acd0726b1ff1fb24 Mon Sep 17 00:00:00 2001 From: Idhibhat Pankam Date: Sun, 28 Jul 2024 13:26:40 +0700 Subject: [PATCH 10/10] baan annouce dev 13.00