d6e464afad
Co-authored-by: Camille Moussu <cmoussu@linagora.com>
26 lines
766 B
TypeScript
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));
|
|
}
|
|
}
|
|
);
|