mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
prevent lectures from dropping on each other
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
import { lectureKeys } from "./lectureKeys";
|
||||
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||
import {
|
||||
deleteLecture,
|
||||
getLectures,
|
||||
updateLecture,
|
||||
} from "@/services/fileStorage/lectureFileStorageService";
|
||||
@@ -28,8 +29,18 @@ export const useLectureUpdateMutation = () => {
|
||||
const { data: settings } = useLocalCourseSettingsQuery();
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (lecture: Lecture) => {
|
||||
mutationFn: async ({
|
||||
lecture,
|
||||
previousDay,
|
||||
}: {
|
||||
lecture: Lecture;
|
||||
previousDay?: string;
|
||||
}) => {
|
||||
await updateLecture(courseName, settings, lecture);
|
||||
|
||||
if (previousDay && previousDay !== lecture.date) {
|
||||
await deleteLecture(courseName, settings, previousDay);
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
Reference in New Issue
Block a user