@roomstay/frontend 2.3.25 → 2.3.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,9 @@ const types_1 = require("@sentry/types");
43
43
  const react_1 = __importStar(require("react"));
44
44
  const react_hook_form_1 = require("react-hook-form");
45
45
  const react_i18next_1 = require("react-i18next");
46
+ const CommittedBookingEvent_1 = require("../../events/views/CommittedBookingEvent");
47
+ const PlacedBookingEvent_1 = require("../../events/views/PlacedBookingEvent");
48
+ const RolledBackBookingEvent_1 = require("../../events/views/RolledBackBookingEvent");
46
49
  const ConfirmationQuery_1 = require("../../hooks/ConfirmationQuery");
47
50
  const Translation_1 = require("../../translations/Translation");
48
51
  const BookingAPI_1 = __importDefault(require("../../api/BookingAPI"));
@@ -61,6 +64,7 @@ const ConfirmationStepContextWrapper = ({ children }) => {
61
64
  const basketAddonRows = basketContext.basketAddonRows;
62
65
  const { hotel } = (0, hooks_1.useCurrentHotel)();
63
66
  const { t } = (0, react_i18next_1.useTranslation)();
67
+ const { raise } = (0, hooks_1.useEvent)();
64
68
  const toUserProfiles = (formValues) => {
65
69
  return formValues.userProfiles.map((values) => ({
66
70
  FirstName: values.Forename,
@@ -120,8 +124,10 @@ const ConfirmationStepContextWrapper = ({ children }) => {
120
124
  setIsLoading(false);
121
125
  onPostValidationError === null || onPostValidationError === void 0 ? void 0 : onPostValidationError(validationResult);
122
126
  }
123
- else
127
+ else {
128
+ raise(new PlacedBookingEvent_1.PlacedBookingEvent(data, basketContext.currentBasketRows));
124
129
  yield (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data));
130
+ }
125
131
  }
126
132
  catch (error) {
127
133
  console.log(error);
@@ -154,6 +160,7 @@ const ConfirmationStepContextWrapper = ({ children }) => {
154
160
  Sentry.captureException('Failed to read reservations from GTM code: ' + JSON.stringify(ex));
155
161
  }
156
162
  basketContext.checkedOut(response);
163
+ raise(new CommittedBookingEvent_1.CommittedBookingEvent(resData, basketContext.currentBasketRows));
157
164
  })
158
165
  .catch((ex) => {
159
166
  console.log(ex);
@@ -189,6 +196,7 @@ const ConfirmationStepContextWrapper = ({ children }) => {
189
196
  if (reservationIds.length) {
190
197
  setIsLoading(true);
191
198
  yield BookingAPI_1.default.Reservation.rollback(reservationIds, basketContext.reservationData.itineraryNumber, hotel === null || hotel === void 0 ? void 0 : hotel.hotelID);
199
+ raise(new RolledBackBookingEvent_1.RolledBackBookingEvent(basketContext.reservationData));
192
200
  }
193
201
  else {
194
202
  Sentry.captureException('No reservation IDs found when attempting to rollback: ' + JSON.stringify(basketContext.reservationData));
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmationStepContextWrapper.js","sourceRoot":"/","sources":["src/contexts/ConfirmationStepContext/ConfirmationStepContextWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiE;AACjE,2CAAkD;AAClD,wDAA0C;AAC1C,yCAAyC;AACzC,+CAA2E;AAC3E,qDAAwD;AACxD,iDAA+C;AAE/C,iEAAiE;AAEjE,4DAAyD;AAEzD,sEAAuC;AAIvC,kEAAmF;AACnF,uEAAoE;AAEpE,MAAM,+BAA+B,GAAG,iDAAuB,CAAC,QAAQ,CAAC;AAClE,MAAM,8BAA8B,GAA+B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACvF,MAAM,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,GAAG,IAAA,wCAAoB,GAAE,CAAC;IAEnH,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IAC3D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,IAAA,yBAAO,EAAyB;QAC5C,IAAI,EAAE,UAAU;KACnB,CAAC,CAAC;IAE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,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAE9C,MAAM,IAAI,GAAG,CACT,iBAAyC,EACzC,QAAiB,EACjB,WAAmC,EACnC,qBAA+C,EAC/C,SAAgC,EAClC,EAAE;QACA,MAAM,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,EAAE,WAAW,EAAE,qBAAqB,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;IACvH,CAAC,CAAA,CAAC;IAEF,OAAO,CACH,8BAAC,8BAAY,oBAAK,OAAO;QACrB,8BAAC,+BAA+B,IAC5B,KAAK,EAAE;gBACH,IAAI;gBACJ,iBAAiB;gBACjB,mBAAmB;gBAEnB,SAAS;gBACT,SAAS;gBACT,cAAc;gBACd,iBAAiB;aACpB,IAEA,QAAQ,CACqB,CACvB,CAClB,CAAC;AACN,CAAC,CAAC;AA9LW,QAAA,8BAA8B,kCA8LzC","sourcesContent":["import { BasketContext, ErrorHandler } from '@frontend/contexts';\nimport { useCurrentHotel } from '@frontend/hooks';\nimport * as Sentry from '@sentry/browser';\nimport { Severity } from '@sentry/types';\nimport React, { FC, PropsWithChildren, useContext, useState } from 'react';\nimport { FormProvider, useForm } from 'react-hook-form';\nimport { useTranslation } from 'react-i18next';\n\nimport { useConfirmationQuery } from '@/hooks/ConfirmationQuery';\nimport { ConfirmationFormValues, FBookGetPaymentDetails, FBookSuccessCallback, FBookValidateFunction, FBookValidationCallback, IBookValidationResult } from '@/models/Confirmation';\nimport { Translation } from '@/translations/Translation';\n\nimport API from '../../api/BookingAPI';\nimport ReservationsDTO, { ReservationDTO } from '../../models/Api/ReservationsDTO';\nimport BasketRowDifferences from '../../models/BasketRowDifferences';\nimport UserProfile from '../../models/UserProfile';\nimport DataLayer, { InteractionStep, InteractionType } from '../../util/DataLayer';\nimport { ConfirmationStepContext } from './ConfirmationStepContext';\n\nconst ConfirmationStepContextProvider = ConfirmationStepContext.Provider;\nexport const ConfirmationStepContextWrapper: FC<PropsWithChildren<any>> = ({ children }) => {\n const { queryPaymentMethod, queryRoomstayId: queryReservationId, queryPlanpayCheckoutId } = useConfirmationQuery();\n\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [apiErrors, setApiErrors] = useState<string>('');\n const methods = useForm<ConfirmationFormValues>({\n mode: 'onChange',\n });\n\n const basketContext = useContext(BasketContext);\n const basketRows = basketContext.getAllValidRows();\n const basketAddonRows = basketContext.basketAddonRows;\n const { hotel } = useCurrentHotel();\n const { t } = useTranslation();\n\n const toUserProfiles = (formValues: ConfirmationFormValues): UserProfile[] => {\n return formValues.userProfiles.map((values) => ({\n FirstName: values.Forename,\n LastName: values.Surname,\n Phone: values.Phone.replace(' ', ''),\n Email: values.Email,\n Address: {\n Line1: values.Address,\n City: values.City,\n PostalCode: values.PostCode,\n Country: values.Country,\n },\n MarketingOptIn: false,\n }));\n };\n\n const validateReservation = async (data: ReservationsDTO): Promise<IBookValidationResult | undefined> => {\n const apiDifferences: BasketRowDifferences[] = [];\n if (data.reservations) {\n data.reservations.forEach((reservation: ReservationDTO, index) => {\n const diff = basketContext.currentBasketRows[index].checkDiffFromReservation(reservation);\n\n if (diff) {\n apiDifferences.push(diff);\n }\n });\n } else {\n Sentry.addBreadcrumb({\n level: Severity.Error,\n message: 'No reservation data: ' + JSON.stringify(data),\n });\n throw new Error('The reservation could not be completed due to an unexpected issue, please try again');\n }\n\n // If there are differences, we want to display them to make sure the booking still needs to proceed\n if (apiDifferences.length || (data.warnings && data.warnings.length)) {\n return {\n differences: apiDifferences,\n warnings: data.warnings as string[],\n };\n }\n };\n\n const onSubmit =\n (\n getPaymentDetails: FBookGetPaymentDetails,\n comments?: string,\n preValidate?: FBookValidateFunction,\n onPostValidationError?: FBookValidationCallback,\n onSuccess?: FBookSuccessCallback\n ) =>\n async (formValues: ConfirmationFormValues): Promise<void> => {\n DataLayer.instance.sendInteraction('Complete Booking', InteractionType.BUTTON, InteractionStep.GUEST_DETAILS);\n setIsLoading(true);\n let data: ReservationsDTO | undefined;\n const validateResult = !preValidate || (await preValidate());\n if (!validateResult) {\n setIsLoading(false);\n return;\n }\n\n const payment = await getPaymentDetails();\n\n try {\n data = await API.Reservation.bookNow(basketRows, toUserProfiles(formValues), payment, basketAddonRows, comments || '', hotel?.hotelID as string);\n basketContext.booked(data);\n const validationResult = await validateReservation(data);\n if (validationResult) {\n setIsLoading(false);\n onPostValidationError?.(validationResult);\n } else await onSuccess?.(data);\n } catch (error: any) {\n console.log(error);\n setApiErrors(error?.Message ?? t(Translation.Step.Confirmation.UnexpectedErrorFromBookingDatabase));\n // We don't want to stop the isLoading on a succesful flow to avoid clicking checkout twice\n } finally {\n setIsLoading(false);\n }\n };\n\n const isBackFromPlanpay = !!queryPlanpayCheckoutId && !!queryReservationId && !!queryPaymentMethod;\n\n const parseReservationIdsFromData = (data: ReservationsDTO) => {\n return data?.reservations?.map((reservation) => reservation.reservationNumber);\n };\n\n const commitReservation = async (resData: ReservationsDTO) => {\n try {\n setIsLoading(true);\n if (resData) {\n const reservationIds = parseReservationIdsFromData(resData);\n if (reservationIds.length) {\n try {\n await API.Reservation.commit(reservationIds, resData.itineraryNumber, hotel?.hotelID as string, queryPlanpayCheckoutId || undefined)\n .then((response: ReservationsDTO) => {\n try {\n DataLayer.instance.sendReservationConfirmed(basketContext.getAllValidRows(), basketContext.basketAddonRows, response);\n } catch (ex) {\n Sentry.captureException('Failed to read reservations from GTM code: ' + JSON.stringify(ex));\n }\n basketContext.checkedOut(response);\n })\n .catch((ex: any) => {\n console.log(ex);\n setApiErrors(t(Translation.Misc.UnexpectedError));\n })\n .finally(() => {\n setIsLoading(false);\n });\n } catch (error: any) {\n setApiErrors(error?.Message ?? t(Translation.Step.Confirmation.UnexpectedErrorFromBookingDatabase));\n }\n } else {\n setApiErrors(t(Translation.Step.Confirmation.UnexpectedErrorOnCommittingReservation));\n ErrorHandler.add({ message: t(Translation.Step.Confirmation.UnexpectedErrorOnCommittingReservation) });\n Sentry.captureException('No reservation IDs found when attempting to commit: ' + JSON.stringify(resData));\n }\n }\n } catch (ex) {\n setApiErrors(t(Translation.Step.Confirmation.FailedToCommitReservation));\n console.log('Failed to commit reservation ');\n console.error(ex);\n Sentry.captureException(ex);\n }\n };\n\n const rollbackReservation = async () => {\n if (!basketContext.reservationData) return;\n try {\n const reservationIds = parseReservationIdsFromData(basketContext.reservationData);\n if (reservationIds.length) {\n setIsLoading(true);\n await API.Reservation.rollback(reservationIds, basketContext.reservationData.itineraryNumber, hotel?.hotelID as string);\n } else {\n Sentry.captureException('No reservation IDs found when attempting to rollback: ' + JSON.stringify(basketContext.reservationData));\n }\n } catch (ex) {\n console.log('Failed to rollback reservations');\n Sentry.captureException(ex);\n } finally {\n basketContext.rollback();\n setIsLoading(false);\n }\n };\n\n const clearApiErrors = () => setApiErrors('');\n\n const book = async (\n getPaymentDetails: FBookGetPaymentDetails,\n comments?: string,\n preValidate?: FBookValidateFunction,\n onPostValidationError?: FBookValidationCallback,\n onSuccess?: FBookSuccessCallback\n ) => {\n await methods.handleSubmit(onSubmit(getPaymentDetails, comments, preValidate, onPostValidationError, onSuccess))();\n };\n\n return (\n <FormProvider {...methods}>\n <ConfirmationStepContextProvider\n value={{\n book,\n commitReservation,\n rollbackReservation,\n\n isLoading,\n apiErrors,\n clearApiErrors,\n isBackFromPlanpay,\n }}\n >\n {children}\n </ConfirmationStepContextProvider>\n </FormProvider>\n );\n};\n"]}
1
+ {"version":3,"file":"ConfirmationStepContextWrapper.js","sourceRoot":"/","sources":["src/contexts/ConfirmationStepContext/ConfirmationStepContextWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiE;AACjE,2CAA4D;AAC5D,wDAA0C;AAC1C,yCAAyC;AACzC,+CAA2E;AAC3E,qDAAwD;AACxD,iDAA+C;AAE/C,gFAA6E;AAC7E,0EAAuE;AACvE,kFAA+E;AAC/E,iEAAiE;AAEjE,4DAAyD;AAEz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B,8BAAC,+BAA+B,IAC5B,KAAK,EAAE;gBACH,IAAI;gBACJ,iBAAiB;gBACjB,mBAAmB;gBAEnB,SAAS;gBACT,SAAS;gBACT,cAAc;gBACd,iBAAiB;aACpB,IAEA,QAAQ,CACqB,CACvB,CAClB,CAAC;AACN,CAAC,CAAC;AApMW,QAAA,8BAA8B,kCAoMzC","sourcesContent":["import { BasketContext, ErrorHandler } from '@frontend/contexts';\nimport { useCurrentHotel, useEvent } from '@frontend/hooks';\nimport * as Sentry from '@sentry/browser';\nimport { Severity } from '@sentry/types';\nimport React, { FC, PropsWithChildren, useContext, useState } from 'react';\nimport { FormProvider, useForm } from 'react-hook-form';\nimport { useTranslation } from 'react-i18next';\n\nimport { CommittedBookingEvent } from '@/events/views/CommittedBookingEvent';\nimport { PlacedBookingEvent } from '@/events/views/PlacedBookingEvent';\nimport { RolledBackBookingEvent } from '@/events/views/RolledBackBookingEvent';\nimport { useConfirmationQuery } from '@/hooks/ConfirmationQuery';\nimport { ConfirmationFormValues, FBookGetPaymentDetails, FBookSuccessCallback, FBookValidateFunction, FBookValidationCallback, IBookValidationResult } from '@/models/Confirmation';\nimport { Translation } from '@/translations/Translation';\n\nimport API from '../../api/BookingAPI';\nimport ReservationsDTO, { ReservationDTO } from '../../models/Api/ReservationsDTO';\nimport BasketRowDifferences from '../../models/BasketRowDifferences';\nimport UserProfile from '../../models/UserProfile';\nimport DataLayer, { InteractionStep, InteractionType } from '../../util/DataLayer';\nimport { ConfirmationStepContext } from './ConfirmationStepContext';\n\nconst ConfirmationStepContextProvider = ConfirmationStepContext.Provider;\nexport const ConfirmationStepContextWrapper: FC<PropsWithChildren<any>> = ({ children }) => {\n const { queryPaymentMethod, queryRoomstayId: queryReservationId, queryPlanpayCheckoutId } = useConfirmationQuery();\n\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [apiErrors, setApiErrors] = useState<string>('');\n const methods = useForm<ConfirmationFormValues>({\n mode: 'onChange',\n });\n\n const basketContext = useContext(BasketContext);\n const basketRows = basketContext.getAllValidRows();\n const basketAddonRows = basketContext.basketAddonRows;\n const { hotel } = useCurrentHotel();\n const { t } = useTranslation();\n const { raise } = useEvent();\n\n const toUserProfiles = (formValues: ConfirmationFormValues): UserProfile[] => {\n return formValues.userProfiles.map((values) => ({\n FirstName: values.Forename,\n LastName: values.Surname,\n Phone: values.Phone.replace(' ', ''),\n Email: values.Email,\n Address: {\n Line1: values.Address,\n City: values.City,\n PostalCode: values.PostCode,\n Country: values.Country,\n },\n MarketingOptIn: false,\n }));\n };\n\n const validateReservation = async (data: ReservationsDTO): Promise<IBookValidationResult | undefined> => {\n const apiDifferences: BasketRowDifferences[] = [];\n if (data.reservations) {\n data.reservations.forEach((reservation: ReservationDTO, index) => {\n const diff = basketContext.currentBasketRows[index].checkDiffFromReservation(reservation);\n\n if (diff) {\n apiDifferences.push(diff);\n }\n });\n } else {\n Sentry.addBreadcrumb({\n level: Severity.Error,\n message: 'No reservation data: ' + JSON.stringify(data),\n });\n throw new Error('The reservation could not be completed due to an unexpected issue, please try again');\n }\n\n // If there are differences, we want to display them to make sure the booking still needs to proceed\n if (apiDifferences.length || (data.warnings && data.warnings.length)) {\n return {\n differences: apiDifferences,\n warnings: data.warnings as string[],\n };\n }\n };\n\n const onSubmit =\n (\n getPaymentDetails: FBookGetPaymentDetails,\n comments?: string,\n preValidate?: FBookValidateFunction,\n onPostValidationError?: FBookValidationCallback,\n onSuccess?: FBookSuccessCallback\n ) =>\n async (formValues: ConfirmationFormValues): Promise<void> => {\n DataLayer.instance.sendInteraction('Complete Booking', InteractionType.BUTTON, InteractionStep.GUEST_DETAILS);\n setIsLoading(true);\n let data: ReservationsDTO | undefined;\n const validateResult = !preValidate || (await preValidate());\n if (!validateResult) {\n setIsLoading(false);\n return;\n }\n\n const payment = await getPaymentDetails();\n\n try {\n data = await API.Reservation.bookNow(basketRows, toUserProfiles(formValues), payment, basketAddonRows, comments || '', hotel?.hotelID as string);\n basketContext.booked(data);\n const validationResult = await validateReservation(data);\n if (validationResult) {\n setIsLoading(false);\n onPostValidationError?.(validationResult);\n } else {\n raise(new PlacedBookingEvent(data, basketContext.currentBasketRows));\n await onSuccess?.(data);\n }\n } catch (error: any) {\n console.log(error);\n setApiErrors(error?.Message ?? t(Translation.Step.Confirmation.UnexpectedErrorFromBookingDatabase));\n // We don't want to stop the isLoading on a succesful flow to avoid clicking checkout twice\n } finally {\n setIsLoading(false);\n }\n };\n\n const isBackFromPlanpay = !!queryPlanpayCheckoutId && !!queryReservationId && !!queryPaymentMethod;\n\n const parseReservationIdsFromData = (data: ReservationsDTO) => {\n return data?.reservations?.map((reservation) => reservation.reservationNumber);\n };\n\n const commitReservation = async (resData: ReservationsDTO) => {\n try {\n setIsLoading(true);\n if (resData) {\n const reservationIds = parseReservationIdsFromData(resData);\n if (reservationIds.length) {\n try {\n await API.Reservation.commit(reservationIds, resData.itineraryNumber, hotel?.hotelID as string, queryPlanpayCheckoutId || undefined)\n .then((response: ReservationsDTO) => {\n try {\n DataLayer.instance.sendReservationConfirmed(basketContext.getAllValidRows(), basketContext.basketAddonRows, response);\n } catch (ex) {\n Sentry.captureException('Failed to read reservations from GTM code: ' + JSON.stringify(ex));\n }\n basketContext.checkedOut(response);\n raise(new CommittedBookingEvent(resData, basketContext.currentBasketRows));\n })\n .catch((ex: any) => {\n console.log(ex);\n setApiErrors(t(Translation.Misc.UnexpectedError));\n })\n .finally(() => {\n setIsLoading(false);\n });\n } catch (error: any) {\n setApiErrors(error?.Message ?? t(Translation.Step.Confirmation.UnexpectedErrorFromBookingDatabase));\n }\n } else {\n setApiErrors(t(Translation.Step.Confirmation.UnexpectedErrorOnCommittingReservation));\n ErrorHandler.add({ message: t(Translation.Step.Confirmation.UnexpectedErrorOnCommittingReservation) });\n Sentry.captureException('No reservation IDs found when attempting to commit: ' + JSON.stringify(resData));\n }\n }\n } catch (ex) {\n setApiErrors(t(Translation.Step.Confirmation.FailedToCommitReservation));\n console.log('Failed to commit reservation ');\n console.error(ex);\n Sentry.captureException(ex);\n }\n };\n\n const rollbackReservation = async () => {\n if (!basketContext.reservationData) return;\n try {\n const reservationIds = parseReservationIdsFromData(basketContext.reservationData);\n if (reservationIds.length) {\n setIsLoading(true);\n await API.Reservation.rollback(reservationIds, basketContext.reservationData.itineraryNumber, hotel?.hotelID as string);\n raise(new RolledBackBookingEvent(basketContext.reservationData));\n } else {\n Sentry.captureException('No reservation IDs found when attempting to rollback: ' + JSON.stringify(basketContext.reservationData));\n }\n } catch (ex) {\n console.log('Failed to rollback reservations');\n Sentry.captureException(ex);\n } finally {\n basketContext.rollback();\n setIsLoading(false);\n }\n };\n\n const clearApiErrors = () => setApiErrors('');\n\n const book = async (\n getPaymentDetails: FBookGetPaymentDetails,\n comments?: string,\n preValidate?: FBookValidateFunction,\n onPostValidationError?: FBookValidationCallback,\n onSuccess?: FBookSuccessCallback\n ) => {\n await methods.handleSubmit(onSubmit(getPaymentDetails, comments, preValidate, onPostValidationError, onSuccess))();\n };\n\n return (\n <FormProvider {...methods}>\n <ConfirmationStepContextProvider\n value={{\n book,\n commitReservation,\n rollbackReservation,\n\n isLoading,\n apiErrors,\n clearApiErrors,\n isBackFromPlanpay,\n }}\n >\n {children}\n </ConfirmationStepContextProvider>\n </FormProvider>\n );\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import ReservationsDTO from '../../models/Api/ReservationsDTO';
2
+ import BasketRow from '../../models/BasketRow';
3
+ import { RoomstayEvent } from '../RoomstayEvent';
4
+ export declare class CommittedBookingEvent extends RoomstayEvent {
5
+ reservation: ReservationsDTO;
6
+ basketRows: BasketRow[];
7
+ constructor(reservation: ReservationsDTO, basketRows: BasketRow[]);
8
+ static getLabel(): string;
9
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommittedBookingEvent = void 0;
4
+ const RoomstayEvent_1 = require("../RoomstayEvent");
5
+ class CommittedBookingEvent extends RoomstayEvent_1.RoomstayEvent {
6
+ constructor(reservation, basketRows) {
7
+ super();
8
+ this.reservation = reservation;
9
+ this.basketRows = basketRows;
10
+ }
11
+ static getLabel() {
12
+ return 'Booking/Committed';
13
+ }
14
+ }
15
+ exports.CommittedBookingEvent = CommittedBookingEvent;
16
+ //# sourceMappingURL=CommittedBookingEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommittedBookingEvent.js","sourceRoot":"/","sources":["src/events/views/CommittedBookingEvent.ts"],"names":[],"mappings":";;;AAGA,oDAAiD;AAEjD,MAAa,qBAAsB,SAAQ,6BAAa;IAGpD,YAAmB,WAA4B,EAAE,UAAuB;QACpE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,QAAQ;QACX,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AAZD,sDAYC","sourcesContent":["import ReservationsDTO from '@/models/Api/ReservationsDTO';\nimport BasketRow from '@/models/BasketRow';\n\nimport { RoomstayEvent } from '../RoomstayEvent';\n\nexport class CommittedBookingEvent extends RoomstayEvent {\n public reservation: ReservationsDTO;\n public basketRows: BasketRow[];\n public constructor(reservation: ReservationsDTO, basketRows: BasketRow[]) {\n super();\n this.reservation = reservation;\n this.basketRows = basketRows;\n }\n\n static getLabel(): string {\n return 'Booking/Committed';\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import ReservationsDTO from '../../models/Api/ReservationsDTO';
2
+ import BasketRow from '../../models/BasketRow';
3
+ import { RoomstayEvent } from '../RoomstayEvent';
4
+ export declare class PlacedBookingEvent extends RoomstayEvent {
5
+ reservation: ReservationsDTO;
6
+ basketRows: BasketRow[];
7
+ constructor(reservation: ReservationsDTO, basketRows: BasketRow[]);
8
+ static getLabel(): string;
9
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlacedBookingEvent = void 0;
4
+ const RoomstayEvent_1 = require("../RoomstayEvent");
5
+ class PlacedBookingEvent extends RoomstayEvent_1.RoomstayEvent {
6
+ constructor(reservation, basketRows) {
7
+ super();
8
+ this.reservation = reservation;
9
+ this.basketRows = basketRows;
10
+ }
11
+ static getLabel() {
12
+ return 'Booking/Placed';
13
+ }
14
+ }
15
+ exports.PlacedBookingEvent = PlacedBookingEvent;
16
+ //# sourceMappingURL=PlacedBookingEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlacedBookingEvent.js","sourceRoot":"/","sources":["src/events/views/PlacedBookingEvent.ts"],"names":[],"mappings":";;;AAGA,oDAAiD;AAEjD,MAAa,kBAAmB,SAAQ,6BAAa;IAGjD,YAAmB,WAA4B,EAAE,UAAuB;QACpE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,QAAQ;QACX,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ;AAZD,gDAYC","sourcesContent":["import ReservationsDTO from '@/models/Api/ReservationsDTO';\nimport BasketRow from '@/models/BasketRow';\n\nimport { RoomstayEvent } from '../RoomstayEvent';\n\nexport class PlacedBookingEvent extends RoomstayEvent {\n public reservation: ReservationsDTO;\n public basketRows: BasketRow[];\n public constructor(reservation: ReservationsDTO, basketRows: BasketRow[]) {\n super();\n this.reservation = reservation;\n this.basketRows = basketRows;\n }\n\n static getLabel(): string {\n return 'Booking/Placed';\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import ReservationsDTO from '../../models/Api/ReservationsDTO';
2
+ import { RoomstayEvent } from '../RoomstayEvent';
3
+ export declare class RolledBackBookingEvent extends RoomstayEvent {
4
+ reservation: ReservationsDTO;
5
+ constructor(reservation: ReservationsDTO);
6
+ static getLabel(): string;
7
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RolledBackBookingEvent = void 0;
4
+ const RoomstayEvent_1 = require("../RoomstayEvent");
5
+ class RolledBackBookingEvent extends RoomstayEvent_1.RoomstayEvent {
6
+ constructor(reservation) {
7
+ super();
8
+ this.reservation = reservation;
9
+ }
10
+ static getLabel() {
11
+ return 'Booking/RolledBack';
12
+ }
13
+ }
14
+ exports.RolledBackBookingEvent = RolledBackBookingEvent;
15
+ //# sourceMappingURL=RolledBackBookingEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RolledBackBookingEvent.js","sourceRoot":"/","sources":["src/events/views/RolledBackBookingEvent.ts"],"names":[],"mappings":";;;AAEA,oDAAiD;AAEjD,MAAa,sBAAuB,SAAQ,6BAAa;IAErD,YAAmB,WAA4B;QAC3C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,QAAQ;QACX,OAAO,oBAAoB,CAAC;IAChC,CAAC;CACJ;AAVD,wDAUC","sourcesContent":["import ReservationsDTO from '@/models/Api/ReservationsDTO';\n\nimport { RoomstayEvent } from '../RoomstayEvent';\n\nexport class RolledBackBookingEvent extends RoomstayEvent {\n public reservation: ReservationsDTO;\n public constructor(reservation: ReservationsDTO) {\n super();\n this.reservation = reservation;\n }\n\n static getLabel(): string {\n return 'Booking/RolledBack';\n }\n}\n"]}
@@ -51,6 +51,7 @@ export { default as RoomstayThemeEngine } from './providers/RoomstayThemeEngine'
51
51
  export { default as SessionProvider } from './providers/SessionProvider';
52
52
  export { default as DataLayer } from './util/DataLayer';
53
53
  export * from './util/DataLayer';
54
+ export * from './util/DefaultValueManager';
54
55
  export * from './util/RouteManager';
55
56
  export * from './contexts/index.js';
56
57
  export { useFormContext } from 'react-hook-form';
package/dist/src/index.js CHANGED
@@ -117,6 +117,7 @@ Object.defineProperty(exports, "SessionProvider", { enumerable: true, get: funct
117
117
  var DataLayer_1 = require("./util/DataLayer");
118
118
  Object.defineProperty(exports, "DataLayer", { enumerable: true, get: function () { return __importDefault(DataLayer_1).default; } });
119
119
  __exportStar(require("./util/DataLayer"), exports);
120
+ __exportStar(require("./util/DefaultValueManager"), exports);
120
121
  __exportStar(require("./util/RouteManager"), exports);
121
122
  __exportStar(require("./contexts/index.js"), exports);
122
123
  var react_hook_form_1 = require("react-hook-form");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kCAAkC;AAClC,kDAA6B;AAE7B,uGAA+E;AAC/E,+EAAuD;AACvD,+EAAuD;AACvD,qFAA6D;AAC7D,qEAA6C;AAE7C,yFAAiE;AAEpD,QAAA,KAAK,GAAG,eAAQ,CAAC;AAE9B,+CAA+C;AAAtC,+GAAA,cAAc,OAAA;AACvB,qDAAwC;AAA/B,wGAAA,IAAI,OAAA;AAEb,aAAa;AACb,8DAAwE;AAA/D,iIAAA,OAAO,OAAkB;AAClC,6DAA2C;AAC3C,oDAA8D;AAArD,+GAAA,OAAO,OAAS;AACzB,0DAAoE;AAA3D,qHAAA,OAAO,OAAY;AAC5B,mEAA6E;AAApE,qHAAA,OAAO,OAAY;AAC5B,0DAAoE;AAA3D,qHAAA,OAAO,OAAY;AAC5B,uDAAiE;AAAxD,6GAAA,OAAO,OAAQ;AACxB,iEAA+C;AAC/C,yEAAmF;AAA1E,yHAAA,OAAO,OAAc;AAC9B,4DAAsE;AAA7D,uHAAA,OAAO,OAAa;AAC7B,sEAAgF;AAAvE,2HAAA,OAAO,OAAe;AAC/B,oEAAkD;AAClD,4DAA0C;AAC1C,0DAAoE;AAA3D,qHAAA,OAAO,OAAY;AAC5B,wDAAkE;AAAzD,mHAAA,OAAO,OAAW;AAC3B,oGAAkF;AAClF,mHAA6H;AAApH,mKAAA,OAAO,OAAmC;AACnD,+EAAoF;AAA3E,4HAAA,uBAAuB,OAAA;AAChC,+EAAyF;AAAhF,uIAAA,OAAO,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AAA;AACxB,kEAAgD;AAChD,8EAA4D;AAE5D,QAAQ;AACR,+DAAyE;AAAhE,uHAAA,OAAO,OAAa;AAC7B,oFAA8F;AAArF,qIAAA,OAAO,OAAoB;AACpC,4DAAsE;AAA7D,qHAAA,OAAO,OAAY;AAC5B,iFAA2F;AAAlF,mIAAA,OAAO,OAAmB;AACnC,+DAAyE;AAAhE,uHAAA,OAAO,OAAa;AAC7B,4DAAsE;AAA7D,qHAAA,OAAO,OAAY;AAC5B,kEAA4E;AAAnE,yHAAA,OAAO,OAAc;AAC9B,6DAA2C;AAC3C,kDAA4D;AAAnD,2HAAA,OAAO,OAAe;AAK/B,+CAA6B;AAC7B,kDAAgC;AAEhC,QAAQ;AAER,iDAA+B;AAC/B,2DAAyC;AACzC,oDAAkC;AAElC,gDAAgD;AAChD,sEAAgF;AAAvE,6IAAA,OAAO,OAAwB;AAE3B,QAAA,MAAM,GAAG;IAClB,EAAE,EAAE,8BAAoB,CAAC,QAAQ;IACjC,KAAK,EAAE,8BAAoB,CAAC,KAAK;CACpC,CAAC;AAGW,QAAA,OAAO,GAAG,UAAU,CAAC;AAElC,qBAAW,CAAC,YAAY,GAAG;IACvB,CAAC,EAAE,kBAAQ;IACX,EAAE,EAAE,kBAAQ;IACZ,EAAE,EAAE,0BAAgB;IACpB,EAAE,EAAE,oBAAU;CACjB,CAAC","sourcesContent":["// TODO: Look into resolving this.\nimport ReactRaw from 'react';\n\nimport StepConfirmation from '@/pages/steps/StepConfirmation/StepConfirmation';\nimport StepDate from '@/pages/steps/StepDate/StepDate';\nimport StepRoom from '@/pages/steps/StepRoom/StepRoom';\nimport StepThanks from '@/pages/steps/StepThanks/StepThanks';\nimport StepManager from '@/util/StepManager';\n\nimport RoomstayEventManager from './events/RoomstayEventManager';\n\nexport const react = ReactRaw;\n\nexport { useTranslation } from 'react-i18next';\nexport { Link } from 'react-router-dom';\n\n// Components\nexport { default as AutoAutoHeight } from '@/animations/AutoAutoHeight';\nexport * from '@/components/generic/Alert';\nexport { default as Alert } from '@/components/generic/Alert';\nexport { default as BEButton } from '@/components/generic/BEButton';\nexport { default as Checkbox } from '@/components/generic/Checkbox/Checkbox';\nexport { default as Headline } from '@/components/generic/Headline';\nexport { default as Icon } from '@/components/generic/Icon/Icon';\nexport * from '@/components/generic/Icon/Icon';\nexport { default as InputGroup } from '@/components/generic/InputGroup/InputGroup';\nexport { default as LineBreak } from '@/components/generic/LineBreak';\nexport { default as RadioFields } from '@/components/generic/radio/RadioFields';\nexport * from '@/components/generic/Select/index';\nexport * from '@/components/generic/Text';\nexport { default as TextArea } from '@/components/generic/TextArea';\nexport { default as TextBox } from '@/components/generic/TextBox';\nexport * from '@/components/steps/confirmation/StepConfirmationCommentsComponent';\nexport { default as StepConfirmationCountrySelector } from '@/components/steps/confirmation/StepConfirmationCountrySelector';\nexport { BE_NO_ROOMS_FOUND_BLOCK } from '@/components/steps/room/NoRoomsFoundBlock';\nexport { default as NoRoomsFoundBlock } from '@/components/steps/room/NoRoomsFoundBlock';\nexport * from '@/components/steps/room/StepRoomBestRateAlert';\nexport { default as StepNoRoomBestRateAlert } from '@/components/steps/room/StepRoomBestRateAlert';\nexport * from '@/components/summary/BESummary';\nexport * from '@/components/summary/BESummaryPerkBlock';\nexport * from '@/engines/BookingWizardEngine/BookingWizardEngine';\nexport * from '@/engines/CustomEngine/CustomEngine';\nexport * from '@/engines/FullPageBookingEngine/FullPageBookingEngine';\nexport * from '@/engines/InlineRoomMiniEngine/InlineRoomMiniEngine';\nexport * from '@/engines/RecentSearchesEngine/RecentSearchesEngine';\n\n// Loaders\nexport { default as SmallSpinner } from '@/components/generic/loader/SmallSpinner';\n\n// Providers\nexport * from '@/providers/CurrencyProvider';\nexport { default as CurrencyProvider } from '@/providers/CurrencyProvider';\nexport { default as FeatureProvider } from '@/providers/FeatureProvider';\nexport * from '@/providers/LanguageProvider';\nexport * from '@/providers/PromotionProvider';\nexport { default as RatePillProvider } from '@/providers/RatePillProvider';\n\n// Features\n\nexport { default as ConfirmationVerifyFeature } from '@/providers/feature/ConfirmationVerifyFeature';\nexport { default as DatePickerTypeFeature } from '@/providers/feature/DatePickerTypeFeature';\nexport { default as E164PhoneNumberFieldFeature } from '@/providers/feature/E164PhoneNumberFieldFeature';\nexport { default as FeaturedPromoFeature } from '@/providers/feature/FeaturedPromoFeature';\nexport { default as FullPageEngineSmallSpacingFeature } from '@/providers/feature/FullPageEngineSmallSpacingFeature';\nexport { default as InlineAddonStepFeature } from '@/providers/feature/InlineAddonStepFeature';\nexport { default as RoomUpsellFeature } from '@/providers/feature/RoomUpsellFeature';\nexport { default as ShowIATANumberOnCheckoutFeature } from '@/providers/feature/ShowIATANumberOnCheckoutFeature';\n\n// Contexts\nexport { registerReplacement, withDI } from '@/providers/DIProvider';\nexport * from '@/providers/RoomstayThemeEngine';\nexport { default as RoomstayThemeEngine } from '@/providers/RoomstayThemeEngine';\nexport { default as SessionProvider } from '@/providers/SessionProvider';\nexport { default as DataLayer } from '@/util/DataLayer';\nexport * from '@/util/DataLayer';\nexport * from '@/util/RouteManager';\nexport * from '@frontend/contexts';\nexport { useFormContext } from 'react-hook-form';\n\n// Models\nexport { default as API } from '@/api/BookingAPI';\nexport * from '@/models/Api/HotelDTO';\nexport * from '@/models/Api/HotelOverrideDTO';\nexport * from '@/models/Client/Hotel/Company';\nexport * from '@/models/Client/Hotel/DistanceUnitType.types';\nexport * from '@/models/Client/Hotel/Hotel';\nexport { HotelDataSource } from '@/models/Client/Hotel/HotelDataSource.types';\nexport * from '@/models/Client/Hotel/HotelPerk';\nexport * from '@/models/Client/Hotel/WeekdayStartsOn.types';\n\n// Steps\nexport { default as StepAddon } from '@/pages/steps/StepAddon/StepAddon';\nexport { default as StepConfirmation } from '@/pages/steps/StepConfirmation/StepConfirmation';\nexport { default as StepDate } from '@/pages/steps/StepDate/StepDate';\nexport { default as StepGroupedRoom } from '@/pages/steps/StepGroupedRoom/StepGroupedRoom';\nexport { default as StepHotel } from '@/pages/steps/StepHotel/StepHotel';\nexport { default as StepRoom } from '@/pages/steps/StepRoom/StepRoom';\nexport { default as StepThanks } from '@/pages/steps/StepThanks/StepThanks';\nexport * from '@/translations/Translation';\nexport { default as StepManager } from '@/util/StepManager';\n\n// Util\n\nexport type { default as ColorProfile } from '@/models/Client/Hotel/ColorProfile';\nexport * from '@/util/Color';\nexport * from '@/util/Debounce';\n\n// Hooks\n\nexport * from '@/events/index';\nexport * from '@/hooks/CurrentHotelHook';\nexport * from '@/hooks/EventHook';\n\n/** @deprecated use `roomstay.events` instead */\nexport { default as RoomstayEventManager } from '@/events/RoomstayEventManager';\n\nexport const events = {\n on: RoomstayEventManager.addEvent,\n raise: RoomstayEventManager.raise,\n};\n\ndeclare const RS_VERSION: string;\nexport const Version = RS_VERSION;\n\nStepManager.currentSteps = {\n 0: StepDate,\n 10: StepRoom,\n 20: StepConfirmation,\n 30: StepThanks,\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kCAAkC;AAClC,kDAA6B;AAE7B,uGAA+E;AAC/E,+EAAuD;AACvD,+EAAuD;AACvD,qFAA6D;AAC7D,qEAA6C;AAE7C,yFAAiE;AAEpD,QAAA,KAAK,GAAG,eAAQ,CAAC;AAE9B,+CAA+C;AAAtC,+GAAA,cAAc,OAAA;AACvB,qDAAwC;AAA/B,wGAAA,IAAI,OAAA;AAEb,aAAa;AACb,8DAAwE;AAA/D,iIAAA,OAAO,OAAkB;AAClC,6DAA2C;AAC3C,oDAA8D;AAArD,+GAAA,OAAO,OAAS;AACzB,0DAAoE;AAA3D,qHAAA,OAAO,OAAY;AAC5B,mEAA6E;AAApE,qHAAA,OAAO,OAAY;AAC5B,0DAAoE;AAA3D,qHAAA,OAAO,OAAY;AAC5B,uDAAiE;AAAxD,6GAAA,OAAO,OAAQ;AACxB,iEAA+C;AAC/C,yEAAmF;AAA1E,yHAAA,OAAO,OAAc;AAC9B,4DAAsE;A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from '@/pages/steps/StepConfirmation/StepConfirmation';\nimport StepDate from '@/pages/steps/StepDate/StepDate';\nimport StepRoom from '@/pages/steps/StepRoom/StepRoom';\nimport StepThanks from '@/pages/steps/StepThanks/StepThanks';\nimport StepManager from '@/util/StepManager';\n\nimport RoomstayEventManager from './events/RoomstayEventManager';\n\nexport const react = ReactRaw;\n\nexport { useTranslation } from 'react-i18next';\nexport { Link } from 'react-router-dom';\n\n// Components\nexport { default as AutoAutoHeight } from '@/animations/AutoAutoHeight';\nexport * from '@/components/generic/Alert';\nexport { default as Alert } from '@/components/generic/Alert';\nexport { default as BEButton } from '@/components/generic/BEButton';\nexport { default as Checkbox } from '@/components/generic/Checkbox/Checkbox';\nexport { default as Headline } from '@/components/generic/Headline';\nexport { default as Icon } from '@/components/generic/Icon/Icon';\nexport * from '@/components/generic/Icon/Icon';\nexport { default as InputGroup } from '@/components/generic/InputGroup/InputGroup';\nexport { default as LineBreak } from '@/components/generic/LineBreak';\nexport { default as RadioFields } from '@/components/generic/radio/RadioFields';\nexport * from '@/components/generic/Select/index';\nexport * from '@/components/generic/Text';\nexport { default as TextArea } from '@/components/generic/TextArea';\nexport { default as TextBox } from '@/components/generic/TextBox';\nexport * from '@/components/steps/confirmation/StepConfirmationCommentsComponent';\nexport { default as StepConfirmationCountrySelector } from '@/components/steps/confirmation/StepConfirmationCountrySelector';\nexport { BE_NO_ROOMS_FOUND_BLOCK } from '@/components/steps/room/NoRoomsFoundBlock';\nexport { default as NoRoomsFoundBlock } from '@/components/steps/room/NoRoomsFoundBlock';\nexport * from '@/components/steps/room/StepRoomBestRateAlert';\nexport { default as StepNoRoomBestRateAlert } from '@/components/steps/room/StepRoomBestRateAlert';\nexport * from '@/components/summary/BESummary';\nexport * from '@/components/summary/BESummaryPerkBlock';\nexport * from '@/engines/BookingWizardEngine/BookingWizardEngine';\nexport * from '@/engines/CustomEngine/CustomEngine';\nexport * from '@/engines/FullPageBookingEngine/FullPageBookingEngine';\nexport * from '@/engines/InlineRoomMiniEngine/InlineRoomMiniEngine';\nexport * from '@/engines/RecentSearchesEngine/RecentSearchesEngine';\n\n// Loaders\nexport { default as SmallSpinner } from '@/components/generic/loader/SmallSpinner';\n\n// Providers\nexport * from '@/providers/CurrencyProvider';\nexport { default as CurrencyProvider } from '@/providers/CurrencyProvider';\nexport { default as FeatureProvider } from '@/providers/FeatureProvider';\nexport * from '@/providers/LanguageProvider';\nexport * from '@/providers/PromotionProvider';\nexport { default as RatePillProvider } from '@/providers/RatePillProvider';\n\n// Features\n\nexport { default as ConfirmationVerifyFeature } from '@/providers/feature/ConfirmationVerifyFeature';\nexport { default as DatePickerTypeFeature } from '@/providers/feature/DatePickerTypeFeature';\nexport { default as E164PhoneNumberFieldFeature } from '@/providers/feature/E164PhoneNumberFieldFeature';\nexport { default as FeaturedPromoFeature } from '@/providers/feature/FeaturedPromoFeature';\nexport { default as FullPageEngineSmallSpacingFeature } from '@/providers/feature/FullPageEngineSmallSpacingFeature';\nexport { default as InlineAddonStepFeature } from '@/providers/feature/InlineAddonStepFeature';\nexport { default as RoomUpsellFeature } from '@/providers/feature/RoomUpsellFeature';\nexport { default as ShowIATANumberOnCheckoutFeature } from '@/providers/feature/ShowIATANumberOnCheckoutFeature';\n\n// Contexts\nexport { registerReplacement, withDI } from '@/providers/DIProvider';\nexport * from '@/providers/RoomstayThemeEngine';\nexport { default as RoomstayThemeEngine } from '@/providers/RoomstayThemeEngine';\nexport { default as SessionProvider } from '@/providers/SessionProvider';\nexport { default as DataLayer } from '@/util/DataLayer';\nexport * from '@/util/DataLayer';\nexport * from '@/util/DefaultValueManager';\nexport * from '@/util/RouteManager';\nexport * from '@frontend/contexts';\nexport { useFormContext } from 'react-hook-form';\n\n// Models\nexport { default as API } from '@/api/BookingAPI';\nexport * from '@/models/Api/HotelDTO';\nexport * from '@/models/Api/HotelOverrideDTO';\nexport * from '@/models/Client/Hotel/Company';\nexport * from '@/models/Client/Hotel/DistanceUnitType.types';\nexport * from '@/models/Client/Hotel/Hotel';\nexport { HotelDataSource } from '@/models/Client/Hotel/HotelDataSource.types';\nexport * from '@/models/Client/Hotel/HotelPerk';\nexport * from '@/models/Client/Hotel/WeekdayStartsOn.types';\n\n// Steps\nexport { default as StepAddon } from '@/pages/steps/StepAddon/StepAddon';\nexport { default as StepConfirmation } from '@/pages/steps/StepConfirmation/StepConfirmation';\nexport { default as StepDate } from '@/pages/steps/StepDate/StepDate';\nexport { default as StepGroupedRoom } from '@/pages/steps/StepGroupedRoom/StepGroupedRoom';\nexport { default as StepHotel } from '@/pages/steps/StepHotel/StepHotel';\nexport { default as StepRoom } from '@/pages/steps/StepRoom/StepRoom';\nexport { default as StepThanks } from '@/pages/steps/StepThanks/StepThanks';\nexport * from '@/translations/Translation';\nexport { default as StepManager } from '@/util/StepManager';\n\n// Util\n\nexport type { default as ColorProfile } from '@/models/Client/Hotel/ColorProfile';\nexport * from '@/util/Color';\nexport * from '@/util/Debounce';\n\n// Hooks\n\nexport * from '@/events/index';\nexport * from '@/hooks/CurrentHotelHook';\nexport * from '@/hooks/EventHook';\n\n/** @deprecated use `roomstay.events` instead */\nexport { default as RoomstayEventManager } from '@/events/RoomstayEventManager';\n\nexport const events = {\n on: RoomstayEventManager.addEvent,\n raise: RoomstayEventManager.raise,\n};\n\ndeclare const RS_VERSION: string;\nexport const Version = RS_VERSION;\n\nStepManager.currentSteps = {\n 0: StepDate,\n 10: StepRoom,\n 20: StepConfirmation,\n 30: StepThanks,\n};\n"]}
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const Color_1 = require("../util/Color");
4
+ const DefaultValueManager_1 = require("../util/DefaultValueManager");
4
5
  class BasketRow {
5
6
  constructor(rate, uniqId) {
7
+ var _a, _b;
6
8
  /*
7
9
  Rate is optional since we can create row entries
8
10
  on first step, where there is no ability to select rate.
@@ -10,8 +12,8 @@ class BasketRow {
10
12
  if (rate) {
11
13
  this.setRate(rate);
12
14
  }
13
- this.adults = 1;
14
- this.children = 0;
15
+ this.adults = (_a = DefaultValueManager_1.DEFAULT_VALUES.ADULTS) !== null && _a !== void 0 ? _a : 1;
16
+ this.children = (_b = DefaultValueManager_1.DEFAULT_VALUES.CHILDREN) !== null && _b !== void 0 ? _b : 0;
15
17
  this.promoCode = '';
16
18
  this.promoCodeStatus = 'new';
17
19
  this.promoOnly = false;
@@ -1 +1 @@
1
- {"version":3,"file":"BasketRow.js","sourceRoot":"/","sources":["src/models/BasketRow.ts"],"names":[],"mappings":";;AAOA,wCAAqC;AAErC,MAAqB,SAAS;IAkB1B,YAAmB,IAAe,EAAE,MAAe;QAC/C;;;MAGF;QACE,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtB;QAED,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAEvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5F,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEM,OAAO;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;IACxC,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAEM,kBAAkB;QACrB,IAAI,IAAI,CAAC,eAAe,KAAK,O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E,CAAC;QAE7C,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACnF,WAAW,CAAC,UAAU,GAAG;gBACrB,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE;gBAC5B,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ;aAC5B,CAAC;SACL;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE;YACjC,WAAW,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAE9B,OAAO,WAAW,CAAC;SACtB;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;CACJ;AAlND,4BAkNC","sourcesContent":["import { IRoomstayMember } from '@roomstay/core';\nimport dayjs from 'dayjs';\n\nimport { ReservationDTO } from '@/models/Api/ReservationsDTO';\nimport BasketRowDifferences from '@/models/BasketRowDifferences';\nimport type { Room } from '@/models/Room/Room';\nimport type { RoomRate } from '@/models/Room/RoomRate';\nimport { Color } from '@/util/Color';\n\nexport default class BasketRow {\n private uniqId: string;\n\n private room!: Room;\n private rate!: RoomRate | null;\n private isStale!: boolean;\n private adults: number;\n private children: number;\n\n private promoCode: string;\n private promoCodeStatus: 'valid' | 'invalid' | 'new';\n\n private startDate!: dayjs.Dayjs;\n private endDate!: dayjs.Dayjs;\n\n private promoOnly: boolean;\n private member?: Partial<IRoomstayMember>;\n\n public constructor(rate?: RoomRate, uniqId?: string) {\n /*\n Rate is optional since we can create row entries\n on first step, where there is no ability to select rate.\n */\n if (rate) {\n this.setRate(rate);\n }\n\n this.adults = 1;\n this.children = 0;\n this.promoCode = '';\n this.promoCodeStatus = 'new';\n this.promoOnly = false;\n\n this.uniqId = uniqId ? uniqId : btoa(((Date.now() % 1000) / 1000) * Math.random() + '');\n }\n\n public getStale() {\n return this.isStale;\n }\n\n public getRate() {\n return this.rate;\n }\n\n public getPromoCode() {\n return this.promoCode.toUpperCase();\n }\n\n public getPromoOnly() {\n return this.promoOnly;\n }\n\n public getPromoCodeColour() {\n if (this.promoCodeStatus === 'valid') {\n return Color.Success;\n } else if (this.promoCodeStatus === 'invalid') {\n return Color.Alert;\n }\n\n return Color.Navy;\n }\n\n public isPromoCodeValid() {\n const rate = this.getRate();\n\n return (rate?.getAveragePrice(true) as number) < (rate?.getAveragePriceBeforeDiscount(true) as number) && this.getPromoCode() && this.getPromoCodeStatus() === 'valid';\n }\n\n public getNumberOfDays() {\n if (this.endDate && this.startDate) {\n return this.endDate.diff(this.startDate, 'day');\n }\n\n return 0;\n }\n\n public getRoom() {\n return this.room;\n }\n\n public getStartDate() {\n return this.startDate;\n }\n\n public getEndDate() {\n return this.endDate;\n }\n\n public getArrivalDate() {\n if (this.startDate) {\n return this.startDate.format('D MMM');\n }\n\n return null;\n }\n\n public getDepartureDate() {\n if (this.endDate) {\n return this.endDate.format('D MMM');\n }\n\n return null;\n }\n\n public getStayDateRange(format = 'ddd D MMM', separator = ',') {\n if (this.startDate && this.endDate) {\n return `${this.startDate.format(format)}${separator} ${this.endDate.format(format)}`;\n }\n }\n\n public getAdults() {\n return this.adults;\n }\n\n public getChildren() {\n return this.children;\n }\n\n public getID() {\n return this.uniqId;\n }\n\n public getPromoCodeStatus() {\n return this.promoCodeStatus;\n }\n\n public isValid(): boolean {\n return this.startDate && this.endDate && !!this.rate;\n }\n\n public setPromoCode(code: string) {\n if (this.promoCode !== code.toUpperCase()) {\n this.setPromoCodeStatus('new');\n this.promoOnly = false;\n }\n\n this.promoCode = code.toUpperCase();\n }\n\n public setPromoOnly(value: boolean) {\n this.promoOnly = value;\n }\n\n public setStale(status: boolean) {\n this.isStale = status;\n }\n\n public setPromoCodeStatus(status: 'valid' | 'invalid' | 'new') {\n this.promoCodeStatus = this.promoCode ? status : 'new';\n }\n\n public setStartDate(date: dayjs.Dayjs) {\n if (this.rate && !date.isSame(this.startDate) && this.startDate) {\n this.rate = null;\n }\n\n if (date?.isValid() || date === undefined) {\n this.startDate = date;\n }\n }\n\n public setEndDate(date: dayjs.Dayjs) {\n if (this.rate && !date.isSame(this.endDate) && this.endDate) {\n this.rate = null;\n }\n\n if (date?.isValid() || date === undefined) {\n this.endDate = date;\n }\n }\n\n public setAdults(adults: number) {\n this.adults = adults;\n }\n\n public setChildren(children: number) {\n this.children = children;\n }\n\n public setRate(rate: RoomRate) {\n this.rate = rate;\n this.room = rate.getRoom();\n }\n\n public setMember(member: Partial<IRoomstayMember>) {\n this.member = member;\n }\n\n public getTotalPrice(beforeTax = false) {\n return this.getRate()?.getTotalPrice(beforeTax);\n }\n\n public checkDiffFromReservation(res: ReservationDTO) {\n const differences: BasketRowDifferences = {};\n\n if (Number(res.total.afterTax).toFixed(2) !== Number(this.getTotalPrice()).toFixed(2)) {\n differences.totalPrice = {\n before: this.getTotalPrice(),\n after: res.total.afterTax,\n };\n }\n\n if (Object.keys(differences).length) {\n differences.id = this.getID();\n\n return differences;\n } else {\n return false;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"BasketRow.js","sourceRoot":"/","sources":["src/models/BasketRow.ts"],"names":[],"mappings":";;AAOA,wCAAqC;AACrC,oEAA4D;AAE5D,MAAqB,SAAS;IAkB1B,YAAmB,IAAe,EAAE,MAAe;;QAC/C;;;MAGF;QACE,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtB;QAED,IAAI,CAAC,MAAM,GAAG,MAAA,oCAAc,CAAC,MAAM,mCAAI,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,MAAA,oCAAc,CAAC,QAAQ,mCAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK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QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,WAAW,CAAC,QAAgB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAEM,OAAO,CAAC,IAAc;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAEM,SAAS,CAAC,MAAgC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,aAAa,CAAC,SAAS,GAAG,KAAK;;QAClC,OAAO,MAAA,IAAI,CAAC,OAAO,EAAE,0CAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAEM,wBAAwB,CAAC,GAAmB;QAC/C,MAAM,WAAW,GAAyB,EAAE,CAAC;QAE7C,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACnF,WAAW,CAAC,UAAU,GAAG;gBACrB,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE;gBAC5B,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ;aAC5B,CAAC;SACL;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE;YACjC,WAAW,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAE9B,OAAO,WAAW,CAAC;SACtB;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;CACJ;AAlND,4BAkNC","sourcesContent":["import { IRoomstayMember } from '@roomstay/core';\nimport dayjs from 'dayjs';\n\nimport { ReservationDTO } from '@/models/Api/ReservationsDTO';\nimport BasketRowDifferences from '@/models/BasketRowDifferences';\nimport type { Room } from '@/models/Room/Room';\nimport type { RoomRate } from '@/models/Room/RoomRate';\nimport { Color } from '@/util/Color';\nimport { DEFAULT_VALUES } from '@/util/DefaultValueManager';\n\nexport default class BasketRow {\n private uniqId: string;\n\n private room!: Room;\n private rate!: RoomRate | null;\n private isStale!: boolean;\n private adults: number;\n private children: number;\n\n private promoCode: string;\n private promoCodeStatus: 'valid' | 'invalid' | 'new';\n\n private startDate!: dayjs.Dayjs;\n private endDate!: dayjs.Dayjs;\n\n private promoOnly: boolean;\n private member?: Partial<IRoomstayMember>;\n\n public constructor(rate?: RoomRate, uniqId?: string) {\n /*\n Rate is optional since we can create row entries\n on first step, where there is no ability to select rate.\n */\n if (rate) {\n this.setRate(rate);\n }\n\n this.adults = DEFAULT_VALUES.ADULTS ?? 1;\n this.children = DEFAULT_VALUES.CHILDREN ?? 0;\n this.promoCode = '';\n this.promoCodeStatus = 'new';\n this.promoOnly = false;\n\n this.uniqId = uniqId ? uniqId : btoa(((Date.now() % 1000) / 1000) * Math.random() + '');\n }\n\n public getStale() {\n return this.isStale;\n }\n\n public getRate() {\n return this.rate;\n }\n\n public getPromoCode() {\n return this.promoCode.toUpperCase();\n }\n\n public getPromoOnly() {\n return this.promoOnly;\n }\n\n public getPromoCodeColour() {\n if (this.promoCodeStatus === 'valid') {\n return Color.Success;\n } else if (this.promoCodeStatus === 'invalid') {\n return Color.Alert;\n }\n\n return Color.Navy;\n }\n\n public isPromoCodeValid() {\n const rate = this.getRate();\n\n return (rate?.getAveragePrice(true) as number) < (rate?.getAveragePriceBeforeDiscount(true) as number) && this.getPromoCode() && this.getPromoCodeStatus() === 'valid';\n }\n\n public getNumberOfDays() {\n if (this.endDate && this.startDate) {\n return this.endDate.diff(this.startDate, 'day');\n }\n\n return 0;\n }\n\n public getRoom() {\n return this.room;\n }\n\n public getStartDate() {\n return this.startDate;\n }\n\n public getEndDate() {\n return this.endDate;\n }\n\n public getArrivalDate() {\n if (this.startDate) {\n return this.startDate.format('D MMM');\n }\n\n return null;\n }\n\n public getDepartureDate() {\n if (this.endDate) {\n return this.endDate.format('D MMM');\n }\n\n return null;\n }\n\n public getStayDateRange(format = 'ddd D MMM', separator = ',') {\n if (this.startDate && this.endDate) {\n return `${this.startDate.format(format)}${separator} ${this.endDate.format(format)}`;\n }\n }\n\n public getAdults() {\n return this.adults;\n }\n\n public getChildren() {\n return this.children;\n }\n\n public getID() {\n return this.uniqId;\n }\n\n public getPromoCodeStatus() {\n return this.promoCodeStatus;\n }\n\n public isValid(): boolean {\n return this.startDate && this.endDate && !!this.rate;\n }\n\n public setPromoCode(code: string) {\n if (this.promoCode !== code.toUpperCase()) {\n this.setPromoCodeStatus('new');\n this.promoOnly = false;\n }\n\n this.promoCode = code.toUpperCase();\n }\n\n public setPromoOnly(value: boolean) {\n this.promoOnly = value;\n }\n\n public setStale(status: boolean) {\n this.isStale = status;\n }\n\n public setPromoCodeStatus(status: 'valid' | 'invalid' | 'new') {\n this.promoCodeStatus = this.promoCode ? status : 'new';\n }\n\n public setStartDate(date: dayjs.Dayjs) {\n if (this.rate && !date.isSame(this.startDate) && this.startDate) {\n this.rate = null;\n }\n\n if (date?.isValid() || date === undefined) {\n this.startDate = date;\n }\n }\n\n public setEndDate(date: dayjs.Dayjs) {\n if (this.rate && !date.isSame(this.endDate) && this.endDate) {\n this.rate = null;\n }\n\n if (date?.isValid() || date === undefined) {\n this.endDate = date;\n }\n }\n\n public setAdults(adults: number) {\n this.adults = adults;\n }\n\n public setChildren(children: number) {\n this.children = children;\n }\n\n public setRate(rate: RoomRate) {\n this.rate = rate;\n this.room = rate.getRoom();\n }\n\n public setMember(member: Partial<IRoomstayMember>) {\n this.member = member;\n }\n\n public getTotalPrice(beforeTax = false) {\n return this.getRate()?.getTotalPrice(beforeTax);\n }\n\n public checkDiffFromReservation(res: ReservationDTO) {\n const differences: BasketRowDifferences = {};\n\n if (Number(res.total.afterTax).toFixed(2) !== Number(this.getTotalPrice()).toFixed(2)) {\n differences.totalPrice = {\n before: this.getTotalPrice(),\n after: res.total.afterTax,\n };\n }\n\n if (Object.keys(differences).length) {\n differences.id = this.getID();\n\n return differences;\n } else {\n return false;\n }\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export declare enum DEFAULT_VALUES_NAMES {
2
+ ADULTS = "ADULTS",
3
+ CHILDREN = "CHILDREN"
4
+ }
5
+ export declare const DEFAULT_VALUES: {
6
+ [name in DEFAULT_VALUES_NAMES]?: any;
7
+ };
8
+ export declare const registerDefaultValuesReplacement: (valueName: DEFAULT_VALUES_NAMES, value: any) => void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerDefaultValuesReplacement = exports.DEFAULT_VALUES = exports.DEFAULT_VALUES_NAMES = void 0;
4
+ var DEFAULT_VALUES_NAMES;
5
+ (function (DEFAULT_VALUES_NAMES) {
6
+ DEFAULT_VALUES_NAMES["ADULTS"] = "ADULTS";
7
+ DEFAULT_VALUES_NAMES["CHILDREN"] = "CHILDREN";
8
+ })(DEFAULT_VALUES_NAMES = exports.DEFAULT_VALUES_NAMES || (exports.DEFAULT_VALUES_NAMES = {}));
9
+ exports.DEFAULT_VALUES = {};
10
+ const registerDefaultValuesReplacement = (valueName, value) => {
11
+ exports.DEFAULT_VALUES[valueName] = value;
12
+ };
13
+ exports.registerDefaultValuesReplacement = registerDefaultValuesReplacement;
14
+ //# sourceMappingURL=DefaultValueManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultValueManager.js","sourceRoot":"/","sources":["src/util/DefaultValueManager.ts"],"names":[],"mappings":";;;AAAA,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC5B,yCAAiB,CAAA;IACjB,6CAAqB,CAAA;AACzB,CAAC,EAHW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAG/B;AAEY,QAAA,cAAc,GAA6C,EAAE,CAAC;AAEpE,MAAM,gCAAgC,GAAG,CAAC,SAA+B,EAAE,KAAU,EAAE,EAAE;IAC5F,sBAAc,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;AACtC,CAAC,CAAC;AAFW,QAAA,gCAAgC,oCAE3C","sourcesContent":["export enum DEFAULT_VALUES_NAMES {\n ADULTS = 'ADULTS',\n CHILDREN = 'CHILDREN',\n}\n\nexport const DEFAULT_VALUES: { [name in DEFAULT_VALUES_NAMES]?: any } = {};\n\nexport const registerDefaultValuesReplacement = (valueName: DEFAULT_VALUES_NAMES, value: any) => {\n DEFAULT_VALUES[valueName] = value;\n};\n"]}