@roomstay/frontend 2.4.5 → 2.4.7
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.
- package/dist/468.bundle.js +1 -1
- package/dist/main.bundle.js +1 -1
- package/dist/src/contexts/ConfirmationStepContext/ConfirmationStepContextWrapper.js +8 -4
- package/dist/src/contexts/ConfirmationStepContext/ConfirmationStepContextWrapper.js.map +1 -1
- package/dist/test.bundle.js +1 -1
- package/package.json +1 -1
|
@@ -123,9 +123,13 @@ const ConfirmationStepContextWrapper = ({ children }) => {
|
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
const onSubmitSuccess = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
const onSubmitSuccess = (data, paymentMethod) => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
127
|
var _a, _b, _c, _d;
|
|
128
128
|
raise(new PlacedBookingEvent_1.PlacedBookingEvent(data, basketContext.currentBasketRows));
|
|
129
|
+
// If this is a planpay booking, we don't need to do anything else.
|
|
130
|
+
if (paymentMethod === core_1.EBookingPaymentMethod.Planpay) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
129
133
|
if ((hotel === null || hotel === void 0 ? void 0 : hotel.cardProcessor) === core_1.EHotelCardProcessor.Passthrough) {
|
|
130
134
|
yield (commitReservation === null || commitReservation === void 0 ? void 0 : commitReservation(data));
|
|
131
135
|
}
|
|
@@ -159,7 +163,7 @@ const ConfirmationStepContextWrapper = ({ children }) => {
|
|
|
159
163
|
onPostValidationError === null || onPostValidationError === void 0 ? void 0 : onPostValidationError(validationResult);
|
|
160
164
|
}
|
|
161
165
|
else {
|
|
162
|
-
yield onSubmitSuccess(data);
|
|
166
|
+
yield onSubmitSuccess(data, payment.Method);
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
catch (error) {
|
|
@@ -245,7 +249,7 @@ const ConfirmationStepContextWrapper = ({ children }) => {
|
|
|
245
249
|
window.location.href = targetUrl;
|
|
246
250
|
};
|
|
247
251
|
const onRetryBooking = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
|
-
var _e;
|
|
252
|
+
var _e, _f;
|
|
249
253
|
setErrorModalLoading(true);
|
|
250
254
|
const resRequest = currentSession === null || currentSession === void 0 ? void 0 : currentSession.reservationRequest;
|
|
251
255
|
const roomstayId = (_e = currentSession === null || currentSession === void 0 ? void 0 : currentSession.reservation) === null || _e === void 0 ? void 0 : _e.roomstayId;
|
|
@@ -260,7 +264,7 @@ const ConfirmationStepContextWrapper = ({ children }) => {
|
|
|
260
264
|
setIsLoading(false);
|
|
261
265
|
}
|
|
262
266
|
else {
|
|
263
|
-
yield onSubmitSuccess(data);
|
|
267
|
+
yield onSubmitSuccess(data, (_f = resRequest.payment) === null || _f === void 0 ? void 0 : _f.Method);
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
270
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationStepContextWrapper.js","sourceRoot":"/","sources":["src/contexts/ConfirmationStepContext/ConfirmationStepContextWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAuF;AACvF,2CAA4D;AAC5D,yCAAkF;AAClF,wDAA0C;AAC1C,yCAAyC;AACzC,+CAA+F;AAC/F,qDAAwD;AACxD,iDAA+C;AAC/C,+CAA0C;AAE1C,kEAAmC;AACnC,6EAA0E;AAC1E,wGAAqG;AACrG,gFAA6E;AAC7E,0EAAuE;AACvE,kFAA+E;AAC/E,iEAAiE;AAKjE,4DAAyD;AACzD,8DAA+E;AAG/E,6EAA0E;AAE1E,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,EAA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AI;YAE7I,QAAQ,CACqB,CACvB,CAClB,CAAC;AACN,CAAC,CAAC;AA1RW,QAAA,8BAA8B,kCA0RzC","sourcesContent":["import { BasketContext, BookingEngineContext, ErrorHandler } from '@frontend/contexts';\nimport { useCurrentHotel, useEvent } from '@frontend/hooks';\nimport { EHotelCardProcessor, IBookingCreateErrorResponse } from '@roomstay/core';\nimport * as Sentry from '@sentry/browser';\nimport { Severity } from '@sentry/types';\nimport React, { FC, PropsWithChildren, useContext, useEffect, useMemo, useState } from 'react';\nimport { FormProvider, useForm } from 'react-hook-form';\nimport { useTranslation } from 'react-i18next';\nimport { useHistory } from 'react-router';\n\nimport API from '@/api/BookingAPI';\nimport { OverlayLoader } from '@/components/generic/loader/OverlayLoader';\nimport { ConfirmationStepContext } from '@/contexts/ConfirmationStepContext/ConfirmationStepContext';\nimport { CommittedBookingEvent } from '@/events/views/CommittedBookingEvent';\nimport { PlacedBookingEvent } from '@/events/views/PlacedBookingEvent';\nimport { RolledBackBookingEvent } from '@/events/views/RolledBackBookingEvent';\nimport { useConfirmationQuery } from '@/hooks/ConfirmationQuery';\nimport ReservationsDTO, { ReservationDTO } from '@/models/Api/ReservationsDTO';\nimport BasketRowDifferences from '@/models/BasketRowDifferences';\nimport { ConfirmationFormValues, FBookGetPaymentDetails, FBookValidateFunction, FBookValidationCallback, IBookValidationResult } from '@/models/Confirmation';\nimport UserProfile from '@/models/UserProfile';\nimport { Translation } from '@/translations/Translation';\nimport DataLayer, { InteractionStep, InteractionType } from '@/util/DataLayer';\nimport StepManager from '@/util/StepManager';\n\nimport { ConfirmationStepErrorModal } from './ConfirmationStepErrorModal';\n\nconst ConfirmationStepContextProvider = ConfirmationStepContext.Provider;\nexport const ConfirmationStepContextWrapper: FC<PropsWithChildren<any>> = ({ children }) => {\n const { queryPaymentMethod, queryRoomstayId: queryReservationId, queryPlanpayCheckoutId, returnFromPayment, success } = useConfirmationQuery();\n // load the engine context\n const engineContext = useContext(BookingEngineContext);\n\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [loadingStatus, setLoadingStatus] = useState('');\n\n const [apiErrorResponse, setApiErrorResponse] = useState<IBookingCreateErrorResponse>();\n const [errorModalLoading, setErrorModalLoading] = useState(false);\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 history = useHistory();\n\n const currentSession = useMemo(() => {\n return engineContext.engine.getInitialSession();\n }, []);\n\n const { hotel } = useCurrentHotel();\n const { t } = useTranslation();\n const { raise } = useEvent();\n\n useEffect(() => {\n if (hotel?.requireDeposit) {\n basketContext.getBasketQuoteDetails();\n }\n }, [hotel?.requireDeposit]);\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 AuxInputs: values.AuxInputs,\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 onSubmitSuccess = async (data: ReservationsDTO) => {\n raise(new PlacedBookingEvent(data, basketContext.currentBasketRows));\n\n if (hotel?.cardProcessor === EHotelCardProcessor.Passthrough) {\n await commitReservation?.(data);\n } else {\n if (data.payment?.external?.redirectUrl) {\n redirectOut(data.payment?.external?.redirectUrl);\n }\n }\n };\n\n const onSubmit =\n (getPaymentDetails: FBookGetPaymentDetails, comments?: string, preValidate?: FBookValidateFunction, onPostValidationError?: FBookValidationCallback) =>\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\n const validateResult = !preValidate || (await preValidate());\n if (!validateResult) {\n setIsLoading(false);\n return;\n }\n\n const payment = await getPaymentDetails();\n const userProfiles = toUserProfiles(formValues);\n\n try {\n data = await API.Reservation.bookNow(\n basketRows,\n userProfiles,\n payment,\n basketAddonRows,\n comments || '',\n hotel?.hotelID as string,\n engineContext.sessionProvider.getCurrentSessionID().toString()\n );\n await basketContext.booked(data, {\n userProfiles,\n payment,\n comments: comments || '',\n });\n\n const validationResult = await validateReservation(data);\n if (validationResult) {\n setIsLoading(false);\n onPostValidationError?.(validationResult);\n } else {\n await onSubmitSuccess(data);\n }\n } catch (error: any) {\n setApiErrorResponse(error as IBookingCreateErrorResponse);\n } finally {\n setIsLoading(false);\n }\n };\n\n const isBackFromPlanpay = !!queryPlanpayCheckoutId && !!queryReservationId && !!queryPaymentMethod;\n const isBackFromExternalPayment = !!returnFromPayment && !!success && !!queryReservationId;\n\n const parseReservationIdsFromData = (data: ReservationsDTO) => {\n return data?.reservations?.map((reservation) => reservation.reservationNumber);\n };\n\n const commitReservation = async (resData: ReservationsDTO, statusUpdate?: string) => {\n try {\n if (statusUpdate) {\n setLoadingStatus(statusUpdate);\n }\n\n setIsLoading(true);\n\n if (resData) {\n const reservationIds = parseReservationIdsFromData(resData);\n if (reservationIds.length) {\n try {\n const response = await API.Reservation.commit(reservationIds, resData.itineraryNumber, hotel?.hotelID as string, queryPlanpayCheckoutId || undefined);\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 } catch (error: any) {\n setApiErrorResponse(error);\n }\n } else {\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 console.error(ex);\n Sentry.captureException(ex);\n }\n\n setIsLoading(false);\n };\n\n const rollbackReservation = async () => {\n if (!basketContext.reservationData) return;\n\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 book = async (getPaymentDetails: FBookGetPaymentDetails, comments?: string, preValidate?: FBookValidateFunction, onPostValidationError?: FBookValidationCallback) => {\n await methods.handleSubmit(onSubmit(getPaymentDetails, comments, preValidate, onPostValidationError))();\n };\n\n const redirectOut = (targetUrl: string, stateUpdate?: string) => {\n setIsLoading(true);\n if (stateUpdate) {\n setLoadingStatus(stateUpdate);\n }\n\n window.location.href = targetUrl;\n };\n\n const onRetryBooking = async () => {\n setErrorModalLoading(true);\n\n const resRequest = currentSession?.reservationRequest;\n const roomstayId = currentSession?.reservation?.roomstayId;\n\n if (!resRequest || !roomstayId) {\n return null; // TODO: Handle me please\n }\n\n try {\n const data = await API.Reservation.bookNow(\n basketRows,\n resRequest.userProfiles,\n resRequest.payment,\n basketAddonRows,\n '',\n hotel?.hotelID as string,\n engineContext.sessionProvider.getCurrentSessionID().toString(),\n undefined,\n true,\n roomstayId\n );\n await basketContext.booked(data);\n const validationResult = await validateReservation(data);\n\n if (validationResult) {\n setIsLoading(false);\n } else {\n await onSubmitSuccess(data);\n }\n } catch (error: any) {\n setApiErrorResponse(error as IBookingCreateErrorResponse);\n } finally {\n setIsLoading(false);\n setErrorModalLoading(false);\n }\n };\n\n const onErrorModalClose = async () => {\n setErrorModalLoading(true);\n await rollbackReservation();\n const params = new URLSearchParams(window.location.search);\n window.history.replaceState({}, '', `${window.location.pathname}?${params}`);\n\n window.location.reload();\n };\n\n return (\n <FormProvider {...methods}>\n <ConfirmationStepContextProvider\n value={{\n book,\n commitReservation,\n rollbackReservation,\n redirectOut,\n setLoadingStatus,\n\n isLoading,\n isBackFromPlanpay,\n isBackFromExternalPayment,\n }}\n >\n {isLoading && <OverlayLoader isFullscreen label={loadingStatus} />}\n <ConfirmationStepErrorModal onRetry={onRetryBooking} onClose={onErrorModalClose} errorData={apiErrorResponse} isLoading={errorModalLoading} />\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,iDAAuF;AACvF,2CAA4D;AAC5D,yCAAyG;AACzG,wDAA0C;AAC1C,yCAAyC;AACzC,+CAA+F;AAC/F,qDAAwD;AACxD,iDAA+C;AAC/C,+CAA0C;AAE1C,kEAAmC;AACnC,6EAA0E;AAC1E,wGAAqG;AACrG,gFAA6E;AAC7E,0EAAuE;AACvE,kFAA+E;AAC/E,iEAAiE;AAKjE,4DAAyD;AACzD,8DAA+E;AAE/E,6EAA0E;AAE1E,MAAM,+BAA+B,GAAG,iDAAuB,CAAC,Q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ACJ,iBAAiB;gBACjB,mBAAmB;gBACnB,WAAW;gBACX,gBAAgB;gBAEhB,SAAS;gBACT,iBAAiB;gBACjB,yBAAyB;aAC5B;YAEA,SAAS,IAAI,8BAAC,6BAAa,IAAC,YAAY,QAAC,KAAK,EAAE,aAAa,GAAI;YAClE,8BAAC,uDAA0B,IAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,GAAI;YAE7I,QAAQ,CACqB,CACvB,CAClB,CAAC;AACN,CAAC,CAAC;AA/RW,QAAA,8BAA8B,kCA+RzC","sourcesContent":["import { BasketContext, BookingEngineContext, ErrorHandler } from '@frontend/contexts';\nimport { useCurrentHotel, useEvent } from '@frontend/hooks';\nimport { EBookingPaymentMethod, EHotelCardProcessor, IBookingCreateErrorResponse } from '@roomstay/core';\nimport * as Sentry from '@sentry/browser';\nimport { Severity } from '@sentry/types';\nimport React, { FC, PropsWithChildren, useContext, useEffect, useMemo, useState } from 'react';\nimport { FormProvider, useForm } from 'react-hook-form';\nimport { useTranslation } from 'react-i18next';\nimport { useHistory } from 'react-router';\n\nimport API from '@/api/BookingAPI';\nimport { OverlayLoader } from '@/components/generic/loader/OverlayLoader';\nimport { ConfirmationStepContext } from '@/contexts/ConfirmationStepContext/ConfirmationStepContext';\nimport { CommittedBookingEvent } from '@/events/views/CommittedBookingEvent';\nimport { PlacedBookingEvent } from '@/events/views/PlacedBookingEvent';\nimport { RolledBackBookingEvent } from '@/events/views/RolledBackBookingEvent';\nimport { useConfirmationQuery } from '@/hooks/ConfirmationQuery';\nimport ReservationsDTO, { ReservationDTO } from '@/models/Api/ReservationsDTO';\nimport BasketRowDifferences from '@/models/BasketRowDifferences';\nimport { ConfirmationFormValues, FBookGetPaymentDetails, FBookValidateFunction, FBookValidationCallback, IBookValidationResult } from '@/models/Confirmation';\nimport UserProfile from '@/models/UserProfile';\nimport { Translation } from '@/translations/Translation';\nimport DataLayer, { InteractionStep, InteractionType } from '@/util/DataLayer';\n\nimport { ConfirmationStepErrorModal } from './ConfirmationStepErrorModal';\n\nconst ConfirmationStepContextProvider = ConfirmationStepContext.Provider;\nexport const ConfirmationStepContextWrapper: FC<PropsWithChildren<any>> = ({ children }) => {\n const { queryPaymentMethod, queryRoomstayId: queryReservationId, queryPlanpayCheckoutId, returnFromPayment, success } = useConfirmationQuery();\n // load the engine context\n const engineContext = useContext(BookingEngineContext);\n\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [loadingStatus, setLoadingStatus] = useState('');\n\n const [apiErrorResponse, setApiErrorResponse] = useState<IBookingCreateErrorResponse>();\n const [errorModalLoading, setErrorModalLoading] = useState(false);\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 history = useHistory();\n\n const currentSession = useMemo(() => {\n return engineContext.engine.getInitialSession();\n }, []);\n\n const { hotel } = useCurrentHotel();\n const { t } = useTranslation();\n const { raise } = useEvent();\n\n useEffect(() => {\n if (hotel?.requireDeposit) {\n basketContext.getBasketQuoteDetails();\n }\n }, [hotel?.requireDeposit]);\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 AuxInputs: values.AuxInputs,\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 onSubmitSuccess = async (data: ReservationsDTO, paymentMethod: EBookingPaymentMethod) => {\n raise(new PlacedBookingEvent(data, basketContext.currentBasketRows));\n\n // If this is a planpay booking, we don't need to do anything else.\n if (paymentMethod === EBookingPaymentMethod.Planpay) {\n return;\n }\n\n if (hotel?.cardProcessor === EHotelCardProcessor.Passthrough) {\n await commitReservation?.(data);\n } else {\n if (data.payment?.external?.redirectUrl) {\n redirectOut(data.payment?.external?.redirectUrl);\n }\n }\n };\n\n const onSubmit =\n (getPaymentDetails: FBookGetPaymentDetails, comments?: string, preValidate?: FBookValidateFunction, onPostValidationError?: FBookValidationCallback) =>\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\n const validateResult = !preValidate || (await preValidate());\n if (!validateResult) {\n setIsLoading(false);\n return;\n }\n\n const payment = await getPaymentDetails();\n const userProfiles = toUserProfiles(formValues);\n\n try {\n data = await API.Reservation.bookNow(\n basketRows,\n userProfiles,\n payment,\n basketAddonRows,\n comments || '',\n hotel?.hotelID as string,\n engineContext.sessionProvider.getCurrentSessionID().toString()\n );\n await basketContext.booked(data, {\n userProfiles,\n payment,\n comments: comments || '',\n });\n\n const validationResult = await validateReservation(data);\n if (validationResult) {\n setIsLoading(false);\n onPostValidationError?.(validationResult);\n } else {\n await onSubmitSuccess(data, payment.Method);\n }\n } catch (error: any) {\n setApiErrorResponse(error as IBookingCreateErrorResponse);\n } finally {\n setIsLoading(false);\n }\n };\n\n const isBackFromPlanpay = !!queryPlanpayCheckoutId && !!queryReservationId && !!queryPaymentMethod;\n const isBackFromExternalPayment = !!returnFromPayment && !!success && !!queryReservationId;\n\n const parseReservationIdsFromData = (data: ReservationsDTO) => {\n return data?.reservations?.map((reservation) => reservation.reservationNumber);\n };\n\n const commitReservation = async (resData: ReservationsDTO, statusUpdate?: string) => {\n try {\n if (statusUpdate) {\n setLoadingStatus(statusUpdate);\n }\n\n setIsLoading(true);\n\n if (resData) {\n const reservationIds = parseReservationIdsFromData(resData);\n if (reservationIds.length) {\n try {\n const response = await API.Reservation.commit(reservationIds, resData.itineraryNumber, hotel?.hotelID as string, queryPlanpayCheckoutId || undefined);\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 } catch (error: any) {\n setApiErrorResponse(error);\n }\n } else {\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 console.error(ex);\n Sentry.captureException(ex);\n }\n\n setIsLoading(false);\n };\n\n const rollbackReservation = async () => {\n if (!basketContext.reservationData) return;\n\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 book = async (getPaymentDetails: FBookGetPaymentDetails, comments?: string, preValidate?: FBookValidateFunction, onPostValidationError?: FBookValidationCallback) => {\n await methods.handleSubmit(onSubmit(getPaymentDetails, comments, preValidate, onPostValidationError))();\n };\n\n const redirectOut = (targetUrl: string, stateUpdate?: string) => {\n setIsLoading(true);\n if (stateUpdate) {\n setLoadingStatus(stateUpdate);\n }\n\n window.location.href = targetUrl;\n };\n\n const onRetryBooking = async () => {\n setErrorModalLoading(true);\n\n const resRequest = currentSession?.reservationRequest;\n const roomstayId = currentSession?.reservation?.roomstayId;\n\n if (!resRequest || !roomstayId) {\n return null; // TODO: Handle me please\n }\n\n try {\n const data = await API.Reservation.bookNow(\n basketRows,\n resRequest.userProfiles,\n resRequest.payment,\n basketAddonRows,\n '',\n hotel?.hotelID as string,\n engineContext.sessionProvider.getCurrentSessionID().toString(),\n undefined,\n true,\n roomstayId\n );\n await basketContext.booked(data);\n const validationResult = await validateReservation(data);\n\n if (validationResult) {\n setIsLoading(false);\n } else {\n await onSubmitSuccess(data, resRequest.payment?.Method);\n }\n } catch (error: any) {\n setApiErrorResponse(error as IBookingCreateErrorResponse);\n } finally {\n setIsLoading(false);\n setErrorModalLoading(false);\n }\n };\n\n const onErrorModalClose = async () => {\n setErrorModalLoading(true);\n await rollbackReservation();\n const params = new URLSearchParams(window.location.search);\n window.history.replaceState({}, '', `${window.location.pathname}?${params}`);\n\n window.location.reload();\n };\n\n return (\n <FormProvider {...methods}>\n <ConfirmationStepContextProvider\n value={{\n book,\n commitReservation,\n rollbackReservation,\n redirectOut,\n setLoadingStatus,\n\n isLoading,\n isBackFromPlanpay,\n isBackFromExternalPayment,\n }}\n >\n {isLoading && <OverlayLoader isFullscreen label={loadingStatus} />}\n <ConfirmationStepErrorModal onRetry={onRetryBooking} onClose={onErrorModalClose} errorData={apiErrorResponse} isLoading={errorModalLoading} />\n\n {children}\n </ConfirmationStepContextProvider>\n </FormProvider>\n );\n};\n"]}
|