All files / src/utils Constants.ts

92.18% Statements 59/64
66.66% Branches 8/12
100% Functions 3/3
92.18% Lines 59/64

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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85      1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 111x 111x   1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x   1x 1x 1x   1x 110x 89x 89x 110x   34x 21x 21x 110x   1x 91x 91x 91x 91x     91x   91x       91x   91x 91x 91x 91x               1x  
/**
 * Endpoints
 */
export const VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT =
  "/offices-and-services/";
export const VUE_APP_ZMS_API_CALENDAR_ENDPOINT = "/available-days-by-office/";
export const VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT =
  "/available-appointments-by-office/";
export const VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT =
  "/reserve-appointment/";
export const VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT = "/appointment/";
export const VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT =
  "/update-appointment/";
export const VUE_APP_ZMS_API_CONFIRM_APPOINTMENT_ENDPOINT =
  "/confirm-appointment/";
export const VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT =
  "/cancel-appointment/";
export const VUE_APP_ZMS_API_PRECONFIRM_APPOINTMENT_ENDPOINT =
  "/preconfirm-appointment/";
export const VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT = "/captcha-details/";
export const VUE_APP_ZMS_API_CAPTCHA_CHALLENGE_ENDPOINT = "/captcha-challenge/";
export const VUE_APP_ZMS_API_CAPTCHA_VERIFY_ENDPOINT = "/captcha-verify/";
 
export function getServiceBaseURL(): string {
  return import.meta.env.VITE_VUE_APP_SERVICE_BASE_URL;
}
 
export const MAX_SLOTS = 25;
 
export const OFTEN_SEARCHED_SERVICES = new Map<string, string>([
  ["1063475", "shortNameResidenceRegistration"],
  ["1063453", "shortNamePassport"],
  ["1063441", "shortNameIdentityCard"],
  ["10295182", "shortNameIdentityCardCollection"],
  ["10176294", "shortNameDrivingLicenseCollection"],
  ["10225119", "shortNameEidPin"],
  ["1064314", "shortNameVehicleReregistration"],
  ["1064305", "shortNameVehicleDeregistration"],
]);
 
export const QUERY_PARAM_APPOINTMENT_ID = "ap-id";
 
export const API_BASE_URL_EXTENSION = "/api/citizen";
export const API_BASE_URL_AUTHENTICATED_EXTENSION =
  "/authenticated/api/citizen";
 
export function getAPIBaseURL(baseUrl: string | undefined): string {
  if (baseUrl) {
    return baseUrl;
  }
  if (import.meta.env.VITE_VUE_APP_API_URL) {
    return import.meta.env.VITE_VUE_APP_API_URL;
  } else {
    return new URL(import.meta.url).origin;
  }
}
 
export function getGeneratedAPIBaseURL(
  baseUrl: string | undefined,
  authenticated: boolean
): string {
  let url = getAPIBaseURL(baseUrl);
 
  // Can be deleted if the configurations have been adjusted on all environments.
  if (url.endsWith("/api/citizen")) {
    url = url.slice(0, -"/api/citizen".length);
  } else if (url.endsWith("/api/citizen/")) {
    url = url.slice(0, -"/api/citizen/".length);
  }
 
  if (authenticated) {
    return url + API_BASE_URL_AUTHENTICATED_EXTENSION;
  } else {
    return url + API_BASE_URL_EXTENSION;
  }
}
 
/**
 * UI thresholds and limits
 */
// ZMSKVR-110: UX rule for view mode
// Few appointments → group by am/pm (≤ 18 per day); many appointments → hourly (> 18)
// Rationale: accessibility and layout density tradeoff documented in the ticket.
export const APPOINTMENTS_THRESHOLD_FOR_HOURLY_VIEW = 18;