From 5a44de23c12fcbdd94c819b3624a2bf9f1ac75f7 Mon Sep 17 00:00:00 2001 From: teegoood Date: Sun, 4 Aug 2024 15:19:10 +0700 Subject: [PATCH] add: fix invalid date --- src/app/rpkm/staff/home/page.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/rpkm/staff/home/page.tsx b/src/app/rpkm/staff/home/page.tsx index e49fffd..392e25d 100644 --- a/src/app/rpkm/staff/home/page.tsx +++ b/src/app/rpkm/staff/home/page.tsx @@ -11,7 +11,7 @@ import ConfirmationModal from '@/components/rpkm/staff/home/qrscanner/confirmati import { CheckIn } from '@/types/checkIn'; import { FRESHYNIGHT_EVENT, RPKM_DAY_1, RPKM_DAY_2 } from '@/utils/date'; import StudentCodeInput from '@/components/rpkm/staff/home/qrscanner/StudentCodeInput'; -import moment from 'moment'; +// import moment from 'moment'; function Page() { const [eventText, setEventText] = useState(''); @@ -81,14 +81,18 @@ function Page() { if (newCheckInData) { if (newCheckInData.checkIn.isDuplicate) { - const date = moment(newCheckInData.checkIn.timestamp); + // const date = moment(newCheckInData.checkIn.timestamp); + let time = newCheckInData.checkIn.timestamp.split(' ')[1]; + time = + ((parseInt(time.split(':')[0]) + 7) % 24) + ':' + time.split(':')[1]; + setStatus('error'); setError(
ผู้ใช้สแกน QR-code นี้แล้ว
-
{newCheckInData.checkIn.timestamp}
- {`เมื่อเวลา ${date.format('HH:mm')} น.`} + {/* {`เมื่อเวลา ${date.format('HH:mm')} น.`} */} + {`เมื่อเวลา ${time} น.`}
); setErrorTopic('Already taken!');