time selection must be before 01/16/2024

This commit is contained in:
Aaron Lee 2024-01-12 20:23:28 +08:00
parent 217d0cbd73
commit 42d67a5906

View file

@ -119,9 +119,8 @@ export const toggleAttendance = async (ctx: Context, input: { periodId: number,
if (!period) throw new TRPCError({ code: "NOT_FOUND", message: "Period not found" }); if (!period) throw new TRPCError({ code: "NOT_FOUND", message: "Period not found" });
if (checkWeekInAdvance) { if (checkWeekInAdvance) {
const weekInAdvance = new Date(); const weekInAdvance = new Date("2024/01/16 23:59");
weekInAdvance.setDate(weekInAdvance.getDate() + 7); if (new Date() > weekInAdvance) throw new TRPCError({ code: "BAD_REQUEST", message: "Time selection period has passed. Please contact HR." });
if (period.date < weekInAdvance) throw new TRPCError({ code: "BAD_REQUEST", message: "Period is not a week in advance. Please contact HR." });
} }
if (input.attendance) { if (input.attendance) {