fix(growth): convert dates to strings before SQL query
Postgres driver expects strings, not Date objects Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
abbaaf8874
commit
855541f4e2
1 changed files with 4 additions and 2 deletions
|
|
@ -32,10 +32,11 @@ export async function POST(request: Request) {
|
|||
return NextResponse.json({ error: ownership.error }, { status: ownership.status });
|
||||
}
|
||||
|
||||
const measuredAtDate = new Date(measuredAt).toISOString();
|
||||
await sql.unsafe(
|
||||
`INSERT INTO growth (child_id, measured_at, weight_kg, height_cm, head_circumference_cm, notes)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)`,
|
||||
[childId, new Date(measuredAt), weightKg || null, heightCm || null, headCircumferenceCm || null, notes || null]
|
||||
[childId, measuredAtDate, weightKg || null, heightCm || null, headCircumferenceCm || null, notes || null]
|
||||
);
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
|
|
@ -118,9 +119,10 @@ export async function PUT(request: Request) {
|
|||
return NextResponse.json({ error: "Not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const measuredAtStr = measuredAt ? new Date(measuredAt).toISOString() : null;
|
||||
await sql.unsafe(
|
||||
`UPDATE growth SET measured_at = $1, weight_kg = $2, height_cm = $3, head_circumference_cm = $4, notes = $5 WHERE id = $6`,
|
||||
[measuredAt ? new Date(measuredAt) : null, weightKg ?? null, heightCm ?? null, headCircumferenceCm ?? null, notes ?? null, id]
|
||||
[measuredAtStr, weightKg ?? null, heightCm ?? null, headCircumferenceCm ?? null, notes ?? null, id]
|
||||
);
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue