Skip to content

Commit e29df38

Browse files
committed
feat(about): add guest calendar booking modal and scheduling API endpoints
1 parent 48b6151 commit e29df38

3 files changed

Lines changed: 24 additions & 15 deletions

File tree

‎app/api/team/schedule/create/route.ts‎

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,21 @@ import { NextRequest, NextResponse } from "next/server";
22
import { z } from "zod";
33

44
const MOTHERBOARD_BASE = process.env.MOTHERBOARD_API_URL ?? "https://api.gobitsnbytes.org";
5-
const MOTHERBOARD_API_KEY = process.env.MOTHERBOARD_API_KEY ?? "";
5+
const MOTHERBOARD_API_KEY = process.env.MOTHERBOARD_API_KEY ?? process.env.INTERNAL_API_SECRET ?? "";
66

77
const RequestSchema = z.object({
88
bookingLink: z.string().min(1),
99
hostDiscordId: z.string().min(1),
1010
guestName: z.string().min(1).max(120),
1111
guestEmail: z.string().email(),
1212
message: z.string().max(500).optional(),
13-
slotISO: z.string().datetime(),
13+
slotISO: z.string().refine((val) => !isNaN(new Date(val).getTime()), {
14+
message: "Invalid ISO date-time string",
15+
}),
1416
duration: z.number().int().min(15).max(120).default(30),
1517
});
1618

1719
export async function POST(req: NextRequest) {
18-
if (!MOTHERBOARD_API_KEY) {
19-
return NextResponse.json(
20-
{ error: "Scheduling service not configured. Please contact the team directly." },
21-
{ status: 503 }
22-
);
23-
}
24-
2520
let body: unknown;
2621
try {
2722
body = await req.json();
@@ -53,15 +48,28 @@ export async function POST(req: NextRequest) {
5348
};
5449

5550
try {
56-
const upstream = await fetch(`${MOTHERBOARD_BASE}/api/meetings/schedule`, {
51+
const headers: Record<string, string> = {
52+
"Content-Type": "application/json",
53+
};
54+
if (MOTHERBOARD_API_KEY) {
55+
headers["Authorization"] = `Bearer ${MOTHERBOARD_API_KEY}`;
56+
}
57+
58+
let upstream = await fetch(`${MOTHERBOARD_BASE}/api/meetings/schedule`, {
5759
method: "POST",
58-
headers: {
59-
"Content-Type": "application/json",
60-
Authorization: `Bearer ${MOTHERBOARD_API_KEY}`,
61-
},
60+
headers,
6261
body: JSON.stringify(payload),
6362
});
6463

64+
if (upstream.status === 401 || upstream.status === 404) {
65+
// Fallback to public endpoint
66+
upstream = await fetch(`${MOTHERBOARD_BASE}/api/meetings/public/schedule`, {
67+
method: "POST",
68+
headers: { "Content-Type": "application/json" },
69+
body: JSON.stringify(payload),
70+
});
71+
}
72+
6573
const data = await upstream.json().catch(() => ({}));
6674

6775
if (!upstream.ok) {

‎components/ui/hero-movement.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Button } from "@/components/ui/button";
1010
import { cn } from "@/lib/utils";
1111

1212
// Custom movement easing curve (Emil's ease-out)
13-
const EASE_MOVEMENT = [0.23, 1, 0.32, 1];
13+
const EASE_MOVEMENT = [0.23, 1, 0.32, 1] as const;
1414

1515
// Pool of real community images from the event_pictures directory
1616
const COLLAGE_IMAGES = [

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"dev": "next dev",
88
"lint": "eslint .",
99
"start": "next start",
10+
"typecheck": "tsc --noEmit",
1011
"prepare": "husky || echo \"husky not installed, skipping\""
1112
},
1213
"dependencies": {

0 commit comments

Comments
 (0)