All files / src/modules/booking Booking.constants.js

88.89% Statements 8/9
100% Branches 0/0
66.67% Functions 2/3
85.71% Lines 6/7

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      1x               1x             3x                 3x         1x   1x  
import * as generalConstants from 'common/utils/general.constants'
import { StatusCodes } from 'http-status-codes'
 
export const PAGE_STATE = {
  LOADING: 'loading',
  NOT_FOUND: 'notFound',
  UNAVAILABLE: 'unavailable',
  CANCELLED: 'cancelled',
  CONFIRMED: 'confirmed',
}
 
export const BOOKING_STATUS = {
  [StatusCodes.NOT_FOUND]: PAGE_STATE.NOT_FOUND,
  [StatusCodes.LOCKED]: PAGE_STATE.CANCELLED,
  [StatusCodes.OK]: PAGE_STATE.CONFIRMED,
  [StatusCodes.PRECONDITION_FAILED]: PAGE_STATE.UNAVAILABLE,
}
 
export const STATUS_MESSAGES = (translate) => ({
  [PAGE_STATE.CONFIRMED]: translate(
    'Congratulations! Your reservation has been successfully confirmed. Here is a brief summary of your booking details:',
  ),
  [PAGE_STATE.CANCELLED]: translate(
    'You cancelled your booking. Here is a brief summary of your cancelled booking details:',
  ),
})
 
export const STATUS_NAMES = (translate) => ({
  [PAGE_STATE.CONFIRMED]: translate('Confirmed'),
  [PAGE_STATE.CANCELLED]: translate('Cancelled'),
})
 
export const BOOKING_CONFIRM_URL = (bookingId) =>
  `${generalConstants.BASE_URL}/booking/confirm/${bookingId}`
export const BOOKING_CANCEL_URL = `${generalConstants.BASE_URL}/booking/cancel`