frontend/src/common/api.js
/** Performs one action to change the setup of a course */
Performs one action to change the setup of a course
Performs one action to change the setup of a course
function useMutateCourseSetup(courseId, action, options = {}) {
  const client = useQueryClient();
  return useMutation(
    () =>
      apiClient(`courses/${courseId}/setup/${action}`, {
        method: "POST",
      }),
    {
      ...options,
      onSuccess() {
        if (action === "publish-assignment") {
          client.resetQueries(["course", courseId]);
        } else {
          client.invalidateQueries(["course", courseId, "setup"]);
        }
        options.onSuccess?.();
      },
    }
  );
}
function useMutateCourseSetup ( courseId , action , options = { } ) { const client = useQueryClient ( ) ; return useMutation ( ( ) => apiClient ( ` ${ courseId } ${ action } ` , { method : "POST" , } ) , { ... options , onSuccess ( ) { if ( action === "publish-assignment" ) { client . resetQueries ( [ "course" , courseId ] ) ; } else { client . invalidateQueries ( [ "course" , courseId , "setup" ] ) ; } options . onSuccess ?. ( ) ; } , } ) ; }
Performs one action to change the setup of a course
Performs one action to change the setup of a course
// Reset queries to trigger loading indicator when // moving to imoport flow