ultisuite-client/lib/agenda/use-agenda-event-move.ts
R3D347HR4Y ad1370ea7e
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
feat: enhance configuration and add new demo layouts
- Introduced turbopack alias for canvas in next.config.mjs.
- Updated package.json scripts for development and branding tasks.
- Added new dependencies for Tiptap extensions.
- Implemented new demo layouts for agenda, contacts, drive, and mail applications.
- Enhanced globals.css for improved theming and splash screen animations.
- Added OAuth callback handling for drive mounts.
- Updated layout components to integrate new demo shells and improve structure.
2026-06-12 19:10:24 +02:00

33 lines
1.1 KiB
TypeScript

"use client"
import { useCallback } from "react"
import { toast } from "sonner"
import { eventRescheduleApiPayload, shiftedEventRange } from "@/lib/agenda/agenda-move-event"
import { isExternalCalendarId } from "@/lib/agenda/agenda-calendar-visibility"
import type { AgendaEvent } from "@/lib/agenda/agenda-types"
import { useUpdateAgendaEvent } from "@/lib/api/hooks/use-calendar-mutations"
export function useAgendaEventMove() {
const updateMutation = useUpdateAgendaEvent()
const moveEvent = useCallback(
async (event: AgendaEvent, targetStart: Date) => {
if (isExternalCalendarId(event.calendarId)) return
const { start, end } = shiftedEventRange(event, targetStart)
try {
await updateMutation.mutateAsync({
path: event.path,
etag: event.etag,
event: eventRescheduleApiPayload(event, start, end),
})
toast.success("Événement déplacé")
} catch {
toast.error("Impossible de déplacer l'événement")
}
},
[updateMutation],
)
return { moveEvent, isMoving: updateMutation.isPending }
}