feat(03-06): add deleteEvent, fetchSyncStatus client calls and delete/sync Zustand keys

- deleteEvent(uid): DELETE /api/events/:uid with credentials:include, throws on !ok
- fetchSyncStatus(uid): GET /api/events/sync-status?uid= returning SyncStatus
- Export SyncStatus and SyncStatusValue types
- Zustand: deleteDialogOpen/deleteDialogUid/lastSyncedUid keys + setDeleteDialog/setLastSyncedUid setters
This commit is contained in:
Lucas Berger
2026-06-05 18:35:51 -04:00
parent 8357cf998e
commit 8aeacc8607
2 changed files with 85 additions and 0 deletions
+31
View File
@@ -43,6 +43,13 @@ export interface CalendarStore {
eventFormMode: 'create' | 'edit'
eventFormUid: string | null
// ── Delete dialog + sync-state UI state (Plan 03-06) ─────────────────────
// Drives DeleteConfirmationDialog visibility and SyncStateToast polling.
deleteDialogOpen: boolean
deleteDialogUid: string | null
/** UID of the most recently enqueued write. SyncStateToast polls sync-status for this. */
lastSyncedUid: string | null
setSelectedView: (view: string) => void
setSelectedDate: (date: string) => void
setOpenEventId: (id: string | null) => void
@@ -56,6 +63,20 @@ export interface CalendarStore {
* @param uid UID of the event to pre-populate in edit mode (null otherwise)
*/
setEventForm: (open: boolean, mode?: 'create' | 'edit', uid?: string | null) => void
/**
* Open or close the DeleteConfirmationDialog.
*
* @param open true to open, false to close
* @param uid UID of the event to confirm-delete (null when closing)
*/
setDeleteDialog: (open: boolean, uid?: string | null) => void
/**
* Set the UID of the most recently enqueued write, driving SyncStateToast polling.
* Pass null to dismiss the toast.
*/
setLastSyncedUid: (uid: string | null) => void
}
// ── Helpers ────────────────────────────────────────────────────────────────
@@ -115,6 +136,11 @@ export const useCalendarStore = create<CalendarStore>((set) => ({
eventFormMode: 'create',
eventFormUid: null,
// Delete dialog + sync-state UI state — closed/null by default
deleteDialogOpen: false,
deleteDialogUid: null,
lastSyncedUid: null,
setSelectedView: (view: string) => {
set({ selectedView: view })
// Persist to localStorage keyed by breakpoint group
@@ -135,4 +161,9 @@ export const useCalendarStore = create<CalendarStore>((set) => ({
setEventForm: (open: boolean, mode: 'create' | 'edit' = 'create', uid: string | null = null) =>
set({ eventFormOpen: open, eventFormMode: mode, eventFormUid: uid }),
setDeleteDialog: (open: boolean, uid: string | null = null) =>
set({ deleteDialogOpen: open, deleteDialogUid: uid }),
setLastSyncedUid: (uid: string | null) => set({ lastSyncedUid: uid }),
}))