Files
workavia-calendar-front/src/features/Calendars/services/moveEventAsync.ts
T
Camille Moussu d6e464afad [#421] added eslint check to CI (#534)
Co-authored-by: Camille Moussu <cmoussu@linagora.com>
2026-02-10 10:41:37 +01:00

26 lines
766 B
TypeScript

import { moveEvent } from "@/features/Events/EventApi";
import { CalendarEvent } from "@/features/Events/EventsTypes";
import { toRejectedError } from "@/utils/errorUtils";
import { createAsyncThunk } from "@reduxjs/toolkit";
import { Calendar } from "../CalendarTypes";
import { RejectedError } from "../types/RejectedError";
export const moveEventAsync = createAsyncThunk<
{ calId: string },
{ cal: Calendar; newEvent: CalendarEvent; newURL: string },
{ rejectValue: RejectedError }
>(
"calendars/moveEvent",
async ({ cal, newEvent, newURL }, { rejectWithValue }) => {
try {
await moveEvent(newEvent, newURL);
return {
calId: cal.id,
};
} catch (err) {
return rejectWithValue(toRejectedError(err));
}
}
);