Signed-off-by: Max <ai-agent@topdoglabs.com>
This commit is contained in:
parent
29cac07f58
commit
eba669f187
@ -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": "<uuid>" }`
|
||||
- `PATCH /api/sprints`
|
||||
- `{ "id": "<sprint-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(...)`
|
||||
|
||||
@ -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": "<uuid>" }`
|
||||
- `PATCH /api/sprints`
|
||||
- `{ "id": "<sprint-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
|
||||
|
||||
|
||||
@ -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<string, unknown> = {};
|
||||
if (updates.name !== undefined) dbUpdates.name = updates.name;
|
||||
if (updates.goal !== undefined) dbUpdates.goal = updates.goal;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user