forked from schulze/bam
Compare commits
89 Commits
renovate/a
...
renovate/m
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a81b65a06 | |||
| a00599ef22 | |||
| 34cb1fd4aa | |||
| 589d3b870e | |||
| fe5c9d4dae | |||
| 324f7d4061 | |||
| 778d65a357 | |||
| 1fdec62dbd | |||
| 4b02928b8f | |||
| a3bd460c0c | |||
| 4b93109582 | |||
| dba0d58477 | |||
| 3a5d65fc5c | |||
| eeed7ba07f | |||
| efa4907b49 | |||
| c53b6d18e5 | |||
| 110d7f25c9 | |||
| 6d6c7e9775 | |||
| aca89c0cab | |||
| 49665c375f | |||
| 9bbd282380 | |||
| 97be9dcacb | |||
| 62923affa0 | |||
| 134a7f8564 | |||
| cdb3bb060f | |||
| e5c272d028 | |||
| c8be8b2180 | |||
| 1350398ef0 | |||
| e6b3fa5654 | |||
| 07f98398c1 | |||
| 611266fed1 | |||
| 3019ad1795 | |||
| 3c01582293 | |||
| dcd02c655a | |||
| 2294ebd04a | |||
| 9c08db9d5f | |||
| 487a471b87 | |||
| b534ab3c14 | |||
| c8f766ef67 | |||
| cd63c5a9ce | |||
| a471595ef1 | |||
| af90787bb0 | |||
| d2f94b2c66 | |||
| 707a4220c3 | |||
| 199e8ba8b2 | |||
| 8eddc2a3d6 | |||
| 1bb2c715fc | |||
| c98e67d4ef | |||
| 8d847fdf2a | |||
| c67540febb | |||
| 699ec9fa26 | |||
| 75e50287cf | |||
| 0af9577400 | |||
| f202342297 | |||
| f930a9882d | |||
| a733f548bc | |||
| 895e44f930 | |||
| 22be09e87a | |||
| cb05115068 | |||
| 4e7cbd01e7 | |||
| 7fcea85ff1 | |||
| 4641430185 | |||
| 63064f29f8 | |||
| 3a00e01cab | |||
| 776f676947 | |||
| b9ed74ea66 | |||
| f27c23cde4 | |||
| b24c7a2169 | |||
| ded9a26818 | |||
| 48e39f5add | |||
| e16ad7619b | |||
| 7f61fd8ba1 | |||
| 313548166d | |||
| c2dbbb0df1 | |||
| d136e4463b | |||
| c81cbdc026 | |||
| 9f2d56332b | |||
| 1764e96d64 | |||
| 9e8adcd34e | |||
| eaebac6c2f | |||
| 697edf5372 | |||
| f45c18eb30 | |||
| 007b435306 | |||
| 9571e08478 | |||
| 206d725d61 | |||
| d998f2b751 | |||
| 21c73ba8cf | |||
| a4ba63f708 | |||
| 6b2fc6b859 |
@@ -16,12 +16,12 @@ jobs:
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
|
||||
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
|
||||
with:
|
||||
node-version: 22
|
||||
node-version: 24
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Install dependencies
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"eventDates": ["2025-09-05", "1999-01-01"],
|
||||
"cutoffTime": "15:00",
|
||||
"eventDates": ["2025-09-05", "2025-10-25", "2025-12-06", "1999-01-01"],
|
||||
"cutoffTime": "23:00",
|
||||
"blockDurationHours": 6,
|
||||
"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 3pm (15:00) on these dates by default."
|
||||
"internalComment": "Add event dates in YYYY-MM-DD format. Signups will be disabled after cutoffTime (23:00) for blockDurationHours (6 hours)."
|
||||
}
|
||||
|
||||
40
lib/signup-time-check.test.ts
Normal file
40
lib/signup-time-check.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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,17 +1,23 @@
|
||||
import eventConfig from "@/event-dates.json";
|
||||
|
||||
export function isSignupBlocked(): { blocked: boolean; message?: string } {
|
||||
const now = new Date();
|
||||
const currentDate = now.toISOString().split("T")[0]; // YYYY-MM-DD format
|
||||
const currentTime = now.toTimeString().slice(0, 5); // HH:MM format
|
||||
|
||||
// Check if today is an event date
|
||||
const isEventDay = eventConfig.eventDates.includes(currentDate);
|
||||
|
||||
if (isEventDay) {
|
||||
// Check if current time is after the cutoff time (default 15:00 / 3pm)
|
||||
export function isSignupBlocked(currentTime?: Date): { blocked: boolean; message?: string } {
|
||||
const now = currentTime || new Date();
|
||||
const cutoffTime = eventConfig.cutoffTime || "15:00";
|
||||
if (currentTime >= cutoffTime) {
|
||||
const blockDurationHours = eventConfig.blockDurationHours || 6;
|
||||
|
||||
// Check each event date to see if we're in a block period
|
||||
for (const eventDate of eventConfig.eventDates) {
|
||||
// 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)
|
||||
const blockEnd = new Date(blockStart);
|
||||
blockEnd.setHours(blockStart.getHours() + blockDurationHours);
|
||||
|
||||
// Check if current time is within the block period
|
||||
if (now >= blockStart && now < blockEnd) {
|
||||
return {
|
||||
blocked: true,
|
||||
message: eventConfig.message,
|
||||
|
||||
24
package.json
24
package.json
@@ -18,8 +18,8 @@
|
||||
"clsx": "^2.1.1",
|
||||
"cssnano": "^7.1.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"lucide-react": "^0.539.0",
|
||||
"next": "^15.4.1",
|
||||
"lucide-react": "^0.552.0",
|
||||
"next": "^16.0.0",
|
||||
"next-plausible": "^3.12.4",
|
||||
"postcss-flexbugs-fixes": "^5.0.2",
|
||||
"postcss-preset-env": "^10.2.4",
|
||||
@@ -32,17 +32,17 @@
|
||||
"zod": "^4.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "4.1.11",
|
||||
"@types/node": "22.17.1",
|
||||
"@types/react": "19.1.8",
|
||||
"@types/react-dom": "19.1.6",
|
||||
"eslint": "9.33.0",
|
||||
"eslint-config-next": "15.4.5",
|
||||
"@tailwindcss/postcss": "4.1.16",
|
||||
"@types/node": "24.9.2",
|
||||
"@types/react": "19.2.2",
|
||||
"@types/react-dom": "19.2.2",
|
||||
"eslint": "9.39.0",
|
||||
"eslint-config-next": "16.0.1",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"postcss": "8.5.6",
|
||||
"tailwindcss": "4.1.11",
|
||||
"turbo": "2.5.5",
|
||||
"typescript": "5.9.2"
|
||||
"tailwindcss": "4.1.16",
|
||||
"turbo": "2.6.0",
|
||||
"typescript": "5.9.3"
|
||||
},
|
||||
"packageManager": "pnpm@10.14.0"
|
||||
"packageManager": "pnpm@10.20.0"
|
||||
}
|
||||
|
||||
2403
pnpm-lock.yaml
generated
2403
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user