All files / utils dokkuUtils.js

100% Statements 6/6
100% Branches 2/2
100% Functions 4/4
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                105x             3x                 5x 3x   2x                 40x    
import { toast } from "react-toastify";
 
/**
 * Query key for the (global) list of dokku account translations. The list
 * itself is not per-course, but it is always fetched from a course's Dokku
 * tab, which passes the courseId for authorization.
 */
export function dokkuTranslationsQueryKey(courseId) {
  return `/api/dokku/translations?courseId=${courseId}`;
}
 
/**
 * URL of the dokku_users_list.csv download for a course.
 */
export function dokkuUsersListUrl(courseId) {
  return `/api/dokku/dokku_users_list?courseId=${courseId}`;
}
 
/**
 * Shared onError handler for dokku account translation create/update
 * mutations. A 409 from the backend means that email already has a
 * translation.
 */
export function onDokkuTranslationMutationError(error) {
  if (error.response.status === 409) {
    toast("A dokku account translation for that email already exists.");
  } else {
    toast(`${error}`);
  }
}
 
/**
 * Query key for a course's dokku users list header (the extra lines placed at
 * the start of dokku_users_list.csv).
 */
export function dokkuUsersListHeaderQueryKey(courseId) {
  return `/api/dokku/users_list_header?courseId=${courseId}`;
}