feat: update Daily management features and enhance date handling

- Marked the calendar/history view of dailies as completed in the TODO list.
- Improved date formatting in `formatDateForAPI` to avoid timezone issues.
- Added `getDailyDates` method in `DailyClient` and `DailyService` to retrieve all dates with dailies.
- Enhanced `POST` route to robustly parse date input for better error handling.
- Integrated daily dates loading in `DailyPageClient` for calendar display.
This commit is contained in:
Julien Froidefond
2025-09-15 18:21:48 +02:00
parent cf2e360ce9
commit 936e0306fc
8 changed files with 381 additions and 46 deletions

View File

@@ -68,7 +68,16 @@ export async function POST(request: Request) {
);
}
const date = new Date(body.date);
// Parser la date de façon plus robuste
let date: Date;
if (typeof body.date === 'string') {
// Si c'est une string YYYY-MM-DD, créer une date locale
const [year, month, day] = body.date.split('-').map(Number);
date = new Date(year, month - 1, day); // month est 0-indexé
} else {
date = new Date(body.date);
}
if (isNaN(date.getTime())) {
return NextResponse.json(
{ error: 'Format de date invalide. Utilisez YYYY-MM-DD' },
@@ -93,4 +102,4 @@ export async function POST(request: Request) {
{ status: 500 }
);
}
}
}