fixes trail multi save bug

This commit is contained in:
Christian Beutel
2025-03-14 17:36:11 +01:00
parent ababbabadc
commit e5a28d2c42
3 changed files with 21 additions and 13 deletions

View File

@@ -28,8 +28,16 @@ export async function GET(event: RequestEvent) {
export async function PUT(event: RequestEvent) {
try {
const r = await create<Trail>(event, TrailCreateSchema, Collection.trails)
enrichRecord(r);
return json(r);
} catch (e) {
throw handleError(e)
}
}
function enrichRecord(r: Trail) {
r.date = r.date?.substring(0, 10) ?? "";
for (const log of r.expand?.summit_logs ?? []) {
log.date = log.date.substring(0, 10);
}
}