From eba669f1873487afb5d81be2dbe05ae21656b8e6 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Feb 2026 14:55:28 -0600 Subject: [PATCH] Signed-off-by: Max --- README.md | 6 ++++++ SUPABASE_SETUP.md | 6 ++++++ src/app/api/sprints/route.ts | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fe7c51c..72ba6e4 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,12 @@ Task and sprint board built with Next.js + Zustand and Supabase-backed API persi - Accepts date strings with a `YYYY-MM-DD` prefix (`YYYY-MM-DD` or ISO timestamp). - Normalizes and persists only the date part (`YYYY-MM-DD`). - `PATCH` returns `400` for invalid `startDate`/`endDate` format. +- Example request payloads: + - `POST /api/sprints` + - `{ "name": "Sprint 1", "startDate": "2026-02-16", "endDate": "2026-02-22", "status": "active", "projectId": "" }` + - `PATCH /api/sprints` + - `{ "id": "", "startDate": "2026-02-16T00:00:00.000Z", "endDate": "2026-02-22T23:59:59.999Z" }` + - persisted as `start_date = '2026-02-16'`, `end_date = '2026-02-22'` - Do not use `new Date("YYYY-MM-DD")` for sprint display logic. Use shared helpers: - `parseSprintStart(...)` - `parseSprintEnd(...)` diff --git a/SUPABASE_SETUP.md b/SUPABASE_SETUP.md index c57f881..2d737a4 100644 --- a/SUPABASE_SETUP.md +++ b/SUPABASE_SETUP.md @@ -133,6 +133,12 @@ Or push to git and let Vercel auto-deploy. - API behavior: - `/api/sprints` normalizes `startDate` and `endDate` to `YYYY-MM-DD` before persistence. - Invalid date format on `PATCH /api/sprints` returns `400`. +- API payload examples: + - `POST /api/sprints` + - `{ "name": "Sprint 1", "startDate": "2026-02-16", "endDate": "2026-02-22", "status": "active", "projectId": "" }` + - `PATCH /api/sprints` + - `{ "id": "", "startDate": "2026-02-16T00:00:00.000Z", "endDate": "2026-02-22T23:59:59.999Z" }` + - stored as date-only values in Supabase `DATE` columns ## Architecture Changes diff --git a/src/app/api/sprints/route.ts b/src/app/api/sprints/route.ts index dd200c0..eaa9452 100644 --- a/src/app/api/sprints/route.ts +++ b/src/app/api/sprints/route.ts @@ -4,6 +4,8 @@ import { getAuthenticatedUser } from "@/lib/server/auth"; export const runtime = "nodejs"; +// Sprint dates are stored as SQL DATE values (YYYY-MM-DD). We accept either +// date-only or ISO datetime inputs and normalize to the date prefix. const DATE_PREFIX_PATTERN = /^(\d{4}-\d{2}-\d{2})/; function toDateOnlyInput(value: unknown): string | null { @@ -114,7 +116,7 @@ export async function PATCH(request: Request) { const supabase = getServiceSupabase(); const now = new Date().toISOString(); - // Map camelCase to snake_case for database + // Map camelCase to snake_case for database and keep date-only semantics. const dbUpdates: Record = {}; if (updates.name !== undefined) dbUpdates.name = updates.name; if (updates.goal !== undefined) dbUpdates.goal = updates.goal;