[#7] fixed move destination
This commit is contained in:
@@ -94,9 +94,9 @@ export const putEventAsync = createAsyncThunk<
|
||||
});
|
||||
export const moveEventAsync = createAsyncThunk<
|
||||
{ calId: string; events: CalendarEvent[] }, // Return type
|
||||
{ cal: Calendars; newEvent: CalendarEvent } // Arg type
|
||||
>("calendars/moveEvent", async ({ cal, newEvent }) => {
|
||||
const response = await moveEvent(newEvent);
|
||||
{ cal: Calendars; newEvent: CalendarEvent; newURL: string } // Arg type
|
||||
>("calendars/moveEvent", async ({ cal, newEvent, newURL }) => {
|
||||
const response = await moveEvent(newEvent, newURL);
|
||||
const calEvents = (await getCalendar(cal.id, {
|
||||
start: formatDateToYYYYMMDDTHHMMSS(new Date(newEvent.start)),
|
||||
end: formatDateToYYYYMMDDTHHMMSS(
|
||||
|
||||
@@ -16,11 +16,11 @@ export async function putEvent(event: CalendarEvent) {
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function moveEvent(event: CalendarEvent) {
|
||||
export async function moveEvent(event: CalendarEvent, newUrl: string) {
|
||||
const response = await api(`dav${event.URL}`, {
|
||||
method: "MOVE",
|
||||
headers: {
|
||||
destination: event.URL,
|
||||
destination: newUrl,
|
||||
},
|
||||
});
|
||||
return response;
|
||||
|
||||
@@ -132,7 +132,6 @@ export default function EventDisplayModal({
|
||||
};
|
||||
|
||||
dispatch(putEventAsync({ cal: calendar, newEvent }));
|
||||
onClose({}, "backdropClick");
|
||||
}
|
||||
|
||||
const handleSave = () => {
|
||||
@@ -176,7 +175,11 @@ export default function EventDisplayModal({
|
||||
|
||||
if (newCalId !== calId) {
|
||||
dispatch(
|
||||
moveEventAsync({ cal: userPersonnalCalendars[calendarid], newEvent })
|
||||
moveEventAsync({
|
||||
cal: userPersonnalCalendars[calendarid],
|
||||
newEvent,
|
||||
newURL: `/calendars/${newCalId}/${event.uid}.ics`,
|
||||
})
|
||||
);
|
||||
}
|
||||
onClose({}, "backdropClick");
|
||||
|
||||
Reference in New Issue
Block a user