Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b58b4d443 |
@@ -13,15 +13,15 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
|
||||||
|
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
|
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||||
with:
|
with:
|
||||||
node-version: 24
|
node-version: 22
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"eventDates": ["2025-09-05", "2025-10-25", "2025-12-06", "1999-01-01"],
|
"eventDates": ["2025-09-05", "1999-01-01"],
|
||||||
"cutoffTime": "23:00",
|
"cutoffTime": "23:00",
|
||||||
"blockDurationHours": 6,
|
|
||||||
"message": "Sign-ups are closed for today's event. Please come back tomorrow.",
|
"message": "Sign-ups are closed for today's event. Please come back tomorrow.",
|
||||||
|
|
||||||
"internalComment": "Add event dates in YYYY-MM-DD format. Signups will be disabled after cutoffTime (23:00) for blockDurationHours (6 hours)."
|
"internalComment": "Add event dates in YYYY-MM-DD format. Signups will be disabled after 11pm (23:00) on these dates by default."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
import { isSignupBlocked } from "./signup-time-check";
|
|
||||||
|
|
||||||
// Test helper to check different scenarios
|
|
||||||
function testScenario(description: string, date: Date, expected: boolean) {
|
|
||||||
const result = isSignupBlocked(date);
|
|
||||||
const status = result.blocked === expected ? "✅ PASS" : "❌ FAIL";
|
|
||||||
console.log(`${status} ${description}`);
|
|
||||||
console.log(` Expected blocked: ${expected}, Got: ${result.blocked}`);
|
|
||||||
if (result.message) {
|
|
||||||
console.log(` Message: ${result.message}`);
|
|
||||||
}
|
|
||||||
console.log();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run tests
|
|
||||||
console.log("Testing signup blocking logic...\n");
|
|
||||||
|
|
||||||
// October 25, 2025 at 22:00 (before cutoff)
|
|
||||||
testScenario("Oct 25 at 22:00 - Before cutoff", new Date("2025-10-25T22:00:00"), false);
|
|
||||||
|
|
||||||
// October 25, 2025 at 23:00 (exactly at cutoff)
|
|
||||||
testScenario("Oct 25 at 23:00 - At cutoff time", new Date("2025-10-25T23:00:00"), true);
|
|
||||||
|
|
||||||
// October 25, 2025 at 23:30 (during block period)
|
|
||||||
testScenario("Oct 25 at 23:30 - During block period", new Date("2025-10-25T23:30:00"), true);
|
|
||||||
|
|
||||||
// October 26, 2025 at 02:00 (3 hours into block)
|
|
||||||
testScenario("Oct 26 at 02:00 - 3 hours into block", new Date("2025-10-26T02:00:00"), true);
|
|
||||||
|
|
||||||
// October 26, 2025 at 04:59 (just before block ends)
|
|
||||||
testScenario("Oct 26 at 04:59:59 - Just before block ends", new Date("2025-10-26T04:59:59"), true);
|
|
||||||
|
|
||||||
// October 26, 2025 at 05:00 (block period over)
|
|
||||||
testScenario("Oct 26 at 05:00 - Block period ended", new Date("2025-10-26T05:00:00"), false);
|
|
||||||
|
|
||||||
// October 26, 2025 at 12:00 (well after block)
|
|
||||||
testScenario("Oct 26 at 12:00 - Well after block", new Date("2025-10-26T12:00:00"), false);
|
|
||||||
|
|
||||||
// Random non-event date
|
|
||||||
testScenario("Oct 20 at 23:00 - Non-event date", new Date("2025-10-20T23:00:00"), false);
|
|
||||||
@@ -1,23 +1,17 @@
|
|||||||
import eventConfig from "@/event-dates.json";
|
import eventConfig from "@/event-dates.json";
|
||||||
|
|
||||||
export function isSignupBlocked(currentTime?: Date): { blocked: boolean; message?: string } {
|
export function isSignupBlocked(): { blocked: boolean; message?: string } {
|
||||||
const now = currentTime || new Date();
|
const now = new Date();
|
||||||
const cutoffTime = eventConfig.cutoffTime || "15:00";
|
const currentDate = now.toISOString().split("T")[0]; // YYYY-MM-DD format
|
||||||
const blockDurationHours = eventConfig.blockDurationHours || 6;
|
const currentTime = now.toTimeString().slice(0, 5); // HH:MM format
|
||||||
|
|
||||||
// Check each event date to see if we're in a block period
|
// Check if today is an event date
|
||||||
for (const eventDate of eventConfig.eventDates) {
|
const isEventDay = eventConfig.eventDates.includes(currentDate);
|
||||||
// Parse the event date and cutoff time in local timezone
|
|
||||||
const [year, month, day] = eventDate.split("-").map(Number);
|
|
||||||
const [hours, minutes] = cutoffTime.split(":").map(Number);
|
|
||||||
const blockStart = new Date(year, month - 1, day, hours, minutes, 0, 0);
|
|
||||||
|
|
||||||
// Calculate when the block period ends (using wall-clock hours to handle DST correctly)
|
if (isEventDay) {
|
||||||
const blockEnd = new Date(blockStart);
|
// Check if current time is after the cutoff time (default 15:00 / 3pm)
|
||||||
blockEnd.setHours(blockStart.getHours() + blockDurationHours);
|
const cutoffTime = eventConfig.cutoffTime || "15:00";
|
||||||
|
if (currentTime >= cutoffTime) {
|
||||||
// Check if current time is within the block period
|
|
||||||
if (now >= blockStart && now < blockEnd) {
|
|
||||||
return {
|
return {
|
||||||
blocked: true,
|
blocked: true,
|
||||||
message: eventConfig.message,
|
message: eventConfig.message,
|
||||||
|
|||||||
22
package.json
22
package.json
@@ -18,7 +18,7 @@
|
|||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cssnano": "^7.1.0",
|
"cssnano": "^7.1.0",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"lucide-react": "^0.552.0",
|
"lucide-react": "^0.542.0",
|
||||||
"next": "^15.4.1",
|
"next": "^15.4.1",
|
||||||
"next-plausible": "^3.12.4",
|
"next-plausible": "^3.12.4",
|
||||||
"postcss-flexbugs-fixes": "^5.0.2",
|
"postcss-flexbugs-fixes": "^5.0.2",
|
||||||
@@ -32,17 +32,17 @@
|
|||||||
"zod": "^4.0.5"
|
"zod": "^4.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "4.1.16",
|
"@tailwindcss/postcss": "4.1.12",
|
||||||
"@types/node": "24.9.2",
|
"@types/node": "22.18.0",
|
||||||
"@types/react": "19.2.2",
|
"@types/react": "19.1.12",
|
||||||
"@types/react-dom": "19.2.2",
|
"@types/react-dom": "19.1.9",
|
||||||
"eslint": "9.39.0",
|
"eslint": "9.34.0",
|
||||||
"eslint-config-next": "15.5.6",
|
"eslint-config-next": "15.5.2",
|
||||||
"eslint-config-prettier": "10.1.8",
|
"eslint-config-prettier": "10.1.8",
|
||||||
"postcss": "8.5.6",
|
"postcss": "8.5.6",
|
||||||
"tailwindcss": "4.1.16",
|
"tailwindcss": "4.1.12",
|
||||||
"turbo": "2.6.0",
|
"turbo": "2.5.6",
|
||||||
"typescript": "5.9.3"
|
"typescript": "5.9.2"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.20.0"
|
"packageManager": "pnpm@10.15.0"
|
||||||
}
|
}
|
||||||
|
|||||||
1886
pnpm-lock.yaml
generated
1886
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user