feat: implement drag-and-drop reordering for daily checkboxes

- Added DnD functionality to `DailySection` for reordering checkboxes using `@dnd-kit/core` and `@dnd-kit/sortable`.
- Introduced `onReorderCheckboxes` prop to handle server updates after reordering.
- Updated `useDaily` hook to streamline error handling during reordering.
- Cleaned up `Header` component by removing unnecessary syncing text.
- Adjusted `DailyPageClient` to pass reorder function to `DailySection`.
This commit is contained in:
Julien Froidefond
2025-09-18 14:56:05 +02:00
parent 2c262b06e7
commit 618b2e9e5c
5 changed files with 220 additions and 60 deletions

View File

@@ -329,10 +329,7 @@ export function useDaily(initialDate?: Date, initialDailyView?: DailyView): UseD
const dailyId = data.date.toISOString().split('T')[0];
const result = await reorderCheckboxesAction(dailyId, data.checkboxIds);
if (result.success) {
// Rafraîchir pour obtenir l'ordre correct
await refreshDaily();
} else {
if (!result.success) {
setError(result.error || 'Erreur lors du réordonnancement');
}
} catch (err) {
@@ -341,7 +338,7 @@ export function useDaily(initialDate?: Date, initialDailyView?: DailyView): UseD
} finally {
setSaving(false);
}
}, [refreshDaily]);
}, []);
const goToPreviousDay = useCallback(async (): Promise<void> => {
const previousDay = new Date(currentDate);