@roomstay/frontend 1.5.8 → 1.6.0-1
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/661.bundle.js +1 -1
- package/dist/main.bundle.js +1 -1
- package/dist/src/components/steps/room/MemberSignInModal/MemberSignInModal.js +13 -10
- package/dist/src/components/steps/room/MemberSignInModal/MemberSignInModal.js.map +1 -1
- package/dist/src/components/steps/room/RoomList.js +1 -1
- package/dist/src/components/steps/room/RoomList.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/MembersOnlyRow.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateListPromotion/RoomRateListPromotion.d.ts +7 -0
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateListPromotion/RoomRateListPromotion.js +30 -0
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateListPromotion/RoomRateListPromotion.js.map +1 -0
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRates.js +5 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRates.js.map +1 -1
- package/dist/src/contexts/BasketContext/BasketContextType.d.ts +2 -0
- package/dist/src/contexts/BasketContext/BasketContextType.js.map +1 -1
- package/dist/src/contexts/BasketContext/BasketContextWrapper.js +12 -8
- package/dist/src/contexts/BasketContext/BasketContextWrapper.js.map +1 -1
- package/dist/src/contexts/CompanyContext/CompanyContextType.type.d.ts +3 -1
- package/dist/src/contexts/CompanyContext/CompanyContextType.type.js.map +1 -1
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js +9 -1
- package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js.map +1 -1
- package/dist/src/events/RoomstayEventManager.d.ts +1 -1
- package/dist/src/events/RoomstayEventManager.js +23 -4
- package/dist/src/events/RoomstayEventManager.js.map +1 -1
- package/dist/src/events/actions/MemberOnlyFence/MemberOnlyFenceSignUp.d.ts +7 -0
- package/dist/src/events/actions/MemberOnlyFence/MemberOnlyFenceSignUp.js +15 -0
- package/dist/src/events/actions/MemberOnlyFence/MemberOnlyFenceSignUp.js.map +1 -0
- package/dist/src/events/actions/Promotion/PromotionAddedEvent.d.ts +7 -0
- package/dist/src/events/actions/Promotion/PromotionAddedEvent.js +15 -0
- package/dist/src/events/actions/Promotion/PromotionAddedEvent.js.map +1 -0
- package/dist/src/events/actions/Promotion/PromotionClickedEvent.d.ts +7 -0
- package/dist/src/events/actions/Promotion/PromotionClickedEvent.js +15 -0
- package/dist/src/events/actions/Promotion/PromotionClickedEvent.js.map +1 -0
- package/dist/src/events/actions/Promotion/PromotionRemovedEvent.d.ts +7 -0
- package/dist/src/events/actions/Promotion/PromotionRemovedEvent.js +15 -0
- package/dist/src/events/actions/Promotion/PromotionRemovedEvent.js.map +1 -0
- package/dist/src/events/index.d.ts +1 -0
- package/dist/src/events/index.js +1 -0
- package/dist/src/events/index.js.map +1 -1
- package/dist/src/hooks/EventHook.d.ts +1 -1
- package/dist/src/hooks/EventHook.js +2 -2
- package/dist/src/hooks/EventHook.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/Promotion/IPromotion.type.d.ts +26 -0
- package/dist/src/models/Promotion/IPromotion.type.js +3 -0
- package/dist/src/models/Promotion/IPromotion.type.js.map +1 -0
- package/dist/src/providers/PromotionProvider.d.ts +14 -0
- package/dist/src/providers/PromotionProvider.js +210 -0
- package/dist/src/providers/PromotionProvider.js.map +1 -0
- package/dist/test.bundle.js +1 -1
- package/dist/tests/offline/entry/RSCompany.js +39 -0
- package/dist/tests/offline/entry/RSCompany.js.map +1 -1
- package/dist/vendors.bundle.js +1 -1
- package/package.json +1 -1
|
@@ -81,7 +81,7 @@ const MemberOnlyModalDefaultInputs = {
|
|
|
81
81
|
],
|
|
82
82
|
};
|
|
83
83
|
function MemberSignInModal(props) {
|
|
84
|
-
var _a, _b, _c;
|
|
84
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85
85
|
const { t } = react_i18next_1.useTranslation();
|
|
86
86
|
const context = react_1.useContext(contexts_1.BookingEngineContext);
|
|
87
87
|
const basketContext = react_1.useContext(contexts_1.BasketContext);
|
|
@@ -162,9 +162,9 @@ function MemberSignInModal(props) {
|
|
|
162
162
|
yield signUpMember();
|
|
163
163
|
});
|
|
164
164
|
const signUpMember = () => __awaiter(this, void 0, void 0, function* () {
|
|
165
|
-
var
|
|
165
|
+
var _k, _l;
|
|
166
166
|
setIsLoading(true);
|
|
167
|
-
const
|
|
167
|
+
const _m = methods.getValues(), { FirstName, LastName, Email } = _m, extra = __rest(_m, ["FirstName", "LastName", "Email"]);
|
|
168
168
|
if (!FirstName || !LastName || !Email) {
|
|
169
169
|
setIsLoading(false);
|
|
170
170
|
ErrorContext_1.ErrorHandler.add({
|
|
@@ -183,8 +183,8 @@ function MemberSignInModal(props) {
|
|
|
183
183
|
}
|
|
184
184
|
else {
|
|
185
185
|
ccx.signUserIn(Email);
|
|
186
|
-
if (hotel === null || hotel === void 0 ? void 0 : hotel.memberOnlyPromoCode) {
|
|
187
|
-
(
|
|
186
|
+
if ((hotel === null || hotel === void 0 ? void 0 : hotel.memberOnlyPromoCode) && !((_k = ccx.memberOnlyModalPromotion) === null || _k === void 0 ? void 0 : _k.memberOnlyDisableDefaultPromo)) {
|
|
187
|
+
(_l = basketContext.currentBasketRows) === null || _l === void 0 ? void 0 : _l.forEach((row) => {
|
|
188
188
|
row.setPromoCode(hotel === null || hotel === void 0 ? void 0 : hotel.memberOnlyPromoCode);
|
|
189
189
|
basketContext.updateBasketRow(row);
|
|
190
190
|
});
|
|
@@ -213,10 +213,15 @@ function MemberSignInModal(props) {
|
|
|
213
213
|
setShowErrors(true);
|
|
214
214
|
return false;
|
|
215
215
|
});
|
|
216
|
+
const modalTitle = (_e = (_d = ccx === null || ccx === void 0 ? void 0 : ccx.memberOnlyModalPromotion) === null || _d === void 0 ? void 0 : _d.memberOnlyModalTitle) !== null && _e !== void 0 ? _e : t(Translation_1.Translation.MemberOnlyPopup.Headline, {
|
|
217
|
+
companyShort: ccx === null || ccx === void 0 ? void 0 : ccx.companyShort,
|
|
218
|
+
});
|
|
219
|
+
const modalButtonText = (_g = (_f = ccx === null || ccx === void 0 ? void 0 : ccx.memberOnlyModalPromotion) === null || _f === void 0 ? void 0 : _f.memberOnlyModalButtonText) !== null && _g !== void 0 ? _g : t(Translation_1.Translation.MemberOnlyPopup.SubmitButtonText);
|
|
220
|
+
const modalLeadImage = (_j = (_h = ccx === null || ccx === void 0 ? void 0 : ccx.memberOnlyModalPromotion) === null || _h === void 0 ? void 0 : _h.memberOnlyModalImage) !== null && _j !== void 0 ? _j : hotel === null || hotel === void 0 ? void 0 : hotel.heroImage;
|
|
216
221
|
return (React.createElement(SimpleModal_1.default, { open: props.isOpen, onClose: loadingOnClose, size: SimpleModal_1.SimpleModalSize.Normal, alignCenter: true },
|
|
217
222
|
React.createElement("div", { className: "row" },
|
|
218
223
|
React.createElement("div", { className: "col-md-6 u-mh-none", style: {
|
|
219
|
-
background: 'url("' +
|
|
224
|
+
background: 'url("' + modalLeadImage + '")',
|
|
220
225
|
backgroundRepeat: 'no-repeat',
|
|
221
226
|
backgroundPosition: 'center',
|
|
222
227
|
backgroundSize: 'cover',
|
|
@@ -228,9 +233,7 @@ function MemberSignInModal(props) {
|
|
|
228
233
|
React.createElement("div", { className: "u-marg-bottom-half" },
|
|
229
234
|
React.createElement(Headline_1.default, { bold: true, color: Color_1.Color.Success },
|
|
230
235
|
React.createElement("div", { style: { color: Color_1.Color.Success }, dangerouslySetInnerHTML: {
|
|
231
|
-
__html:
|
|
232
|
-
companyShort: ccx === null || ccx === void 0 ? void 0 : ccx.companyShort,
|
|
233
|
-
}),
|
|
236
|
+
__html: modalTitle,
|
|
234
237
|
} }))),
|
|
235
238
|
React.createElement("div", { className: "u-marg-bottom" },
|
|
236
239
|
React.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.DarkGrey }, t(Translation_1.Translation.MemberOnlyPopup.Subtitle))),
|
|
@@ -250,7 +253,7 @@ function MemberSignInModal(props) {
|
|
|
250
253
|
captchaScriptLoaded && (React.createElement(React.Fragment, null,
|
|
251
254
|
captchaError && (React.createElement(Text_1.default, { type: Text_1.TextType.Label, color: Color_1.Color.Alert }, captchaError)),
|
|
252
255
|
React.createElement("div", { ref: captchaRef, className: "u-marg-bottom" }))),
|
|
253
|
-
React.createElement(BEButton_1.default, { size: "normal", filled: true, success: true, isLoading: isLoading, stopIconAnimation: true, icon: context.screenSize > ScreenSize_1.default.Mobile ? Icon_1.IconType.ArrowRight : null, onClick: buttonOnClickHandler },
|
|
256
|
+
React.createElement(BEButton_1.default, { size: "normal", filled: true, success: true, isLoading: isLoading, stopIconAnimation: true, icon: context.screenSize > ScreenSize_1.default.Mobile ? Icon_1.IconType.ArrowRight : null, onClick: buttonOnClickHandler }, modalButtonText))),
|
|
254
257
|
React.createElement(Text_1.default, { type: Text_1.TextType.Label, color: Color_1.Color.DarkGrey },
|
|
255
258
|
React.createElement("span", { dangerouslySetInnerHTML: { __html: t(Translation_1.Translation.MemberOnlyPopup.AgreeToReceiveDeals, { companyShort: ccx === null || ccx === void 0 ? void 0 : ccx.companyShort }) } })),
|
|
256
259
|
' ',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemberSignInModal.js","sourceRoot":"/","sources":["src/components/steps/room/MemberSignInModal/MemberSignInModal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAkF;AAClF,gDAAuD;AACvD,kDAA+C;AAC/C,wDAAiD;AACjD,gDAAuD;AACvD,wDAAiD;AACjD,+BAA+B;AAC/B,iCAAgE;AAChE,sDAA+C;AAC/C,qDAAwD;AACxD,2DAA6C;AAC7C,oEAAiE;AACjE,iDAAyE;AACzE,4DAAqD;AACrD,0CAA0C;AAC1C,sEAAmE;AACnE,iDAA+C;AAE/C,2CAAkD;AAElD,iDAAoD;AACpD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I,EACvB,IAAI,EAAE,OAAO,CAAC,UAAU,GAAG,oBAAU,CAAC,MAAM,CAAC,CAAC,CAAC,eAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EACzE,OAAO,EAAE,oBAAoB,IAE5B,CAAC,CAAC,yBAAW,CAAC,eAAe,CAAC,gBAAgB,CAAC,CACzC,CACT,CACK;oBACf,oBAAC,cAAI,IAAC,IAAI,EAAE,eAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,aAAK,CAAC,QAAQ;wBAC7C,8BAAM,uBAAuB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,yBAAW,CAAC,eAAe,CAAC,mBAAmB,EAAE,EAAE,YAAY,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,YAAY,EAAE,CAAC,EAAE,GAAS,CACxI;oBAAC,GAAG;oBACX,oBAAC,cAAI,IAAC,IAAI,EAAE,eAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,aAAK,CAAC,QAAQ;wBAC7C,8BAAM,uBAAuB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,yBAAW,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,GAAS,CAClG,CACL,CACJ,CACJ,CACI,CACjB,CAAC;AACN,CAAC;AAzPD,oCAyPC","sourcesContent":["import SimpleModal, { SimpleModalSize } from '../../../generic/modal/SimpleModal';\nimport Icon, { IconType } from '../../../generic/Icon';\nimport { Color } from '../../../../util/Color';\nimport Headline from '../../../generic/Headline';\nimport Text, { TextType } from '../../../generic/Text';\nimport BEButton from '../../../generic/BEButton';\nimport * as React from 'react';\nimport { useContext, useState, useEffect, useRef } from 'react';\nimport TextBox from '../../../generic/TextBox';\nimport { FormProvider, useForm } from 'react-hook-form';\nimport API from '../../../../api/BookingAPI';\nimport { ErrorHandler } from '../../../../contexts/ErrorContext';\nimport { BasketContext, BookingEngineContext } from '@frontend/contexts';\nimport ScreenSize from '../../../../util/ScreenSize';\nimport * as Sentry from '@sentry/browser';\nimport { Translation } from '../../../../translations/Translation';\nimport { useTranslation } from 'react-i18next';\n\nimport { useCurrentHotel } from '@frontend/hooks';\n\nimport { CompanyContext } from '@frontend/contexts';\nimport InputGroup from '../../../generic/InputGroup/InputGroup';\nimport { MemberOnlyModalInputs } from './MemberSignInModal.types';\nimport RoomstayThemeEngine from 'providers/RoomstayThemeEngine';\nimport { EMAIL_REGEX } from 'util/Validation';\n\ninterface MemberSignInModalProps {\n onClose?: () => void;\n isOpen?: boolean;\n}\n\nconst MemberOnlyModalDefaultInputs: MemberOnlyModalInputs = {\n Lines: [\n {\n Dimension: '2/2',\n Inputs: [\n {\n name: 'FirstName',\n type: 'TextBox',\n placeholder: 'First Name',\n isRequired: true,\n },\n {\n name: 'LastName',\n type: 'TextBox',\n placeholder: 'Last Name',\n isRequired: true,\n },\n ],\n },\n {\n Dimension: '1',\n Inputs: [\n {\n name: 'Email',\n type: 'TextBox',\n placeholder: 'Email Address',\n isRequired: true,\n validate: (input: string) => {\n if (!input.match(EMAIL_REGEX)) {\n return 'Invalid Email Address';\n }\n return true;\n },\n },\n ],\n },\n ],\n};\n\nexport default function MemberSignInModal(props: MemberSignInModalProps) {\n const { t } = useTranslation();\n\n const context = useContext(BookingEngineContext);\n const basketContext = useContext(BasketContext);\n const ccx = useContext(CompanyContext);\n\n const { hotel } = useCurrentHotel();\n\n const [isLoading, setIsLoading] = useState(false);\n const [showErrors, setShowErrors] = useState(false);\n\n const [captchaScriptLoaded, setCaptchaScriptLoaded] = useState(false);\n const [reCaptchaSecret, setReCaptchaSecret] = useState<string>();\n const [captchaError, setCaptchaError] = useState<string>();\n\n const captchaRef = useRef(null);\n\n const shouldLoadCaptcha = !!hotel?.googleReCaptcha?.loadForMembers && !!hotel?.googleReCaptcha?.siteKey;\n\n useEffect(() => {\n let cancelled = false;\n\n if (shouldLoadCaptcha) {\n RoomstayThemeEngine.loadScript('https://www.google.com/recaptcha/api.js', 'Google ReCaptcha').then(() => {\n /** @ts-ignore */\n window.grecaptcha.ready(() => {\n if (!cancelled) {\n setCaptchaScriptLoaded(true);\n }\n });\n });\n }\n\n return () => {\n cancelled = true;\n };\n }, [hotel]);\n\n useEffect(() => {\n if (shouldLoadCaptcha && captchaScriptLoaded && !captchaRef?.current && props.isOpen) {\n try {\n setTimeout(() => {\n const captchaCallback = (secret: string) => {\n setReCaptchaSecret(secret);\n setCaptchaError(undefined);\n };\n\n /** @ts-ignore */\n window.grecaptcha.render(captchaRef.current, {\n sitekey: hotel.googleReCaptcha.siteKey,\n callback: captchaCallback,\n });\n }, 5);\n } catch (ex) {\n Sentry.captureException(ex);\n }\n }\n }, [props.isOpen, captchaScriptLoaded, captchaRef, captchaRef?.current]);\n\n useEffect(() => {\n if (!props.isOpen) {\n setReCaptchaSecret(null);\n setCaptchaError(null);\n }\n }, [props.isOpen]);\n\n const getValidationClass = (name: string) => {\n if (errors && (formState.touchedFields[name] || showErrors)) {\n if (errors[name]) {\n return 'error';\n } else {\n return 'success';\n }\n } else {\n return null;\n }\n };\n\n const methods = useForm({\n mode: 'onChange',\n });\n\n const { formState, register } = methods;\n const errors = methods.formState.errors;\n\n const onSubmit = async () => {\n if (shouldLoadCaptcha && (!reCaptchaSecret || reCaptchaSecret === '')) {\n setCaptchaError(t(Translation.MemberOnlyPopup.Errors.ReCaptcha.PleaseTick));\n return;\n }\n\n await signUpMember();\n };\n\n const signUpMember = async () => {\n setIsLoading(true);\n const { FirstName, LastName, Email, ...extra } = methods.getValues();\n\n if (!FirstName || !LastName || !Email) {\n setIsLoading(false);\n ErrorHandler.add({\n title: 'Required fields in the Member Signup are missing.',\n message: 'First Name, Last Name, and Email Mandatory Fields, make sure that these fields are present to avoid loss of data.',\n });\n\n return;\n }\n\n try {\n const extraFields = Object.keys(extra).map((extraFieldKey: string) => {\n return { name: extraFieldKey, value: extra[extraFieldKey] };\n });\n\n const response = await API.Member.addMember(FirstName, LastName, Email, extraFields, hotel.hotelID, reCaptchaSecret);\n\n if (response.error) {\n setCaptchaError(t(Translation.MemberOnlyPopup.Errors.ReCaptcha.ValidationError));\n } else {\n ccx.signUserIn(Email);\n\n if (hotel?.memberOnlyPromoCode) {\n basketContext.currentBasketRows?.forEach((row) => {\n row.setPromoCode(hotel?.memberOnlyPromoCode);\n basketContext.updateBasketRow(row);\n });\n }\n }\n } catch (e) {\n ErrorHandler.add({\n title: t(Translation.MemberOnlyPopup.Errors.SignupFailed.Title),\n message: t(Translation.MemberOnlyPopup.Errors.SignupFailed.Message),\n });\n } finally {\n setIsLoading(false);\n }\n };\n\n const modalInputs: MemberOnlyModalInputs = hotel?.memberOnlySignupInputs ?? MemberOnlyModalDefaultInputs;\n\n const loadingOnClose = () => {\n setIsLoading(false);\n if (props.onClose) {\n props.onClose();\n }\n };\n const buttonOnClickHandler = async () => {\n await methods.handleSubmit(onSubmit)();\n setShowErrors(true);\n\n return false;\n };\n\n return (\n <SimpleModal open={props.isOpen} onClose={loadingOnClose} size={SimpleModalSize.Normal} alignCenter={true}>\n <div className=\"row\">\n <div\n className=\"col-md-6 u-mh-none\"\n style={{\n background: 'url(\"' + hotel?.heroImage + '\")',\n backgroundRepeat: 'no-repeat',\n backgroundPosition: 'center',\n backgroundSize: 'cover',\n }}\n />\n <div className=\"col-md-6\">\n <div className=\"u-pad u-pad-heavy@m-\">\n <div className=\"u-marg-bottom-half\">\n <Icon icon={IconType.Money} size=\"24px\" color={Color.Success} backgroundColor={Color.SuccessTint} />\n </div>\n <div className=\"u-marg-bottom-half\">\n <Headline bold={true} color={Color.Success}>\n <div\n style={{ color: Color.Success }}\n dangerouslySetInnerHTML={{\n __html: t(Translation.MemberOnlyPopup.Headline, {\n companyShort: ccx?.companyShort,\n }),\n }}\n ></div>\n </Headline>\n </div>\n <div className=\"u-marg-bottom\">\n <Text type={TextType.Small} color={Color.DarkGrey}>\n {t(Translation.MemberOnlyPopup.Subtitle)}\n </Text>\n </div>\n <FormProvider {...methods}>\n <div>\n {modalInputs.Lines.map((inputLine, lineIndex) => {\n return (\n <InputGroup dimensions={inputLine.Dimension} key={lineIndex}>\n {inputLine.Inputs.map((input, inputIndex) => {\n switch (input.type) {\n case 'TextBox':\n return (\n <TextBox\n key={inputIndex}\n wide={true}\n placeholder={input.placeholder}\n required={input.isRequired}\n validationStatus={getValidationClass(input.name)}\n {...register(input.name, {\n required: input.isRequired,\n validate: input.validate,\n })}\n />\n );\n }\n })}\n </InputGroup>\n );\n })}\n </div>\n <div className=\"u-marg-top--light\" style={{ marginBottom: '45px' }}>\n {captchaScriptLoaded && (\n <>\n {captchaError && (\n <Text type={TextType.Label} color={Color.Alert}>\n {captchaError}\n </Text>\n )}\n <div ref={captchaRef} className=\"u-marg-bottom\"></div>\n </>\n )}\n <BEButton\n size=\"normal\"\n filled={true}\n success={true}\n isLoading={isLoading}\n stopIconAnimation={true}\n icon={context.screenSize > ScreenSize.Mobile ? IconType.ArrowRight : null}\n onClick={buttonOnClickHandler}\n >\n {t(Translation.MemberOnlyPopup.SubmitButtonText)}\n </BEButton>\n </div>\n </FormProvider>\n <Text type={TextType.Label} color={Color.DarkGrey}>\n <span dangerouslySetInnerHTML={{ __html: t(Translation.MemberOnlyPopup.AgreeToReceiveDeals, { companyShort: ccx?.companyShort }) }}></span>\n </Text>{' '}\n <Text type={TextType.Label} color={Color.DarkGrey}>\n <span dangerouslySetInnerHTML={{ __html: t(Translation.MemberOnlyPopup.UnsubscribeAnytime) }}></span>\n </Text>\n </div>\n </div>\n </div>\n </SimpleModal>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MemberSignInModal.js","sourceRoot":"/","sources":["src/components/steps/room/MemberSignInModal/MemberSignInModal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAkF;AAClF,gDAAuD;AACvD,kDAA+C;AAC/C,wDAAiD;AACjD,gDAAuD;AACvD,wDAAiD;AACjD,+BAA+B;AAC/B,iCAAgE;AAChE,sDAA+C;AAC/C,qDAAwD;AACxD,2DAA6C;AAC7C,oEAAiE;AACjE,i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CAAC;AACN,CAAC;AAjQD,oCAiQC","sourcesContent":["import SimpleModal, { SimpleModalSize } from '../../../generic/modal/SimpleModal';\nimport Icon, { IconType } from '../../../generic/Icon';\nimport { Color } from '../../../../util/Color';\nimport Headline from '../../../generic/Headline';\nimport Text, { TextType } from '../../../generic/Text';\nimport BEButton from '../../../generic/BEButton';\nimport * as React from 'react';\nimport { useContext, useState, useEffect, useRef } from 'react';\nimport TextBox from '../../../generic/TextBox';\nimport { FormProvider, useForm } from 'react-hook-form';\nimport API from '../../../../api/BookingAPI';\nimport { ErrorHandler } from '../../../../contexts/ErrorContext';\nimport { BasketContext, BookingEngineContext } from '@frontend/contexts';\nimport ScreenSize from '../../../../util/ScreenSize';\nimport * as Sentry from '@sentry/browser';\nimport { Translation } from '../../../../translations/Translation';\nimport { useTranslation } from 'react-i18next';\n\nimport { useCurrentHotel } from '@frontend/hooks';\n\nimport { CompanyContext } from '@frontend/contexts';\nimport InputGroup from '../../../generic/InputGroup/InputGroup';\nimport { MemberOnlyModalInputs } from './MemberSignInModal.types';\nimport RoomstayThemeEngine from 'providers/RoomstayThemeEngine';\nimport { EMAIL_REGEX } from 'util/Validation';\n\ninterface MemberSignInModalProps {\n onClose?: () => void;\n isOpen?: boolean;\n}\n\nconst MemberOnlyModalDefaultInputs: MemberOnlyModalInputs = {\n Lines: [\n {\n Dimension: '2/2',\n Inputs: [\n {\n name: 'FirstName',\n type: 'TextBox',\n placeholder: 'First Name',\n isRequired: true,\n },\n {\n name: 'LastName',\n type: 'TextBox',\n placeholder: 'Last Name',\n isRequired: true,\n },\n ],\n },\n {\n Dimension: '1',\n Inputs: [\n {\n name: 'Email',\n type: 'TextBox',\n placeholder: 'Email Address',\n isRequired: true,\n validate: (input: string) => {\n if (!input.match(EMAIL_REGEX)) {\n return 'Invalid Email Address';\n }\n return true;\n },\n },\n ],\n },\n ],\n};\n\nexport default function MemberSignInModal(props: MemberSignInModalProps) {\n const { t } = useTranslation();\n\n const context = useContext(BookingEngineContext);\n const basketContext = useContext(BasketContext);\n const ccx = useContext(CompanyContext);\n\n const { hotel } = useCurrentHotel();\n\n const [isLoading, setIsLoading] = useState(false);\n const [showErrors, setShowErrors] = useState(false);\n\n const [captchaScriptLoaded, setCaptchaScriptLoaded] = useState(false);\n const [reCaptchaSecret, setReCaptchaSecret] = useState<string>();\n const [captchaError, setCaptchaError] = useState<string>();\n\n const captchaRef = useRef(null);\n\n const shouldLoadCaptcha = !!hotel?.googleReCaptcha?.loadForMembers && !!hotel?.googleReCaptcha?.siteKey;\n\n useEffect(() => {\n let cancelled = false;\n\n if (shouldLoadCaptcha) {\n RoomstayThemeEngine.loadScript('https://www.google.com/recaptcha/api.js', 'Google ReCaptcha').then(() => {\n /** @ts-ignore */\n window.grecaptcha.ready(() => {\n if (!cancelled) {\n setCaptchaScriptLoaded(true);\n }\n });\n });\n }\n\n return () => {\n cancelled = true;\n };\n }, [hotel]);\n\n useEffect(() => {\n if (shouldLoadCaptcha && captchaScriptLoaded && !captchaRef?.current && props.isOpen) {\n try {\n setTimeout(() => {\n const captchaCallback = (secret: string) => {\n setReCaptchaSecret(secret);\n setCaptchaError(undefined);\n };\n\n /** @ts-ignore */\n window.grecaptcha.render(captchaRef.current, {\n sitekey: hotel.googleReCaptcha.siteKey,\n callback: captchaCallback,\n });\n }, 5);\n } catch (ex) {\n Sentry.captureException(ex);\n }\n }\n }, [props.isOpen, captchaScriptLoaded, captchaRef, captchaRef?.current]);\n\n useEffect(() => {\n if (!props.isOpen) {\n setReCaptchaSecret(null);\n setCaptchaError(null);\n }\n }, [props.isOpen]);\n\n const getValidationClass = (name: string) => {\n if (errors && (formState.touchedFields[name] || showErrors)) {\n if (errors[name]) {\n return 'error';\n } else {\n return 'success';\n }\n } else {\n return null;\n }\n };\n\n const methods = useForm({\n mode: 'onChange',\n });\n\n const { formState, register } = methods;\n const errors = methods.formState.errors;\n\n const onSubmit = async () => {\n if (shouldLoadCaptcha && (!reCaptchaSecret || reCaptchaSecret === '')) {\n setCaptchaError(t(Translation.MemberOnlyPopup.Errors.ReCaptcha.PleaseTick));\n return;\n }\n\n await signUpMember();\n };\n\n const signUpMember = async () => {\n setIsLoading(true);\n const { FirstName, LastName, Email, ...extra } = methods.getValues();\n\n if (!FirstName || !LastName || !Email) {\n setIsLoading(false);\n ErrorHandler.add({\n title: 'Required fields in the Member Signup are missing.',\n message: 'First Name, Last Name, and Email Mandatory Fields, make sure that these fields are present to avoid loss of data.',\n });\n\n return;\n }\n\n try {\n const extraFields = Object.keys(extra).map((extraFieldKey: string) => {\n return { name: extraFieldKey, value: extra[extraFieldKey] };\n });\n\n const response = await API.Member.addMember(FirstName, LastName, Email, extraFields, hotel.hotelID, reCaptchaSecret);\n\n if (response.error) {\n setCaptchaError(t(Translation.MemberOnlyPopup.Errors.ReCaptcha.ValidationError));\n } else {\n ccx.signUserIn(Email);\n\n if (hotel?.memberOnlyPromoCode && !ccx.memberOnlyModalPromotion?.memberOnlyDisableDefaultPromo) {\n basketContext.currentBasketRows?.forEach((row) => {\n row.setPromoCode(hotel?.memberOnlyPromoCode);\n basketContext.updateBasketRow(row);\n });\n }\n }\n } catch (e) {\n ErrorHandler.add({\n title: t(Translation.MemberOnlyPopup.Errors.SignupFailed.Title),\n message: t(Translation.MemberOnlyPopup.Errors.SignupFailed.Message),\n });\n } finally {\n setIsLoading(false);\n }\n };\n\n const modalInputs: MemberOnlyModalInputs = hotel?.memberOnlySignupInputs ?? MemberOnlyModalDefaultInputs;\n\n const loadingOnClose = () => {\n setIsLoading(false);\n if (props.onClose) {\n props.onClose();\n }\n };\n const buttonOnClickHandler = async () => {\n await methods.handleSubmit(onSubmit)();\n setShowErrors(true);\n\n return false;\n };\n\n const modalTitle =\n ccx?.memberOnlyModalPromotion?.memberOnlyModalTitle ??\n t(Translation.MemberOnlyPopup.Headline, {\n companyShort: ccx?.companyShort,\n });\n\n const modalButtonText = ccx?.memberOnlyModalPromotion?.memberOnlyModalButtonText ?? t(Translation.MemberOnlyPopup.SubmitButtonText);\n\n const modalLeadImage = ccx?.memberOnlyModalPromotion?.memberOnlyModalImage ?? hotel?.heroImage;\n\n return (\n <SimpleModal open={props.isOpen} onClose={loadingOnClose} size={SimpleModalSize.Normal} alignCenter={true}>\n <div className=\"row\">\n <div\n className=\"col-md-6 u-mh-none\"\n style={{\n background: 'url(\"' + modalLeadImage + '\")',\n backgroundRepeat: 'no-repeat',\n backgroundPosition: 'center',\n backgroundSize: 'cover',\n }}\n />\n <div className=\"col-md-6\">\n <div className=\"u-pad u-pad-heavy@m-\">\n <div className=\"u-marg-bottom-half\">\n <Icon icon={IconType.Money} size=\"24px\" color={Color.Success} backgroundColor={Color.SuccessTint} />\n </div>\n <div className=\"u-marg-bottom-half\">\n <Headline bold={true} color={Color.Success}>\n <div\n style={{ color: Color.Success }}\n dangerouslySetInnerHTML={{\n __html: modalTitle,\n }}\n ></div>\n </Headline>\n </div>\n <div className=\"u-marg-bottom\">\n <Text type={TextType.Small} color={Color.DarkGrey}>\n {t(Translation.MemberOnlyPopup.Subtitle)}\n </Text>\n </div>\n <FormProvider {...methods}>\n <div>\n {modalInputs.Lines.map((inputLine, lineIndex) => {\n return (\n <InputGroup dimensions={inputLine.Dimension} key={lineIndex}>\n {inputLine.Inputs.map((input, inputIndex) => {\n switch (input.type) {\n case 'TextBox':\n return (\n <TextBox\n key={inputIndex}\n wide={true}\n placeholder={input.placeholder}\n required={input.isRequired}\n validationStatus={getValidationClass(input.name)}\n {...register(input.name, {\n required: input.isRequired,\n validate: input.validate,\n })}\n />\n );\n }\n })}\n </InputGroup>\n );\n })}\n </div>\n <div className=\"u-marg-top--light\" style={{ marginBottom: '45px' }}>\n {captchaScriptLoaded && (\n <>\n {captchaError && (\n <Text type={TextType.Label} color={Color.Alert}>\n {captchaError}\n </Text>\n )}\n <div ref={captchaRef} className=\"u-marg-bottom\"></div>\n </>\n )}\n <BEButton\n size=\"normal\"\n filled={true}\n success={true}\n isLoading={isLoading}\n stopIconAnimation={true}\n icon={context.screenSize > ScreenSize.Mobile ? IconType.ArrowRight : null}\n onClick={buttonOnClickHandler}\n >\n {modalButtonText}\n </BEButton>\n </div>\n </FormProvider>\n <Text type={TextType.Label} color={Color.DarkGrey}>\n <span dangerouslySetInnerHTML={{ __html: t(Translation.MemberOnlyPopup.AgreeToReceiveDeals, { companyShort: ccx?.companyShort }) }}></span>\n </Text>{' '}\n <Text type={TextType.Label} color={Color.DarkGrey}>\n <span dangerouslySetInnerHTML={{ __html: t(Translation.MemberOnlyPopup.UnsubscribeAnytime) }}></span>\n </Text>\n </div>\n </div>\n </div>\n </SimpleModal>\n );\n}\n"]}
|
|
@@ -134,7 +134,7 @@ function RoomList() {
|
|
|
134
134
|
_a.map((hotelId) => (React.createElement(RoomListCrossSellBlock_1.default, { key: hotelId, hotelId: hotelId })))))));
|
|
135
135
|
DataLayer_1.default.instance.sendRoomImpressions();
|
|
136
136
|
return elements;
|
|
137
|
-
}, [rooms, isLoading, openRoom, sortBy, beContext.currentFilters]);
|
|
137
|
+
}, [rooms, isLoading, openRoom, sortBy, beContext.currentFilters, basketContext.loadedPromotion]);
|
|
138
138
|
}
|
|
139
139
|
exports.default = RoomList;
|
|
140
140
|
//# sourceMappingURL=RoomList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoomList.js","sourceRoot":"/","sources":["src/components/steps/room/RoomList.tsx"],"names":[],"mappings":";;AAAA,iCAAyE;AACzE,iDAAyE;AACzE,+BAA+B;AAC/B,2DAAoD;AACpD,2DAAoD;AAEpD,kEAA2D;AAC3D,0EAAmE;AAEnE,sEAA+D;AAC/D,qEAA8D;AAC9D,uDAAgD;AAChD,yDAAkD;AAClD,2CAA4D;AAC5D,iDAAoD;AACpD,2DAAwD;AAExD,sEAAmE;AAGnE,4EAAyE;AAEzE,SAAwB,QAAQ;;IAC5B,MAAM,aAAa,GAAG,kBAAU,CAAC,wBAAa,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,kBAAU,CAAC,+BAAoB,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CAAC,CAAC,CACrB,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,oBAAC,qBAAW,IAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,KAAK,WAAW,CAAC,MAAM,GAAG,CAAC,GAAI,CAAC,CACvI,CAAC,CAAC,CAAC,CACA;YACK,WAAW,CAAC,CAAC,CAAC,oBAAC,qCAAiB,OAAG,CAAC,CAAC,CAAC,oBAAC,2BAAiB,OAAG,QAC3D,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,iBAAiB;eAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACxC,oBAAC,gCAAsB,IAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAI,CAC7D,EACF,CACN,CACC,CACT,CAAC;QAEF,mBAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;QAEzC,OAAO,QAAQ,CAAC;IACpB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;AACvE,CAAC;AAhKD,2BAgKC","sourcesContent":["import { useContext, useState, useMemo, useRef, useEffect } from 'react';\nimport { BasketContext, BookingEngineContext } from '@frontend/contexts';\nimport * as React from 'react';\nimport RoomDetails from './roomDetails/RoomDetails';\nimport NoRoomsFoundBlock from './NoRoomsFoundBlock';\nimport { Room } from '../../../models/Room/Room';\nimport LargeLoader from '../../generic/loader/LargeLoader';\nimport RoomSortProvider from '../../../providers/RoomSortProvider';\nimport Filter from '../../../models/Room/Filters/Filter';\nimport FilterProvider from '../../../providers/FilterProvider';\nimport RoomListCrossSellBlock from './RoomListCrossSellBlock';\nimport DataLayer from '../../../util/DataLayer';\nimport ScreenSize from '../../../util/ScreenSize';\nimport { useCurrentHotel, useEvent } from '@frontend/hooks';\nimport { CompanyContext } from '@frontend/contexts';\nimport { StepRoomErrorForm } from './StepRoomErrorForm';\nimport { SearchParameters } from 'models/SearchParameters';\nimport { GuestSearchEvent } from 'events/actions/GuestSearchEvent';\nimport { RoomListSearch, RoomRateSearch, RoomRateSearchPrice } from 'models/RoomListSearch';\nimport { RoomRate } from 'models/Room/RoomRate';\nimport { RoomListSearchEvent } from 'events/actions/RoomListSearchEvent';\n\nexport default function RoomList() {\n const basketContext = useContext(BasketContext);\n const beContext = useContext(BookingEngineContext);\n const ccx = useContext(CompanyContext);\n\n const { hotel } = useCurrentHotel();\n\n const [rooms, setRooms] = React.useState<Room[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n\n const [openRoom, setOpenRoom] = useState(null);\n const [apiHasError, setApiHasError] = useState(null);\n\n const roomListRef = useRef(null);\n\n const selectedRow = basketContext.selectedBasketRow;\n\n const startDate = selectedRow?.getStartDate();\n const endDate = selectedRow?.getEndDate();\n const promoCode = selectedRow?.getPromoCode();\n\n const adults = selectedRow?.getAdults();\n const children = selectedRow?.getChildren();\n const sortBy = beContext.currentRoomSort;\n\n let listWhenLastScrolled: Room[] = null;\n\n const { raise } = useEvent();\n\n const scrollIntoView = () => {\n if (roomListRef.current && listWhenLastScrolled !== rooms) {\n listWhenLastScrolled = rooms;\n const offset = beContext.screenSize <= ScreenSize.Medium ? 185 : 350;\n\n window.scrollTo({ top: window.scrollY + (roomListRef.current.getBoundingClientRect().top - offset), behavior: 'smooth' });\n }\n };\n\n useEffect(() => {\n let isCancelled = false;\n\n try {\n const search: SearchParameters = {\n checkInTime: startDate?.format('YYYY-M-D'),\n checkOutTime: endDate?.format('YYYY-M-D'),\n numAdults: adults,\n numChildren: children,\n numRooms: 1,\n promoCode: promoCode,\n };\n\n const event = new GuestSearchEvent(search);\n raise(event);\n\n const filters: Filter[] = Object.values(beContext.currentFilters).filter((filter) => !!filter) as Filter[];\n\n let row = basketContext.selectedBasketRow;\n\n if (!row && !rooms.length) {\n row = basketContext.attemptSelectUnfilledRow();\n }\n\n if (!row) {\n const validRows = basketContext.getAllValidRows();\n row = validRows[validRows.length - 1];\n }\n\n if (row) {\n setIsLoading(true);\n FilterProvider.getRoomList(row, filters, hotel.hotelID)\n .then((availableRooms) => {\n if (!isCancelled) {\n setRooms(availableRooms);\n setOpenRoom(basketContext.selectedBasketRow);\n setApiHasError(false);\n\n const foundRooms: RoomListSearch[] =\n availableRooms?.map((room) => {\n const { name, code } = room;\n\n const foundRoom: RoomListSearch = {\n name,\n code,\n lowestPrice: room.getLowestPrice(),\n highestPrice: room.getHighestPrice(),\n currency: ccx.currentCurrency,\n\n rates:\n room.getRates()?.map((rate) => {\n const { name, code } = rate;\n return {\n name,\n code,\n\n price: {\n averagePrice: rate.getAveragePrice(),\n totalPrice: rate.getTotalPrice(),\n currency: ccx.currentCurrency,\n },\n };\n }) ?? [],\n };\n\n return foundRoom;\n }) ?? [];\n\n const event = new RoomListSearchEvent(search, foundRooms);\n raise(event);\n }\n })\n .catch(() => {\n if (!isCancelled) {\n setRooms([]);\n setOpenRoom(null);\n setApiHasError(true);\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }\n } catch (ex) {}\n\n return () => {\n setIsLoading(false);\n isCancelled = true;\n };\n }, [adults, children, startDate, endDate, promoCode, ccx.currentLanguage, beContext.currentFilters, basketContext.selectedBasketRow?.getStale()]);\n\n return useMemo(() => {\n const sortedRooms = [...rooms];\n if (sortedRooms.length !== 0) {\n sortedRooms.sort(RoomSortProvider.getSortByFunction(sortBy));\n }\n\n setTimeout(() => {\n scrollIntoView();\n }, 100);\n\n const elements = (\n <div ref={roomListRef}>\n {isLoading ? (\n <LargeLoader />\n ) : sortedRooms.length ? (\n sortedRooms.map((room, index) => <RoomDetails key={room.code} room={room} disableMarginBottom={index === sortedRooms.length - 1} />)\n ) : (\n <>\n {apiHasError ? <StepRoomErrorForm /> : <NoRoomsFoundBlock />}\n {hotel?.crossSellHotelIds?.map((hotelId) => (\n <RoomListCrossSellBlock key={hotelId} hotelId={hotelId} />\n ))}\n </>\n )}\n </div>\n );\n\n DataLayer.instance.sendRoomImpressions();\n\n return elements;\n }, [rooms, isLoading, openRoom, sortBy, beContext.currentFilters]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RoomList.js","sourceRoot":"/","sources":["src/components/steps/room/RoomList.tsx"],"names":[],"mappings":";;AAAA,iCAAyE;AACzE,iDAAyE;AACzE,+BAA+B;AAC/B,2DAAoD;AACpD,2DAAoD;AAEpD,kEAA2D;AAC3D,0EAAmE;AAEnE,sEAA+D;AAC/D,qEAA8D;AAC9D,uDAAgD;AAChD,yDAAkD;AAClD,2CAA4D;AAC5D,iDAAoD;AACpD,2DAAwD;AAExD,sEAAmE;AAEnE,4EAAyE;AAEzE,SAAwB,QAAQ;;IAC5B,MAAM,aAAa,GAAG,kBAAU,CAAC,wBAAa,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,kBAAU,CAAC,+BAAoB,CAAC,CAAC;IACnD,MAAM,GAAG,GAAG,kBAAU,CAAC,yBAAc,CAAC,CAAC;IAEvC,MAAM,EAAE,KAAK,EAAE,GAAG,uBAAe,EAAE,CAAC;IAEpC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAS,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,gBAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,gBAAQ,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,gBAAQ,CAAC,IAAI,CAAC,CAAC;IAErD,MAAM,WAAW,GAAG,cAAM,CAAC,IAAI,CAAC,CAAC;IAEjC,MAAM,WAAW,GAAG,aAAa,CAAC,iBAAiB,CAAC;IAEpD,MAAM,SAAS,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,YAAY,EAAE,CAAC;I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C,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;AACtG,CAAC;AAhKD,2BAgKC","sourcesContent":["import { useContext, useState, useMemo, useRef, useEffect } from 'react';\nimport { BasketContext, BookingEngineContext } from '@frontend/contexts';\nimport * as React from 'react';\nimport RoomDetails from './roomDetails/RoomDetails';\nimport NoRoomsFoundBlock from './NoRoomsFoundBlock';\nimport { Room } from '../../../models/Room/Room';\nimport LargeLoader from '../../generic/loader/LargeLoader';\nimport RoomSortProvider from '../../../providers/RoomSortProvider';\nimport Filter from '../../../models/Room/Filters/Filter';\nimport FilterProvider from '../../../providers/FilterProvider';\nimport RoomListCrossSellBlock from './RoomListCrossSellBlock';\nimport DataLayer from '../../../util/DataLayer';\nimport ScreenSize from '../../../util/ScreenSize';\nimport { useCurrentHotel, useEvent } from '@frontend/hooks';\nimport { CompanyContext } from '@frontend/contexts';\nimport { StepRoomErrorForm } from './StepRoomErrorForm';\nimport { SearchParameters } from 'models/SearchParameters';\nimport { GuestSearchEvent } from 'events/actions/GuestSearchEvent';\nimport { RoomListSearch } from 'models/RoomListSearch';\nimport { RoomListSearchEvent } from 'events/actions/RoomListSearchEvent';\n\nexport default function RoomList() {\n const basketContext = useContext(BasketContext);\n const beContext = useContext(BookingEngineContext);\n const ccx = useContext(CompanyContext);\n\n const { hotel } = useCurrentHotel();\n\n const [rooms, setRooms] = React.useState<Room[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n\n const [openRoom, setOpenRoom] = useState(null);\n const [apiHasError, setApiHasError] = useState(null);\n\n const roomListRef = useRef(null);\n\n const selectedRow = basketContext.selectedBasketRow;\n\n const startDate = selectedRow?.getStartDate();\n const endDate = selectedRow?.getEndDate();\n const promoCode = selectedRow?.getPromoCode();\n\n const adults = selectedRow?.getAdults();\n const children = selectedRow?.getChildren();\n const sortBy = beContext.currentRoomSort;\n\n let listWhenLastScrolled: Room[] = null;\n\n const { raise } = useEvent();\n\n const scrollIntoView = () => {\n if (roomListRef.current && listWhenLastScrolled !== rooms) {\n listWhenLastScrolled = rooms;\n const offset = beContext.screenSize <= ScreenSize.Medium ? 185 : 350;\n\n window.scrollTo({ top: window.scrollY + (roomListRef.current.getBoundingClientRect().top - offset), behavior: 'smooth' });\n }\n };\n\n useEffect(() => {\n let isCancelled = false;\n\n try {\n const search: SearchParameters = {\n checkInTime: startDate?.format('YYYY-M-D'),\n checkOutTime: endDate?.format('YYYY-M-D'),\n numAdults: adults,\n numChildren: children,\n numRooms: 1,\n promoCode: promoCode,\n };\n\n const event = new GuestSearchEvent(search);\n raise(event);\n\n const filters: Filter[] = Object.values(beContext.currentFilters).filter((filter) => !!filter) as Filter[];\n\n let row = basketContext.selectedBasketRow;\n\n if (!row && !rooms.length) {\n row = basketContext.attemptSelectUnfilledRow();\n }\n\n if (!row) {\n const validRows = basketContext.getAllValidRows();\n row = validRows[validRows.length - 1];\n }\n\n if (row) {\n setIsLoading(true);\n FilterProvider.getRoomList(row, filters, hotel.hotelID)\n .then((availableRooms) => {\n if (!isCancelled) {\n setRooms(availableRooms);\n setOpenRoom(basketContext.selectedBasketRow);\n setApiHasError(false);\n\n const foundRooms: RoomListSearch[] =\n availableRooms?.map((room) => {\n const { name, code } = room;\n\n const foundRoom: RoomListSearch = {\n name,\n code,\n lowestPrice: room.getLowestPrice(),\n highestPrice: room.getHighestPrice(),\n currency: ccx.currentCurrency,\n\n rates:\n room.getRates()?.map((rate) => {\n const { name, code } = rate;\n return {\n name,\n code,\n\n price: {\n averagePrice: rate.getAveragePrice(),\n totalPrice: rate.getTotalPrice(),\n currency: ccx.currentCurrency,\n },\n };\n }) ?? [],\n };\n\n return foundRoom;\n }) ?? [];\n\n const event = new RoomListSearchEvent(search, foundRooms);\n raise(event);\n }\n })\n .catch(() => {\n if (!isCancelled) {\n setRooms([]);\n setOpenRoom(null);\n setApiHasError(true);\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }\n } catch (ex) {}\n\n return () => {\n setIsLoading(false);\n isCancelled = true;\n };\n }, [adults, children, startDate, endDate, promoCode, ccx.currentLanguage, beContext.currentFilters, basketContext.selectedBasketRow?.getStale()]);\n\n return useMemo(() => {\n const sortedRooms = [...rooms];\n if (sortedRooms.length !== 0) {\n sortedRooms.sort(RoomSortProvider.getSortByFunction(sortBy));\n }\n\n setTimeout(() => {\n scrollIntoView();\n }, 100);\n\n const elements = (\n <div ref={roomListRef}>\n {isLoading ? (\n <LargeLoader />\n ) : sortedRooms.length ? (\n sortedRooms.map((room, index) => <RoomDetails key={room.code} room={room} disableMarginBottom={index === sortedRooms.length - 1} />)\n ) : (\n <>\n {apiHasError ? <StepRoomErrorForm /> : <NoRoomsFoundBlock />}\n {hotel?.crossSellHotelIds?.map((hotelId) => (\n <RoomListCrossSellBlock key={hotelId} hotelId={hotelId} />\n ))}\n </>\n )}\n </div>\n );\n\n DataLayer.instance.sendRoomImpressions();\n\n return elements;\n }, [rooms, isLoading, openRoom, sortBy, beContext.currentFilters, basketContext.loadedPromotion]);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MembersOnlyRow.js","sourceRoot":"/","sources":["src/components/steps/room/roomDetails/roomRates/MembersOnlyRow.tsx"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"MembersOnlyRow.js","sourceRoot":"/","sources":["src/components/steps/room/roomDetails/roomRates/MembersOnlyRow.tsx"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,iCAA2C;AAC3C,mDAA0D;AAC1D,qDAAkD;AAClD,2DAAoD;AACpD,yEAAsE;AACtE,iDAA+C;AAE/C,yCAAyC;AAEzC,mDAA0D;AAC1D,mDAA0D;AAC1D,6DAA4F;AAC5F,oEAA6D;AAC7D,iDAAoD;AAEpD,SAAwB,cAAc;IAClC,MAAM,GAAG,GAAG,kBAAU,CAAC,yBAAc,CAAC,C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E,eAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,aAAK,CAAC,OAAO,GAAI,CAChD;gBACP,oBAAC,cAAI,IAAC,IAAI,EAAE,eAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,aAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI;oBACzD,oCAAS,CAAC,CAAC,yBAAW,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAU,CAC1E,CACL,CACJ,CACT,CACC,CACJ,CACT,CAAC;AACN,CAAC;AApFD,iCAoFC","sourcesContent":["import * as React from 'react';\nimport { useContext, useRef } from 'react';\nimport Text, { TextType } from '../../../../generic/Text';\nimport { Color } from '../../../../../util/Color';\nimport BEButton from '../../../../generic/BEButton';\nimport { Translation } from '../../../../../translations/Translation';\nimport { useTranslation } from 'react-i18next';\n\nimport * as classNames from 'classnames';\n\nimport Icon, { IconType } from '../../../../generic/Icon';\nimport Pill, { PillType } from '../../../../generic/Pill';\nimport DataLayer, { InteractionStep, InteractionType } from '../../../../../util/DataLayer';\nimport RoomDetailsPriceBlock from '../RoomDetailsPriceBlock';\nimport { CompanyContext } from '@frontend/contexts';\n\nexport default function MembersOnlyRow() {\n const ccx = useContext(CompanyContext);\n\n const { t } = useTranslation();\n\n const currentRow = useRef(null);\n\n const classes = classNames('room-info', {\n '--locked': true,\n });\n\n let isLocked = false;\n\n if (!ccx.signedInUser) {\n isLocked = true;\n }\n\n const openSignupModalOnClick = () => {\n DataLayer.instance.sendInteraction('Member Signup Modal', InteractionType.BUTTON, InteractionStep.ROOMS);\n ccx.openMemberSignupModal();\n };\n\n return (\n <div className={classes} ref={currentRow}>\n <div className=\"row\">\n {isLocked ? (\n <>\n <div className=\"col-md-8\">\n <div className=\"u-flex flex-column h-100\">\n <div>\n <div className=\"u-marg-bottom-half\">\n <Text type={TextType.Body} color={Color.Success}>\n <strong>{t(Translation.Step.Room.RoomInfo.MemberOnlyRow.MemberOnlyPrices)}</strong>\n </Text>\n </div>\n <div\n className=\"u-marg-bottom u-h-ml-2 text-small u-clear-font-weight\"\n dangerouslySetInnerHTML={{\n __html: t(Translation.Step.Room.RoomInfo.MemberOnlyRow.DealsForOnly, {\n companyShort: ccx?.companyShort,\n }),\n }}\n ></div>\n <div className=\"u-marg-bottom\" onClick={openSignupModalOnClick}>\n <Pill icon={IconType.Money} type={PillType.Success}>\n {t(Translation.Step.Room.RoomInfo.SignUpToSee)}\n </Pill>\n </div>\n </div>\n <div className=\"u-flex justify-content-start u-marg-top-bottom@m-\">\n <div className=\"u-marg-right u-inline-flex\">\n <BEButton icon={IconType.ArrowRight2} isText={true} primary={true} size=\"small\" iconPosition=\"right\" onClick={openSignupModalOnClick}>\n {t(Translation.Step.Room.ReadMore)}\n </BEButton>\n </div>\n </div>\n </div>\n </div>\n <div className=\"col-md-4 u-flex flex-column align-items-start align-items-md-end justify-content-start\">\n <RoomDetailsPriceBlock isLocked={isLocked} averagePreDiscount={321} averagePrice={321} isMemberOnly={true} />\n <div className=\"u-marg-top u-w-100@m-\">\n {isLocked && (\n <BEButton filled={true} success={true} mobileWidth={true} onClick={openSignupModalOnClick}>\n Reveal Prices Now\n </BEButton>\n )}\n </div>\n </div>\n </>\n ) : (\n <div className=\"d-flex justify-content-center w-100\">\n <div className=\"d-flex align-items-center\">\n <span className=\"room-details--content-price-lock u-marg-right\" style={{ opacity: 1, position: 'unset', transform: 'none' }}>\n <Icon icon={IconType.Lock} color={Color.Success} />\n </span>\n <Text type={TextType.Body} color={Color.Success} inline={true}>\n <strong>{t(Translation.Step.Room.RoomInfo.MemberOnlyDealsActivated)}</strong>\n </Text>\n </div>\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IPromotion } from 'models/Promotion/IPromotion.type';
|
|
2
|
+
import './RoomRateListPromotion.global.scss';
|
|
3
|
+
declare type RoomRateListPromotionProps = {
|
|
4
|
+
promotion: IPromotion;
|
|
5
|
+
};
|
|
6
|
+
export declare const RoomRateListPromotion: (props: RoomRateListPromotionProps) => JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoomRateListPromotion = void 0;
|
|
4
|
+
const BEButton_1 = require("components/generic/BEButton");
|
|
5
|
+
const Icon_1 = require("components/generic/Icon");
|
|
6
|
+
const Text_1 = require("components/generic/Text");
|
|
7
|
+
const PromotionClickedEvent_1 = require("events/actions/Promotion/PromotionClickedEvent");
|
|
8
|
+
const EventHook_1 = require("hooks/EventHook");
|
|
9
|
+
const React = require("react");
|
|
10
|
+
const Color_1 = require("util/Color");
|
|
11
|
+
require("./RoomRateListPromotion.global.scss");
|
|
12
|
+
exports.RoomRateListPromotion = (props) => {
|
|
13
|
+
const { promotion } = props;
|
|
14
|
+
const { raise } = EventHook_1.useEvent();
|
|
15
|
+
const onApplyNowClicked = () => {
|
|
16
|
+
const promoClickedEvent = new PromotionClickedEvent_1.PromotionClickedEvent(promotion);
|
|
17
|
+
raise(promoClickedEvent);
|
|
18
|
+
};
|
|
19
|
+
return (React.createElement("div", { className: "c-room-list-promotion" },
|
|
20
|
+
React.createElement("div", { className: "c-room-list-promotion--content" },
|
|
21
|
+
React.createElement("div", { className: "c-room-list-promotion--icon" },
|
|
22
|
+
React.createElement(Icon_1.default, { icon: Icon_1.IconType.Money, size: '42px', color: Color_1.Color.Accent })),
|
|
23
|
+
React.createElement("div", { className: "c-room-list-promotion--body" },
|
|
24
|
+
React.createElement("div", { className: "u-marg-bottom--light" },
|
|
25
|
+
React.createElement(Text_1.default, { color: Color_1.Color.Accent, bold: true }, promotion.name)),
|
|
26
|
+
React.createElement(Text_1.default, { type: Text_1.TextType.Small }, promotion.description))),
|
|
27
|
+
React.createElement("div", { className: "c-room-list-promotion--button" },
|
|
28
|
+
React.createElement(BEButton_1.default, { primary: true, filled: true, onClick: onApplyNowClicked, mobileWidth: true }, "Apply now"))));
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=RoomRateListPromotion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoomRateListPromotion.js","sourceRoot":"/","sources":["src/components/steps/room/roomDetails/roomRates/RoomRateListPromotion/RoomRateListPromotion.tsx"],"names":[],"mappings":";;;AAAA,0DAAmD;AACnD,kDAAyD;AACzD,kDAAyD;AACzD,0FAAuF;AACvF,+CAA2C;AAE3C,+BAA+B;AAC/B,sCAAmC;AAEnC,+CAA6C;AAMhC,QAAA,qBAAqB,GAAG,CAAC,KAAiC,EAAE,EAAE;IACvE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAE5B,MAAM,EAAE,KAAK,EAAE,GAAG,oBAAQ,EAAE,CAAC;IAE7B,MAAM,iBAAiB,GAAG,GAAG,EAAE;QAC3B,MAAM,iBAAiB,GAAG,IAAI,6CAAqB,CAAC,SAAS,CAAC,CAAC;QAE/D,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF,OAAO,CACH,6BAAK,SAAS,EAAC,uBAAuB;QAClC,6BAAK,SAAS,EAAC,gCAAgC;YAC3C,6BAAK,SAAS,EAAC,6BAA6B;gBACxC,oBAAC,cAAI,IAAC,IAAI,EAAE,eAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAK,CAAC,MAAM,GAAI,CAC/D;YACN,6BAAK,SAAS,EAAC,6BAA6B;gBACxC,6BAAK,SAAS,EAAC,sBAAsB;oBACjC,oBAAC,cAAI,IAAC,KAAK,EAAE,aAAK,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,IAChC,SAAS,CAAC,IAAI,CACZ,CACL;gBAEN,oBAAC,cAAI,IAAC,IAAI,EAAE,eAAQ,CAAC,KAAK,IAAG,SAAS,CAAC,WAAW,CAAQ,CACxD,CACJ;QACN,6BAAK,SAAS,EAAC,+BAA+B;YAC1C,oBAAC,kBAAQ,IAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,IAAI,gBAEzE,CACT,CACJ,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import BEButton from 'components/generic/BEButton';\nimport Icon, { IconType } from 'components/generic/Icon';\nimport Text, { TextType } from 'components/generic/Text';\nimport { PromotionClickedEvent } from 'events/actions/Promotion/PromotionClickedEvent';\nimport { useEvent } from 'hooks/EventHook';\nimport type { IPromotion } from 'models/Promotion/IPromotion.type';\nimport * as React from 'react';\nimport { Color } from 'util/Color';\n\nimport './RoomRateListPromotion.global.scss';\n\ntype RoomRateListPromotionProps = {\n promotion: IPromotion;\n};\n\nexport const RoomRateListPromotion = (props: RoomRateListPromotionProps) => {\n const { promotion } = props;\n\n const { raise } = useEvent();\n\n const onApplyNowClicked = () => {\n const promoClickedEvent = new PromotionClickedEvent(promotion);\n\n raise(promoClickedEvent);\n };\n\n return (\n <div className=\"c-room-list-promotion\">\n <div className=\"c-room-list-promotion--content\">\n <div className=\"c-room-list-promotion--icon\">\n <Icon icon={IconType.Money} size={'42px'} color={Color.Accent} />\n </div>\n <div className=\"c-room-list-promotion--body\">\n <div className=\"u-marg-bottom--light\">\n <Text color={Color.Accent} bold={true}>\n {promotion.name}\n </Text>\n </div>\n\n <Text type={TextType.Small}>{promotion.description}</Text>\n </div>\n </div>\n <div className=\"c-room-list-promotion--button\">\n <BEButton primary={true} filled={true} onClick={onApplyNowClicked} mobileWidth={true}>\n Apply now\n </BEButton>\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -15,6 +15,7 @@ const MembersOnlyRow_1 = require("./MembersOnlyRow");
|
|
|
15
15
|
const ScreenSize_1 = require("../../../../../util/ScreenSize");
|
|
16
16
|
const hooks_1 = require("@frontend/hooks");
|
|
17
17
|
const contexts_2 = require("@frontend/contexts");
|
|
18
|
+
const RoomRateListPromotion_1 = require("./RoomRateListPromotion/RoomRateListPromotion");
|
|
18
19
|
function RoomRates(props) {
|
|
19
20
|
const { t } = react_i18next_1.useTranslation();
|
|
20
21
|
const [showingMoreOpen, setShowingMoreOpen] = react_1.useState(false);
|
|
@@ -80,6 +81,9 @@ function RoomRates(props) {
|
|
|
80
81
|
itemsToRender.push(React.createElement(MembersOnlyRow_1.default, null));
|
|
81
82
|
}
|
|
82
83
|
}
|
|
84
|
+
if (basketContext.loadedPromotion) {
|
|
85
|
+
itemsToRender.push(React.createElement(RoomRateListPromotion_1.RoomRateListPromotion, { promotion: basketContext.loadedPromotion }));
|
|
86
|
+
}
|
|
83
87
|
// Then we add the remaining rates to the render list - stop adding if we hit `maxRows`
|
|
84
88
|
sortedRates.forEach((rate) => {
|
|
85
89
|
if (itemsToRender.length < maxRows || showingMoreOpen) {
|
|
@@ -100,7 +104,7 @@ function RoomRates(props) {
|
|
|
100
104
|
rowsLeftToOpen,
|
|
101
105
|
" ",
|
|
102
106
|
t(Translation_1.Translation.Step.Room.RoomInfo.MoreRates))))));
|
|
103
|
-
}, [props.featuredRates, rates, beContext.currentRoomSort, showingMoreOpen]);
|
|
107
|
+
}, [props.featuredRates, rates, beContext.currentRoomSort, showingMoreOpen, basketContext === null || basketContext === void 0 ? void 0 : basketContext.loadedPromotion]);
|
|
104
108
|
}
|
|
105
109
|
exports.default = RoomRates;
|
|
106
110
|
//# sourceMappingURL=RoomRates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoomRates.js","sourceRoot":"/","sources":["src/components/steps/room/roomDetails/roomRates/RoomRates.tsx"],"names":[],"mappings":";;AAAA,+BAA+B;AAE/B,+CAAwC;AAExC,iCAAiE;AACjE,mDAAoD;AACpD,2DAAoD;AACpD,qDAAkD;AAClD,iDAAyE;AACzE,gFAAyE;AAEzE,iDAA+C;AAC/C,yEAAsE;AACtE,6DAAsD;AACtD,qDAA8C;AAC9C,+DAAwD;AACxD,2CAAkD;AAClD,iDAAoD;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I,eAAe,EAAE;gBACnD,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;aAC/C;iBAAM;gBACH,cAAc,EAAE,CAAC;aACpB;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,CACH,6BAAK,SAAS,QAAE,KAAK,CAAC,UAAU,mCAAI,EAAE;YACjC,aAAa,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,KAAa,EAAE,EAAE;gBAC5C,OAAO,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,KAAK,IAAG,IAAI,CAAkB,CAAC;YAC/D,CAAC,CAAC;YACD,cAAc,GAAG,CAAC,IAAI,CACnB,6BAAK,SAAS,EAAC,gBAAgB;gBAC3B,oBAAC,kBAAQ,IAAC,IAAI,EAAE,eAAQ,CAAC,UAAU,EAAE,YAAY,EAAC,OAAO,EAAC,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,aAAK,CAAC,IAAI,EAAE,OAAO,EAAE,eAAe;oBAC3I,CAAC,CAAC,yBAAW,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;;oBAAG,cAAc;;oBAAG,CAAC,CAAC,yBAAW,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAC/F,CACT,CACT,CACC,CACT,CAAC;IACN,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,eAAe,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,eAAe,CAAC,CAAC,CAAC;AACjH,CAAC;AA9GD,4BA8GC","sourcesContent":["import * as React from 'react';\n\nimport RoomRateRow from './RoomRateRow';\nimport { RoomRate } from '../../../../../models/Room/RoomRate';\nimport { useState, useEffect, useContext, useMemo } from 'react';\nimport { IconType } from '../../../../generic/Icon';\nimport BEButton from '../../../../generic/BEButton';\nimport { Color } from '../../../../../util/Color';\nimport { BasketContext, BookingEngineContext } from '@frontend/contexts';\nimport RoomSortProvider from '../../../../../providers/RoomSortProvider';\n\nimport { useTranslation } from 'react-i18next';\nimport { Translation } from '../../../../../translations/Translation';\nimport DataLayer from '../../../../../util/DataLayer';\nimport MembersOnlyRow from './MembersOnlyRow';\nimport ScreenSize from '../../../../../util/ScreenSize';\nimport { useCurrentHotel } from '@frontend/hooks';\nimport { CompanyContext } from '@frontend/contexts';\nimport { RoomRateListPromotion } from './RoomRateListPromotion/RoomRateListPromotion';\nexport interface RoomRatesProps {\n roomCode: string;\n rates: RoomRate[];\n\n featuredRates?: RoomRate[];\n\n classNames?: string;\n\n hideMemberOnlyRow?: boolean;\n\n // Inline Booking Widget overrides\n getButtonLabel?: (isRoomSelectedAndEditing: boolean, isThisSelectedRow: boolean) => string;\n onAddToBasketOverride?: (rate: RoomRate) => void;\n}\n\nexport default function RoomRates(props: RoomRatesProps) {\n const { t } = useTranslation();\n const [showingMoreOpen, setShowingMoreOpen] = useState(false);\n\n const basketContext = useContext(BasketContext);\n const beContext = useContext(BookingEngineContext);\n\n const ccx = useContext(CompanyContext);\n\n const { hotel } = useCurrentHotel();\n\n const { rates } = props;\n\n const numOfRatesToShowFirst = beContext.screenSize <= ScreenSize.Medium ? 2 : 3;\n\n const sortBy = beContext.currentRoomSort;\n\n useEffect(() => {\n if (basketContext.selectedBasketRow?.getRoom() && basketContext.selectedBasketRow.getRoom().code === props.roomCode) {\n setShowingMoreOpen(true);\n }\n }, [basketContext.selectedBasketRow]);\n\n useEffect(() => {\n DataLayer.instance.sendRoomImpressions();\n }, [showingMoreOpen]);\n\n return useMemo(() => {\n const featuredRates = props.featuredRates?.filter((rate) => !!rate);\n const hasFeaturedRates = !!featuredRates && featuredRates.length > 0;\n\n let sortedRates: RoomRate[];\n\n if (rates.length !== 0) {\n sortedRates = rates.sort(RoomSortProvider.getSortByFunction(sortBy));\n }\n\n // Need two sorts because of MOD\n sortedRates = rates.sort((a, b) => {\n if (a.isMemberOnly) {\n return -1;\n } else if (b.isMemberOnly) {\n return 1;\n } else {\n return 0;\n }\n });\n\n const showMoreOnClick = () => {\n setShowingMoreOpen(true);\n };\n\n const itemsToRender = [];\n\n const renderRoomRateRow = (rate: RoomRate, isPromo = false) => {\n return <RoomRateRow key={rate.name} rate={rate} getButtonLabel={props.getButtonLabel} onAddToBasketOverride={props.onAddToBasketOverride} isPromoRate={isPromo} />;\n };\n\n const maxRows = hasFeaturedRates && !showingMoreOpen ? featuredRates.length : numOfRatesToShowFirst;\n let rowsLeftToOpen = 0;\n\n if (featuredRates && featuredRates.length) {\n featuredRates.sort(RoomSortProvider.getSortByFunction(sortBy));\n // First we add Featured Rates to the top of the list - no limits there\n featuredRates.forEach((row) => {\n if (row) {\n itemsToRender.push(renderRoomRateRow(row, true));\n }\n });\n }\n\n // Then we do a tricky check to see if MOD intent should be displayed\n if (!hasFeaturedRates || showingMoreOpen) {\n if (\n !props.hideMemberOnlyRow &&\n !!hotel?.memberOnlyPromoCode &&\n (!ccx.signedInUser || hotel?.memberOnlyPromoCode === basketContext?.selectedBasketRow?.getPromoCode())\n ) {\n itemsToRender.push(<MembersOnlyRow />);\n }\n }\n\n if (basketContext.loadedPromotion) {\n itemsToRender.push(<RoomRateListPromotion promotion={basketContext.loadedPromotion} />);\n }\n\n // Then we add the remaining rates to the render list - stop adding if we hit `maxRows`\n sortedRates.forEach((rate: RoomRate) => {\n if (itemsToRender.length < maxRows || showingMoreOpen) {\n itemsToRender.push(renderRoomRateRow(rate));\n } else {\n rowsLeftToOpen++;\n }\n });\n\n return (\n <div className={props.classNames ?? ''}>\n {itemsToRender.map((item: any, index: number) => {\n return <React.Fragment key={index}>{item}</React.Fragment>;\n })}\n {rowsLeftToOpen > 0 && (\n <div className=\"room-show-more\">\n <BEButton icon={IconType.ArrowDown2} iconPosition=\"right\" stopIconAnimation={true} isText={true} textColor={Color.Navy} onClick={showMoreOnClick}>\n {t(Translation.Step.Room.RoomInfo.Show)} {rowsLeftToOpen} {t(Translation.Step.Room.RoomInfo.MoreRates)}\n </BEButton>\n </div>\n )}\n </div>\n );\n }, [props.featuredRates, rates, beContext.currentRoomSort, showingMoreOpen, basketContext?.loadedPromotion]);\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as dayjs from 'dayjs';
|
|
2
|
+
import { IPromotion } from 'models/Promotion/IPromotion.type';
|
|
2
3
|
import type { Addon } from '../../models/Addon/Addon';
|
|
3
4
|
import type ReservationsDTO from '../../models/Api/ReservationsDTO';
|
|
4
5
|
import type BasketAddonRow from '../../models/BasketAddonRow';
|
|
@@ -8,6 +9,7 @@ export interface BasketContextType {
|
|
|
8
9
|
selectedBasketRow: BasketRow;
|
|
9
10
|
currentBasketRows: BasketRow[];
|
|
10
11
|
basketAddonRows: BasketAddonRow[];
|
|
12
|
+
loadedPromotion: IPromotion | null;
|
|
11
13
|
startDate: dayjs.Dayjs;
|
|
12
14
|
endDate: dayjs.Dayjs;
|
|
13
15
|
addBasketRow: (row: BasketRow, selectThisRate?: boolean, neverSelectThisRate?: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasketContextType.js","sourceRoot":"/","sources":["src/contexts/BasketContext/BasketContextType.ts"],"names":[],"mappings":"","sourcesContent":["import type * as dayjs from 'dayjs';\nimport type { Addon } from '../../models/Addon/Addon';\nimport type ReservationsDTO from '../../models/Api/ReservationsDTO';\nimport type BasketAddonRow from '../../models/BasketAddonRow';\nimport type BasketRow from '../../models/BasketRow';\nimport type { RoomRate } from '../../models/Room/RoomRate';\n\nexport interface BasketContextType {\n selectedBasketRow: BasketRow;\n currentBasketRows: BasketRow[];\n basketAddonRows: BasketAddonRow[];\n\n startDate: dayjs.Dayjs;\n endDate: dayjs.Dayjs;\n\n addBasketRow: (row: BasketRow, selectThisRate?: boolean, neverSelectThisRate?: boolean) => void;\n addRate: (rate: RoomRate, notify?: boolean) => Promise<void>;\n\n getAllValidRows: () => BasketRow[];\n getAllDatelessRows: () => BasketRow[];\n\n getNumberOfAdults: (withTranslation: boolean) => number | string;\n getNumberOfChildren: (withTranslation: boolean) => number | string;\n getNumberOfRooms: (withTranslation: boolean) => number | string;\n\n getTotalPrice: () => any;\n\n updateBasketRow: (row: BasketRow, updateGlobalDates?: boolean) => void;\n removeBasketRow: (row: BasketRow) => void;\n clearBasketRows: (confirm: boolean) => void;\n selectBasketRow: (row: BasketRow) => void;\n\n setStartDate: (date: dayjs.Dayjs) => void;\n setEndDate: (date: dayjs.Dayjs) => void;\n\n hasCheckedOut: boolean;\n reservationData: ReservationsDTO;\n checkedOut: (data: ReservationsDTO) => void;\n clearSelectedRates: () => void;\n\n getRowForAddon: (selectedAddon: Addon) => BasketAddonRow;\n\n setAddonQuantities: (addon: Addon, quantities: { quantity: number; adult: number; child: number }, selectedDate: string, selectedTime: string) => void;\n\n removeBasketAddonRow: (row: BasketAddonRow) => void;\n attemptSelectUnfilledRow: () => BasketRow | null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BasketContextType.js","sourceRoot":"/","sources":["src/contexts/BasketContext/BasketContextType.ts"],"names":[],"mappings":"","sourcesContent":["import type * as dayjs from 'dayjs';\nimport { IPromotion } from 'models/Promotion/IPromotion.type';\nimport type { Addon } from '../../models/Addon/Addon';\nimport type ReservationsDTO from '../../models/Api/ReservationsDTO';\nimport type BasketAddonRow from '../../models/BasketAddonRow';\nimport type BasketRow from '../../models/BasketRow';\nimport type { RoomRate } from '../../models/Room/RoomRate';\n\nexport interface BasketContextType {\n selectedBasketRow: BasketRow;\n currentBasketRows: BasketRow[];\n basketAddonRows: BasketAddonRow[];\n loadedPromotion: IPromotion | null;\n\n startDate: dayjs.Dayjs;\n endDate: dayjs.Dayjs;\n\n addBasketRow: (row: BasketRow, selectThisRate?: boolean, neverSelectThisRate?: boolean) => void;\n addRate: (rate: RoomRate, notify?: boolean) => Promise<void>;\n\n getAllValidRows: () => BasketRow[];\n getAllDatelessRows: () => BasketRow[];\n\n getNumberOfAdults: (withTranslation: boolean) => number | string;\n getNumberOfChildren: (withTranslation: boolean) => number | string;\n getNumberOfRooms: (withTranslation: boolean) => number | string;\n\n getTotalPrice: () => any;\n\n updateBasketRow: (row: BasketRow, updateGlobalDates?: boolean) => void;\n removeBasketRow: (row: BasketRow) => void;\n clearBasketRows: (confirm: boolean) => void;\n selectBasketRow: (row: BasketRow) => void;\n\n setStartDate: (date: dayjs.Dayjs) => void;\n setEndDate: (date: dayjs.Dayjs) => void;\n\n hasCheckedOut: boolean;\n reservationData: ReservationsDTO;\n checkedOut: (data: ReservationsDTO) => void;\n clearSelectedRates: () => void;\n\n getRowForAddon: (selectedAddon: Addon) => BasketAddonRow;\n\n setAddonQuantities: (addon: Addon, quantities: { quantity: number; adult: number; child: number }, selectedDate: string, selectedTime: string) => void;\n\n removeBasketAddonRow: (row: BasketAddonRow) => void;\n attemptSelectUnfilledRow: () => BasketRow | null;\n}\n"]}
|
|
@@ -35,6 +35,7 @@ const StepManager_1 = require("../../util/StepManager");
|
|
|
35
35
|
const StringHelper_1 = require("../../util/StringHelper");
|
|
36
36
|
const Translation_1 = require("../../translations/Translation");
|
|
37
37
|
const Text_1 = require("../../components/generic/Text");
|
|
38
|
+
const PromotionProvider_1 = require("providers/PromotionProvider");
|
|
38
39
|
function BasketContextWrapper(props) {
|
|
39
40
|
var _a, _b, _c;
|
|
40
41
|
const { t } = react_i18next_1.useTranslation();
|
|
@@ -130,7 +131,7 @@ function BasketContextWrapper(props) {
|
|
|
130
131
|
(_a = beContext.sessionProvider) === null || _a === void 0 ? void 0 : _a.updateSession({ basketRows: currentBasketRows, step: (_b = fullPageContext === null || fullPageContext === void 0 ? void 0 : fullPageContext.currentStep) === null || _b === void 0 ? void 0 : _b.getName() });
|
|
131
132
|
}, [currentBasketRows, fullPageContext === null || fullPageContext === void 0 ? void 0 : fullPageContext.currentStep, selectedBasketRow]);
|
|
132
133
|
const checkAndApplyMemberOnlyPromo = (row) => {
|
|
133
|
-
if ((hotel === null || hotel === void 0 ? void 0 : hotel.memberOnlyPromoCode) && localStorage.getItem('hotel' + (hotel === null || hotel === void 0 ? void 0 : hotel.hotelID) + 'user') && !row.getPromoCode()) {
|
|
134
|
+
if ((hotel === null || hotel === void 0 ? void 0 : hotel.memberOnlyPromoCode) && localStorage.getItem('hotel' + (hotel === null || hotel === void 0 ? void 0 : hotel.hotelID) + 'user') && !(row === null || row === void 0 ? void 0 : row.getPromoCode())) {
|
|
134
135
|
row.setPromoCode(hotel === null || hotel === void 0 ? void 0 : hotel.memberOnlyPromoCode);
|
|
135
136
|
workingContext.updateBasketRow(row);
|
|
136
137
|
}
|
|
@@ -160,6 +161,14 @@ function BasketContextWrapper(props) {
|
|
|
160
161
|
}
|
|
161
162
|
return null;
|
|
162
163
|
};
|
|
164
|
+
const updateBasketRow = (row, updateGlobalDates = true) => {
|
|
165
|
+
if (updateGlobalDates && row.getID() === (selectedBasketRow === null || selectedBasketRow === void 0 ? void 0 : selectedBasketRow.getID())) {
|
|
166
|
+
setStartDate(row.getStartDate());
|
|
167
|
+
setEndDate(row.getEndDate());
|
|
168
|
+
}
|
|
169
|
+
basketRowReducer({ method: 'Update', row });
|
|
170
|
+
};
|
|
171
|
+
const { loadedPromotion } = PromotionProvider_1.usePromotionContainer({ selectedBasketRow, updateBasketRow });
|
|
163
172
|
const workingContext = {
|
|
164
173
|
startDate,
|
|
165
174
|
endDate,
|
|
@@ -168,6 +177,7 @@ function BasketContextWrapper(props) {
|
|
|
168
177
|
basketAddonRows,
|
|
169
178
|
hasCheckedOut,
|
|
170
179
|
reservationData,
|
|
180
|
+
loadedPromotion,
|
|
171
181
|
/**
|
|
172
182
|
* When adding a basket row, will check if there is a `selectedBasketRow`
|
|
173
183
|
* if one is already set, row will simply get added, otherwise selectedBasketRow
|
|
@@ -305,13 +315,7 @@ function BasketContextWrapper(props) {
|
|
|
305
315
|
basketRowReducer({ method: 'Clear' });
|
|
306
316
|
}
|
|
307
317
|
},
|
|
308
|
-
updateBasketRow
|
|
309
|
-
if (updateGlobalDates && row.getID() === (selectedBasketRow === null || selectedBasketRow === void 0 ? void 0 : selectedBasketRow.getID())) {
|
|
310
|
-
setStartDate(row.getStartDate());
|
|
311
|
-
setEndDate(row.getEndDate());
|
|
312
|
-
}
|
|
313
|
-
basketRowReducer({ method: 'Update', row });
|
|
314
|
-
},
|
|
318
|
+
updateBasketRow,
|
|
315
319
|
/**
|
|
316
320
|
* Select passed basket row, and update all inputs (like start date)
|
|
317
321
|
*/
|