Skip to content

Commit

Permalink
Merge pull request #191 from isd-sgcu/tee/fix-modal-not-show
Browse files Browse the repository at this point in the history
Tee/fix modal not show
  • Loading branch information
TeeGoood authored Jul 28, 2024
2 parents 0085d16 + db9824b commit 3fb0eaf
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 88 deletions.
4 changes: 2 additions & 2 deletions src/app/(main)/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ export default function Home() {
throw new Error('');
}
} catch (e) {
console.log('fetch check in', e);
console.log('error fetch checkin', e);
}
};

checkedIn();
}, []);
}, [user]);

const checkInConfirm = async () => {
if (!user) {
Expand Down
3 changes: 1 addition & 2 deletions src/app/(main)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Footer from '@/components/(main)/Footer';
import BaanProvider from '@/context/BaanContext';
import React from 'react';

const layout = ({
Expand All @@ -9,7 +8,7 @@ const layout = ({
}>) => {
return (
<main className="bg-1 overflow-auto">
<BaanProvider>{children}</BaanProvider>
{children}
<Footer />
</main>
);
Expand Down
32 changes: 16 additions & 16 deletions src/components/(main)/home/BaanResultModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -26,7 +25,6 @@ const BaanResultModal: React.FC<BaanResultModalProps> = ({
}) => {
const router = useRouter();
const [mode, setMode] = useState<'th' | 'en'>('th');
const { isConfirmed } = useBaan();
const { user } = useAuth();

const HandleOnClick = () => {
Expand All @@ -43,7 +41,7 @@ const BaanResultModal: React.FC<BaanResultModalProps> = ({

return (
<div>
{isConfirmed && !!baan ? (
{baan ? (
<BaseModal
variant="blue"
open={modal}
Expand Down Expand Up @@ -139,19 +137,21 @@ const BaanResultModal: React.FC<BaanResultModalProps> = ({
{baan.ig}
</Link>
</div>
<div className="flex justify-center text-base text-center text-white items-center w-full gap-1 mt-2 mb-3">
<Image
src={LineIconWhite}
alt="lineIcon"
/>
<div className="">line group:</div>
<Link
href={baan.line}
className="text-center truncate underline underline-offset-auto decoration-from-font w-[50%]"
>
{baan.line}
</Link>
</div>
{baan.line && (
<div className="flex justify-center text-base text-center text-white items-center w-full gap-1 mt-2 mb-3">
<Image
src={LineIconWhite}
alt="lineIcon"
/>
<div className="">line group:</div>
<Link
href={baan.line}
className="text-center truncate underline underline-offset-auto decoration-from-font w-[50%]"
>
{baan.line}
</Link>
</div>
)}
</div>
</div>
</BaseModal>
Expand Down
81 changes: 43 additions & 38 deletions src/components/(main)/home/CustomButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useBaan } from '@/context/BaanContext';
import { cn } from '@/lib/utils';
import { createEbookCount } from '@/utils/count';
import { useRouter } from 'next/navigation';
Expand Down Expand Up @@ -34,71 +33,77 @@ const CustomButton: React.FC<CustomButtonProps> = ({
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 &&
Expand Down
2 changes: 0 additions & 2 deletions src/components/firstdate/MenuList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export default function MenuList({ isRewardPage }: TwoCircleMenuProps) {
);
}, [giftCondition, isRewardPage]);

console.log(giftCondition);

return (
<div>
{giftCondition && isShowReward && (
Expand Down
5 changes: 0 additions & 5 deletions src/components/rpkm/Modal/BaanFullModal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,9 +13,6 @@ interface BaanFullModalProps {
* @param setOpen - function
*/
export default function FullBannModal({ open, setOpen }: BaanFullModalProps) {
useEffect(() => {
console.log('KJINKJIHKOJI', open);
}, [open]);
return (
<BaseModal
variant={'black'}
Expand Down
3 changes: 1 addition & 2 deletions src/components/rpkm/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function Navbar() {
/>
</Link>
);
}, []);
}, [currentPath]);

return (
<div className="z-10 relative w-full">
Expand All @@ -75,7 +75,6 @@ function Navbar() {
/>
</button>
)}
dv
{content}
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/rpkm/Sidebar/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ function UserInfo() {
</h1>

<h1 className="text-xs font-semibold text-center text-black">
{isShowBaan && user?.baan}
{isShowBaan &&
baanInfos.find((baan) => baan.name.en == user?.baan)?.name.th}
</h1>
{baan ? (
{baan?.line ? (
<div className="flex flex-col justify-center items-center w-full">
<div className="flex justify-center text-xs font-semibold text-center text-black items-center w-full gap-1">
<Image
Expand Down
26 changes: 7 additions & 19 deletions src/context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand Down

0 comments on commit 3fb0eaf

Please sign in to comment.