mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
am updateing course
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { LocalCourse } from "@/models/local/localCourse";
|
||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
dataTagSymbol,
|
||||
useMutation,
|
||||
useQueryClient,
|
||||
useSuspenseQuery,
|
||||
} from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
|
||||
export const localCourseKeys = {
|
||||
@@ -32,3 +37,22 @@ export const useLocalCourseDetailsQuery = (courseName: string) => {
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateCourseMutation = (courseName: string) => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (body: {
|
||||
updatedCourse: LocalCourse;
|
||||
previousCourse: LocalCourse;
|
||||
}) => {
|
||||
const url = `/api/courses/${courseName}`;
|
||||
await axios.put(url, body);
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: localCourseKeys.allCourses }); //optimize?
|
||||
},
|
||||
scope: {
|
||||
id: "update course",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user