frontend/src/common/api.js
/** Add exams to the import queue starting an import process */
Add exams to the import queue starting an import process
Add exams to the import queue starting an import process
function useMutateImportStart(courseId, examsToImport, options = {}) {
  const client = useQueryClient();
  return useMutation(
    () =>
      apiClient(`courses/${courseId}/import-queue`, {
        method: "POST",
        body: examsToImport.map((exam) => exam.id),
      }),
    {
      ...options,
      onSuccess(data) {
        client.invalidateQueries(["course", courseId, "import", "status"]);
        options.onSuccess?.(data);
      },
    }
  );
}
function useMutateImportStart ( courseId , examsToImport , options = { } ) { const client = useQueryClient ( ) ; return useMutation ( ( ) => apiClient ( ` ${ courseId } ` , { method : "POST" , body : examsToImport . map ( ( exam ) => exam . id ) , } ) , { ... options , onSuccess ( data ) { client . invalidateQueries ( [ "course" , courseId , "import" , "status" ] ) ; options . onSuccess ?. ( data ) ; } , } ) ; }
Add exams to the import queue starting an import process
Add exams to the import queue starting an import process
// Passes status object from API as data to callback