+
+
('');
- const [event, setEvent] = useState('');
useEffect(() => {
- const checkEvent = async () => {
+ const initialize = async () => {
const currentTime = (await getCurrentTime()).currentTime;
+
const freshy_night_time = new Date(
process.env.NEXT_PUBLIC_FRESHY_NIGHT_EVENT as string
);
@@ -21,26 +21,16 @@ function Page() {
process.env.NEXT_PUBLIC_RPKM_DAY_2 as string
);
- if (currentTime > freshy_night_time) {
+ if (currentTime >= freshy_night_time) {
setEventText('Freshy Night');
- setEvent('freshy-night');
- return;
- }
-
- if (currentTime > rpkm_day_2_time) {
+ } else if (currentTime >= rpkm_day_2_time) {
setEventText('Onsite 4 สิงหาคม 2567');
- setEvent('rpkm-day-2');
- return;
- }
-
- if (currentTime > rpkm_day_1_time) {
+ } else if (currentTime >= rpkm_day_1_time) {
setEventText('Onsite 3 สิงหาคม 2567');
- setEvent('rpkm-day-1');
- return;
}
};
- checkEvent();
+ initialize();
}, []);
return (
@@ -74,7 +64,7 @@ function Page() {
{eventText}
-
+
QR-Reader
diff --git a/src/components/rpkm/Sidebar/FreshyNightLink.tsx b/src/components/rpkm/Sidebar/FreshyNightLink.tsx
index f7161941..01e672ad 100644
--- a/src/components/rpkm/Sidebar/FreshyNightLink.tsx
+++ b/src/components/rpkm/Sidebar/FreshyNightLink.tsx
@@ -1,3 +1,4 @@
+import { cn } from '@/lib/utils';
import { GetCheckIn } from '@/types/checkIn';
import { fetchCheckIn } from '@/utils/checkin';
import { getCurrentTime } from '@/utils/time';
@@ -25,10 +26,14 @@ const FreshyNightLink = ({ children }: FreshyNightLinkProps) => {
initialize();
}, []);
- const freshyNightDate = useMemo
(() => {
+ const freshyNightStartDate = useMemo(() => {
return new Date(process.env.NEXT_PUBLIC_FRESHY_NIGHT_DATE as string);
}, []);
+ const freshyNightEndDate = useMemo(() => {
+ return new Date(process.env.NEXT_PUBLIC_END_FRESHY_NIGHT_DATE as string);
+ }, []);
+
const isRegistered = useMemo(() => {
return (
!!checkins &&
@@ -37,7 +42,7 @@ const FreshyNightLink = ({ children }: FreshyNightLinkProps) => {
}, [checkins]);
const handleOnClick = () => {
- if (currentTime && currentTime < freshyNightDate) {
+ if (currentTime && currentTime < freshyNightStartDate) {
router.push('/rpkm/freshy-night/coming-soon');
return;
}
@@ -50,7 +55,17 @@ const FreshyNightLink = ({ children }: FreshyNightLinkProps) => {
router.push('/rpkm/freshy-night/register-done');
};
- return {children}
;
+ return (
+ freshyNightEndDate),
+ })}
+ >
+ {children}
+
+ );
};
export default FreshyNightLink;
diff --git a/src/components/rpkm/Sidebar/Menu.tsx b/src/components/rpkm/Sidebar/Menu.tsx
index 85129214..dbd4ee0a 100644
--- a/src/components/rpkm/Sidebar/Menu.tsx
+++ b/src/components/rpkm/Sidebar/Menu.tsx
@@ -10,12 +10,9 @@ function Menu() {
return (
-
+
ลงทะเบียนเลือกบ้าน
-
+
ลงทะเบียน Freshy Night
diff --git a/src/components/rpkm/Sidebar/UserInfo.tsx b/src/components/rpkm/Sidebar/UserInfo.tsx
index 7a13adf3..806ce80a 100644
--- a/src/components/rpkm/Sidebar/UserInfo.tsx
+++ b/src/components/rpkm/Sidebar/UserInfo.tsx
@@ -11,10 +11,12 @@ import { useAuth } from '@/context/AuthContext';
import Link from 'next/link';
import { baanInfos } from '../Baan/baanInfos';
import { getCurrentTime } from '@/utils/time';
+import QrCodeModal from '../freshy-night/QrCodeModal';
function UserInfo() {
const { user } = useAuth();
const [currentTime, setCurrentTime] = useState
(null);
+ const [qrModal, setQrModal] = useState(false);
const findBaan = (result: string) => {
return baanInfos.find((baan) => baan.name.en === result);
};
@@ -103,8 +105,8 @@ function UserInfo() {
+
);
}
diff --git a/src/components/rpkm/staff/home/qrscanner/QRScanner.tsx b/src/components/rpkm/staff/home/qrscanner/QRScanner.tsx
index a5e6a368..5ac7b404 100644
--- a/src/components/rpkm/staff/home/qrscanner/QRScanner.tsx
+++ b/src/components/rpkm/staff/home/qrscanner/QRScanner.tsx
@@ -1,5 +1,5 @@
'use client';
-import React, { ReactNode, useState } from 'react';
+import React, { ReactNode, useEffect, useState } from 'react';
import { QrReader } from 'react-qr-reader';
import { motion } from 'framer-motion';
import { useAuth } from '@/context/AuthContext';
@@ -8,10 +8,9 @@ import FailureModal from './failureModal';
import { createCheckIn } from '@/utils/checkin';
import { CheckIn } from '@/types/checkIn';
import dayjs from 'dayjs';
-interface ScanProp {
- event: string;
-}
-const Scan: React.FC