@roomstay/frontend 2.3.13-2 → 2.3.14
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/572.bundle.js +1 -1
- package/dist/87.bundle.js +1 -0
- package/dist/975.bundle.js +1 -1
- package/dist/main.bundle.js +1 -1
- package/dist/src/components/generic/Currency.d.ts +2 -11
- package/dist/src/components/generic/Currency.js +10 -62
- package/dist/src/components/generic/Currency.js.map +1 -1
- package/dist/src/components/generic/PaymentCard/InlinePaymentOption.js +23 -13
- package/dist/src/components/generic/PaymentCard/InlinePaymentOption.js.map +1 -1
- package/dist/src/components/generic/PlanpayPrice/PlanpayPrice.d.ts +7 -0
- package/dist/src/components/generic/PlanpayPrice/PlanpayPrice.js +50 -0
- package/dist/src/components/generic/PlanpayPrice/PlanpayPrice.js.map +1 -0
- package/dist/src/components/generic/RadioButtonGroup/RadioButtonGroup.js +34 -33
- package/dist/src/components/generic/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
- package/dist/src/components/generic/Text.d.ts +1 -1
- package/dist/src/components/generic/Text.js.map +1 -1
- package/dist/src/components/steps/confirmation/PaymentInformation.js +10 -24
- package/dist/src/components/steps/confirmation/PaymentInformation.js.map +1 -1
- package/dist/src/components/steps/confirmation/PlanpayLabel.d.ts +2 -0
- package/dist/src/components/steps/confirmation/PlanpayLabel.js +69 -0
- package/dist/src/components/steps/confirmation/PlanpayLabel.js.map +1 -0
- package/dist/src/components/steps/room/roomDetails/RoomDetails.js +18 -2
- package/dist/src/components/steps/room/roomDetails/RoomDetails.js.map +1 -1
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateRow.js +19 -2
- package/dist/src/components/steps/room/roomDetails/roomRates/RoomRateRow.js.map +1 -1
- package/dist/src/contexts/FullPageEngineContext/FullPageEngineContextWrapper.js +1 -2
- package/dist/src/contexts/FullPageEngineContext/FullPageEngineContextWrapper.js.map +1 -1
- package/dist/src/events/views/StepThanksViewEvent.d.ts +3 -1
- package/dist/src/events/views/StepThanksViewEvent.js +2 -1
- package/dist/src/events/views/StepThanksViewEvent.js.map +1 -1
- package/dist/src/hooks/Currency.d.ts +16 -0
- package/dist/src/hooks/Currency.js +73 -0
- package/dist/src/hooks/Currency.js.map +1 -0
- package/dist/src/hooks/Planpay.d.ts +15 -0
- package/dist/src/hooks/Planpay.js +25 -0
- package/dist/src/hooks/Planpay.js.map +1 -0
- package/dist/src/hooks/usePlanpayRawPrice.d.ts +8 -0
- package/dist/src/hooks/usePlanpayRawPrice.js +48 -0
- package/dist/src/hooks/usePlanpayRawPrice.js.map +1 -0
- package/dist/src/models/Api/HotelDTO.d.ts +2 -2
- package/dist/src/models/Api/HotelDTO.js.map +1 -1
- package/dist/src/models/Client/Hotel/Hotel.d.ts +2 -2
- package/dist/src/models/Client/Hotel/Hotel.js.map +1 -1
- package/dist/src/pages/steps/StepThanks/StepThanksComponent.js +1 -1
- package/dist/src/pages/steps/StepThanks/StepThanksComponent.js.map +1 -1
- package/dist/test.bundle.js +1 -1
- package/dist/vendors.bundle.js +1 -1
- package/package.json +2 -2
- package/dist/213.bundle.js +0 -1
- package/dist/423.bundle.js +0 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const contexts_1 = require("../contexts");
|
|
8
|
+
const CurrentHotelHook_1 = require("./CurrentHotelHook");
|
|
9
|
+
const CurrencyProvider_1 = __importDefault(require("../providers/CurrencyProvider"));
|
|
10
|
+
const useCurrency = (props) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const { currentCurrency } = (0, react_1.useContext)(contexts_1.CompanyContext);
|
|
13
|
+
const { hotel } = (0, CurrentHotelHook_1.useCurrentHotel)();
|
|
14
|
+
const [value, setValue] = (0, react_1.useState)(0);
|
|
15
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
16
|
+
const toLocalString = (original, toFixed) => {
|
|
17
|
+
if (props.disableLocalization) {
|
|
18
|
+
return original;
|
|
19
|
+
}
|
|
20
|
+
if (original) {
|
|
21
|
+
return original.toLocaleString(undefined, { minimumFractionDigits: toFixed ? 2 : 0 });
|
|
22
|
+
}
|
|
23
|
+
return original;
|
|
24
|
+
};
|
|
25
|
+
(0, react_1.useEffect)(() => {
|
|
26
|
+
let isCancelled = false;
|
|
27
|
+
setIsLoading(true);
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
if (!isCancelled) {
|
|
31
|
+
setIsLoading(false);
|
|
32
|
+
if (isNaN(props.children)) {
|
|
33
|
+
setValue(props.children);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const totalValue = CurrencyProvider_1.default.convertPrice(props.children, !props.hideDecimals, currentCurrency, (_a = props.originalCurrencyCode) !== null && _a !== void 0 ? _a : hotel === null || hotel === void 0 ? void 0 : hotel.defaultCurrency);
|
|
37
|
+
if (!isCancelled) {
|
|
38
|
+
setValue(totalValue);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, props.disableLoading ? 0 : 200);
|
|
43
|
+
return () => {
|
|
44
|
+
setIsLoading(false);
|
|
45
|
+
isCancelled = true;
|
|
46
|
+
};
|
|
47
|
+
}, [props.children, currentCurrency, props.originalCurrencyCode, CurrencyProvider_1.default.getRatesForCurrencyCode((_a = props.originalCurrencyCode) !== null && _a !== void 0 ? _a : hotel === null || hotel === void 0 ? void 0 : hotel.defaultCurrency)]);
|
|
48
|
+
return (0, react_1.useMemo)(() => {
|
|
49
|
+
const stringVal = props.disableLocalization ? value.toString() : value === null || value === void 0 ? void 0 : value.toLocaleString();
|
|
50
|
+
let symbol = CurrencyProvider_1.default.getSymbol(currentCurrency);
|
|
51
|
+
if (props.removeCurrencyAfterChar) {
|
|
52
|
+
const priceLength = String(value).length;
|
|
53
|
+
if (priceLength + symbol.length > props.removeCurrencyAfterChar) {
|
|
54
|
+
symbol = CurrencyProvider_1.default.getShortSymbol(currentCurrency);
|
|
55
|
+
if (priceLength + symbol.length > props.removeCurrencyAfterChar) {
|
|
56
|
+
symbol = '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
let prettyValue = toLocalString(value, !(props.hideDecimals || typeof value !== 'number'));
|
|
61
|
+
if (props.shortenThousandsAfter && props.shortenThousandsAfter <= String(value).length && props.hideDecimals) {
|
|
62
|
+
prettyValue = stringVal.substring(0, stringVal.length - 3) + '…';
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
isLoading,
|
|
66
|
+
symbol,
|
|
67
|
+
prettyValue,
|
|
68
|
+
value,
|
|
69
|
+
};
|
|
70
|
+
}, [value, isLoading]);
|
|
71
|
+
};
|
|
72
|
+
exports.default = useCurrency;
|
|
73
|
+
//# sourceMappingURL=Currency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Currency.js","sourceRoot":"/","sources":["src/hooks/Currency.ts"],"names":[],"mappings":";;;;;AAAA,iCAAiE;AAEjE,yCAA4C;AAC5C,+DAA2D;AAC3D,oFAA4D;AAgB5D,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;;IAC5C,MAAM,EAAE,eAAe,EAAE,GAAG,IAAA,kBAAU,EAAC,yBAAc,CAAC,CAAC;IACvD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,kCAAe,GAAE,CAAC;IAEpC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IACtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAElD,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,OAA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,SAAS,CAAC,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC","sourcesContent":["import { useContext, useEffect, useMemo, useState } from 'react';\n\nimport { CompanyContext } from '@/contexts';\nimport { useCurrentHotel } from '@/hooks/CurrentHotelHook';\nimport CurrencyProvider from '@/providers/CurrencyProvider';\n\nexport interface UseCurrencyProps {\n removeCurrencyAfterChar?: number;\n shortenThousandsAfter?: number;\n\n children: any;\n\n hideDecimals?: boolean;\n\n disableLocalization?: boolean;\n disableLoading?: boolean;\n\n originalCurrencyCode?: string;\n}\n\nconst useCurrency = (props: UseCurrencyProps) => {\n const { currentCurrency } = useContext(CompanyContext);\n const { hotel } = useCurrentHotel();\n\n const [value, setValue] = useState(0);\n const [isLoading, setIsLoading] = useState(false);\n\n const toLocalString = (original: number, toFixed?: boolean) => {\n if (props.disableLocalization) {\n return original;\n }\n\n if (original) {\n return original.toLocaleString(undefined, { minimumFractionDigits: toFixed ? 2 : 0 });\n }\n\n return original;\n };\n\n useEffect(() => {\n let isCancelled = false;\n\n setIsLoading(true);\n setTimeout(\n () => {\n if (!isCancelled) {\n setIsLoading(false);\n\n if (isNaN(props.children)) {\n setValue(props.children);\n } else {\n const totalValue = CurrencyProvider.convertPrice(\n props.children,\n !props.hideDecimals,\n currentCurrency,\n props.originalCurrencyCode ?? (hotel?.defaultCurrency as string)\n );\n\n if (!isCancelled) {\n setValue(totalValue);\n }\n }\n }\n },\n props.disableLoading ? 0 : 200\n );\n\n return () => {\n setIsLoading(false);\n isCancelled = true;\n };\n }, [props.children, currentCurrency, props.originalCurrencyCode, CurrencyProvider.getRatesForCurrencyCode(props.originalCurrencyCode ?? (hotel?.defaultCurrency as string))]);\n\n return useMemo(() => {\n const stringVal = props.disableLocalization ? value.toString() : value?.toLocaleString();\n\n let symbol = CurrencyProvider.getSymbol(currentCurrency);\n if (props.removeCurrencyAfterChar) {\n const priceLength = String(value).length;\n if (priceLength + symbol.length > props.removeCurrencyAfterChar) {\n symbol = CurrencyProvider.getShortSymbol(currentCurrency);\n if (priceLength + symbol.length > props.removeCurrencyAfterChar) {\n symbol = '';\n }\n }\n }\n\n let prettyValue = toLocalString(value, !(props.hideDecimals || typeof value !== 'number'));\n\n if (props.shortenThousandsAfter && props.shortenThousandsAfter <= String(value).length && props.hideDecimals) {\n prettyValue = stringVal.substring(0, stringVal.length - 3) + '…';\n }\n\n return {\n isLoading,\n symbol,\n prettyValue,\n value,\n };\n }, [value, isLoading]);\n};\n\nexport default useCurrency;\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const usePlanpay: () => {
|
|
2
|
+
hasPricePreview: boolean | undefined;
|
|
3
|
+
hasPlanpay: false | {
|
|
4
|
+
username: string;
|
|
5
|
+
minDaysShowPlanpay: number;
|
|
6
|
+
env: string;
|
|
7
|
+
} | undefined;
|
|
8
|
+
planpay: import("@planpay/web").PlanPayComponents;
|
|
9
|
+
planpayConfig: {
|
|
10
|
+
username: string;
|
|
11
|
+
minDaysShowPlanpay: number;
|
|
12
|
+
env: string;
|
|
13
|
+
} | undefined;
|
|
14
|
+
};
|
|
15
|
+
export default usePlanpay;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const web_1 = require("@planpay/web");
|
|
4
|
+
const core_1 = require("@roomstay/core");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const contexts_1 = require("../contexts");
|
|
7
|
+
const CurrentHotelHook_1 = require("./CurrentHotelHook");
|
|
8
|
+
const usePlanpay = () => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const { hotel } = (0, CurrentHotelHook_1.useCurrentHotel)();
|
|
11
|
+
web_1.planpay.init({
|
|
12
|
+
environment: (_a = hotel === null || hotel === void 0 ? void 0 : hotel.planpay) === null || _a === void 0 ? void 0 : _a.env,
|
|
13
|
+
showDebug: false,
|
|
14
|
+
});
|
|
15
|
+
const ccx = (0, react_1.useContext)(contexts_1.CompanyContext);
|
|
16
|
+
const hasPlanpay = ((_b = hotel === null || hotel === void 0 ? void 0 : hotel.paymentMethods) === null || _b === void 0 ? void 0 : _b.includes(core_1.EBookingPaymentMethod.Planpay)) && hotel.planpay;
|
|
17
|
+
return {
|
|
18
|
+
hasPricePreview: hasPlanpay ? ccx.currentCurrency === 'AUD' : undefined,
|
|
19
|
+
hasPlanpay,
|
|
20
|
+
planpay: web_1.planpay,
|
|
21
|
+
planpayConfig: hasPlanpay ? hotel.planpay : undefined,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.default = usePlanpay;
|
|
25
|
+
//# sourceMappingURL=Planpay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Planpay.js","sourceRoot":"/","sources":["src/hooks/Planpay.ts"],"names":[],"mappings":";;AAAA,sCAAuC;AACvC,yCAAuD;AACvD,iCAAmC;AAEnC,yCAA4C;AAC5C,+DAA2D;AAG3D,MAAM,UAAU,GAAG,GAAG,EAAE;;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,kCAAe,GAAE,CAAC;IACpC,aAAO,CAAC,IAAI,CAAC;QACT,WAAW,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,GAAG;QAChC,SAAS,EAAE,KAAK;KACnB,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,yBAAc,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,CAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,0CAAE,QAAQ,CAAC,4BAAqB,CAAC,OAAO,CAAC,KAAI,KAAK,CAAC,OAAO,CAAC;IACnG,OAAO;QACH,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,eAAe,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS;QACvE,UAAU;QACV,OAAO,EAAP,aAAO;QACP,aAAa,EAAE,UAAU,CAAC,CAAC,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;KACnE,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC","sourcesContent":["import { planpay } from '@planpay/web';\nimport { EBookingPaymentMethod } from '@roomstay/core';\nimport { useContext } from 'react';\n\nimport { CompanyContext } from '@/contexts';\nimport { useCurrentHotel } from '@/hooks/CurrentHotelHook';\nimport { Hotel } from '@/models/Client/Hotel/Hotel';\n\nconst usePlanpay = () => {\n const { hotel } = useCurrentHotel();\n planpay.init({\n environment: hotel?.planpay?.env, // environment: 'prod',\n showDebug: false,\n });\n const ccx = useContext(CompanyContext);\n const hasPlanpay = hotel?.paymentMethods?.includes(EBookingPaymentMethod.Planpay) && hotel.planpay;\n return {\n hasPricePreview: hasPlanpay ? ccx.currentCurrency === 'AUD' : undefined,\n hasPlanpay,\n planpay,\n planpayConfig: hasPlanpay ? (hotel as Hotel).planpay : undefined,\n };\n};\n\nexport default usePlanpay;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PlanPayPricePreviewResponse } from '@planpay/web';
|
|
2
|
+
interface UsePlanpayRawPriceProps {
|
|
3
|
+
price?: number;
|
|
4
|
+
checkin?: string;
|
|
5
|
+
currency?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const usePlanpayRawPrice: ({ price: priceProp, checkin: checkinProp, currency: currencyProp }: UsePlanpayRawPriceProps) => PlanPayPricePreviewResponse | undefined;
|
|
8
|
+
export default usePlanpayRawPrice;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const react_1 = require("react");
|
|
16
|
+
const contexts_1 = require("../contexts");
|
|
17
|
+
const Currency_1 = __importDefault(require("./Currency"));
|
|
18
|
+
const Planpay_1 = __importDefault(require("./Planpay"));
|
|
19
|
+
const usePlanpayRawPrice = ({ price: priceProp, checkin: checkinProp, currency: currencyProp }) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const basketContext = (0, contexts_1.useBasket)();
|
|
22
|
+
const { planpay, planpayConfig, hasPlanpay } = (0, Planpay_1.default)();
|
|
23
|
+
const { currentCurrency } = (0, react_1.useContext)(contexts_1.CompanyContext);
|
|
24
|
+
const currency = currencyProp !== null && currencyProp !== void 0 ? currencyProp : currentCurrency;
|
|
25
|
+
const price = basketContext.getTotalPrice() || priceProp;
|
|
26
|
+
const { value } = (0, Currency_1.default)({
|
|
27
|
+
children: price,
|
|
28
|
+
});
|
|
29
|
+
const checkin = checkinProp !== null && checkinProp !== void 0 ? checkinProp : (((_a = basketContext.selectedBasketRow) === null || _a === void 0 ? void 0 : _a.getStartDate()) || basketContext.endDate).format('YYYY-MM-DD');
|
|
30
|
+
const [data, setData] = (0, react_1.useState)(undefined);
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
|
+
if (hasPlanpay && value) {
|
|
33
|
+
const getRawPrice = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const data = yield planpay.pricePreview.fetch({
|
|
35
|
+
totalCost: price,
|
|
36
|
+
merchantId: planpayConfig.username,
|
|
37
|
+
currencyCode: currency,
|
|
38
|
+
redemptionDate: checkin,
|
|
39
|
+
});
|
|
40
|
+
setData(data);
|
|
41
|
+
});
|
|
42
|
+
getRawPrice();
|
|
43
|
+
}
|
|
44
|
+
}, [value, hasPlanpay, currency, price]);
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
exports.default = usePlanpayRawPrice;
|
|
48
|
+
//# sourceMappingURL=usePlanpayRawPrice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePlanpayRawPrice.js","sourceRoot":"/","sources":["src/hooks/usePlanpayRawPrice.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,iCAAwD;AAExD,yCAAuD;AACvD,gEAA2C;AAC3C,8DAAyC;AASzC,MAAM,kBAAkB,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAA2B,EAAE,EAAE;;IACvH,MAAM,aAAa,GAAG,IAAA,oBAAS,GAAE,CAAC;IAClC,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAU,GAAE,CAAC;IAC5D,MAAM,EAAE,eAAe,EAAE,GAAG,IAAA,kBAAU,EAAC,yBAAc,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,eAAe,CAAC;IACjD,MAAM,KAAK,GAAG,aAAa,CAAC,aAAa,EAAE,IAAI,SAAS,CAAC;IACzD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,kBAAW,EAAC;QAC1B,QAAQ,EAAE,KAAK;KAClB,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,CAAC,CAAA,MAAA,aAAa,CAAC,iBAAiB,0CAAE,YAAY,EAAE,KAAI,aAAa,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/H,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAA0C,SAAS,CAAC,CAAC;IAErF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,UAAU,IAAI,KAAK,EAAE;YACrB,MAAM,WAAW,GAAG,GAAS,EAAE;gBAC3B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC;oBAC1C,SAAS,EAAE,KAAK;oBAChB,UAAU,EAAG,aAA4C,CAAC,QAAQ;oBAClE,YAAY,EAAE,QAAQ;oBACtB,cAAc,EAAE,OAAO;iBAC1B,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC,CAAA,CAAC;YACF,WAAW,EAAE,CAAC;SACjB;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC","sourcesContent":["import { PlanPayPricePreviewResponse } from '@planpay/web';\nimport { useContext, useEffect, useState } from 'react';\n\nimport { CompanyContext, useBasket } from '@/contexts';\nimport useCurrency from '@/hooks/Currency';\nimport usePlanpay from '@/hooks/Planpay';\nimport { Hotel } from '@/models/Client/Hotel/Hotel';\n\ninterface UsePlanpayRawPriceProps {\n price?: number;\n checkin?: string;\n currency?: string;\n}\n\nconst usePlanpayRawPrice = ({ price: priceProp, checkin: checkinProp, currency: currencyProp }: UsePlanpayRawPriceProps) => {\n const basketContext = useBasket();\n const { planpay, planpayConfig, hasPlanpay } = usePlanpay();\n const { currentCurrency } = useContext(CompanyContext);\n const currency = currencyProp ?? currentCurrency;\n const price = basketContext.getTotalPrice() || priceProp;\n const { value } = useCurrency({\n children: price,\n });\n const checkin = checkinProp ?? (basketContext.selectedBasketRow?.getStartDate() || basketContext.endDate).format('YYYY-MM-DD');\n const [data, setData] = useState<PlanPayPricePreviewResponse | undefined>(undefined);\n\n useEffect(() => {\n if (hasPlanpay && value) {\n const getRawPrice = async () => {\n const data = await planpay.pricePreview.fetch({\n totalCost: price,\n merchantId: (planpayConfig as Required<Hotel>['planpay']).username,\n currencyCode: currency,\n redemptionDate: checkin,\n });\n setData(data);\n };\n getRawPrice();\n }\n }, [value, hasPlanpay, currency, price]);\n return data;\n};\n\nexport default usePlanpayRawPrice;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EnvironmentName } from '@planpay/web';
|
|
2
2
|
import type { EBookingPaymentMethod } from '@roomstay/core';
|
|
3
3
|
import { DeepPartial } from 'react-hook-form';
|
|
4
4
|
import ColorProfile from '../Client/Hotel/ColorProfile';
|
|
@@ -82,7 +82,7 @@ export type HotelDTO = {
|
|
|
82
82
|
planpay?: {
|
|
83
83
|
username: string;
|
|
84
84
|
minDaysShowPlanpay: number;
|
|
85
|
-
env:
|
|
85
|
+
env: EnvironmentName;
|
|
86
86
|
};
|
|
87
87
|
email?: string;
|
|
88
88
|
hotelUrl?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HotelDTO.js","sourceRoot":"/","sources":["src/models/Api/HotelDTO.ts"],"names":[],"mappings":";;;AAMA,uDAA+D;AAkG/D,IAAY,WAOX;AAPD,WAAY,WAAW;IACnB,4BAAa,CAAA;IACb,wCAAyB,CAAA;IACzB,0BAAW,CAAA;IACX,wCAAyB,CAAA;IACzB,uCAAwB,CAAA;IACxB,oCAAqB,CAAA;AACzB,CAAC,EAPW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAOtB;AAEY,QAAA,0BAA0B,GAAsD;IACzF,CAAC,wBAAgB,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI;IACzC,CAAC,wBAAgB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,UAAU;IACrD,CAAC,wBAAgB,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,GAAG;IACvC,CAAC,wBAAgB,CAAC,eAAe,CAAC,EAAE,WAAW,CAAC,eAAe;IAC/D,CAAC,wBAAgB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,UAAU;IACrD,CAAC,wBAAgB,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,QAAQ;CACpD,CAAC","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"HotelDTO.js","sourceRoot":"/","sources":["src/models/Api/HotelDTO.ts"],"names":[],"mappings":";;;AAMA,uDAA+D;AAkG/D,IAAY,WAOX;AAPD,WAAY,WAAW;IACnB,4BAAa,CAAA;IACb,wCAAyB,CAAA;IACzB,0BAAW,CAAA;IACX,wCAAyB,CAAA;IACzB,uCAAwB,CAAA;IACxB,oCAAqB,CAAA;AACzB,CAAC,EAPW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAOtB;AAEY,QAAA,0BAA0B,GAAsD;IACzF,CAAC,wBAAgB,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI;IACzC,CAAC,wBAAgB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,UAAU;IACrD,CAAC,wBAAgB,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,GAAG;IACvC,CAAC,wBAAgB,CAAC,eAAe,CAAC,EAAE,WAAW,CAAC,eAAe;IAC/D,CAAC,wBAAgB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,UAAU;IACrD,CAAC,wBAAgB,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,QAAQ;CACpD,CAAC","sourcesContent":["import type { EnvironmentName } from '@planpay/web';\nimport type { EBookingPaymentMethod } from '@roomstay/core';\nimport { DeepPartial } from 'react-hook-form';\n\nimport ColorProfile from '@/models/Client/Hotel/ColorProfile';\nimport { DistanceUnitType } from '@/models/Client/Hotel/DistanceUnitType.types';\nimport { EPaymentCardType } from '@/models/Client/Hotel/Hotel';\nimport HotelAddress from '@/models/Client/Hotel/HotelAddress';\nimport { HotelDataSource } from '@/models/Client/Hotel/HotelDataSource.types';\nimport { WeekdayStartsOn } from '@/models/Client/Hotel/WeekdayStartsOn.types';\n\nexport type HotelServiceDTO = {\n detail: string;\n included: boolean;\n name: string;\n onsite: boolean;\n};\n\nexport type HotelRoomsDTO = {\n [roomTypeCode: string]: HotelRoomDTO;\n};\n\nexport type HotelRoomGroupsDTO = {\n groupName: string;\n id: string;\n filters: { [id: string]: { name: string; type: 'select'; includeAllAbove: boolean; options: any } };\n}[];\n\nexport type HotelRoomAmenitiesDTO = {\n type: string;\n description: string;\n};\n\nexport type HotelRoomDTO = {\n code: string;\n name: string;\n shortDescription: string;\n longDescription: string;\n images: string[];\n quantity: number;\n maxOccupancy: number;\n bedQuantity: number;\n standardNumBeds: number;\n maxRollaways: number;\n bedType: string;\n amenities: HotelRoomAmenitiesDTO[];\n features: HotelRoomAmenitiesDTO[];\n bedTypeOverride?: string;\n roomGroupId?: string;\n};\n\nexport type HotelDTO = {\n id: number;\n name: string;\n chainId: number;\n chainName: string;\n\n address: HotelAddress;\n phone: string;\n\n latitude: string;\n longitude: string;\n\n utcOffset: string;\n\n languageCode: string;\n currencyCode: string;\n\n checkInTime: string;\n checkOutTime: string;\n\n paymentCardTypes: EPaymentCardType[];\n\n description: string;\n locationDescription: string;\n policies: string;\n\n hotelServices: HotelServiceDTO[];\n businessServices: HotelServiceDTO[];\n\n rooms: { [roomTypeCode: string]: HotelRoomDTO };\n dataSource: HotelDataSource;\n\n // Following fields are only present if dataSource = 'roomstay'\n logo?: string;\n colors: DeepPartial<ColorProfile>;\n distanceUnitType?: DistanceUnitType;\n weekdayStartsOn?: WeekdayStartsOn;\n\n crossSellHotelIds?: string[];\n paymentMethods: EBookingPaymentMethod[];\n planpay?: {\n username: string;\n minDaysShowPlanpay: number;\n env: EnvironmentName;\n };\n\n email?: string;\n hotelUrl?: string;\n heroImage?: string;\n images?: string[];\n roomGroups: HotelRoomGroupsDTO;\n};\n\nexport enum VGSCardName {\n Visa = 'visa',\n Mastercard = 'mastercard',\n JCB = 'jcb',\n DinersClub = 'dinersclub',\n AmericanExpress = 'amex',\n UnionPay = 'unionpay',\n}\n\nexport const SynxisToVGSCardNameMapping: { [synxisName in EPaymentCardType]: VGSCardName } = {\n [EPaymentCardType.Visa]: VGSCardName.Visa,\n [EPaymentCardType.Mastercard]: VGSCardName.Mastercard,\n [EPaymentCardType.JCB]: VGSCardName.JCB,\n [EPaymentCardType.AmericanExpress]: VGSCardName.AmericanExpress,\n [EPaymentCardType.DinersClub]: VGSCardName.DinersClub,\n [EPaymentCardType.UnionPay]: VGSCardName.UnionPay,\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EnvironmentName } from '@planpay/web';
|
|
2
2
|
import { EBookingPaymentMethod, IHotelColorScheme } from '@roomstay/core';
|
|
3
3
|
import type { ReactChild } from 'react';
|
|
4
4
|
import type { MemberOnlyModalInputs } from '../../../components/steps/room/MemberSignInModal/MemberSignInModal.types';
|
|
@@ -51,7 +51,7 @@ export interface AdminHotelConfig {
|
|
|
51
51
|
planpay?: {
|
|
52
52
|
username: string;
|
|
53
53
|
minDaysShowPlanpay: number;
|
|
54
|
-
env:
|
|
54
|
+
env: EnvironmentName;
|
|
55
55
|
};
|
|
56
56
|
hotelUrl: string;
|
|
57
57
|
heroImage: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hotel.js","sourceRoot":"/","sources":["src/models/Client/Hotel/Hotel.ts"],"names":[],"mappings":";;;AAgBA,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IACxB,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,8BAAU,CAAA;IACV,0CAAsB,CAAA;IACtB,qCAAiB,CAAA;IACjB,mCAAe,CAAA;AACnB,CAAC,EAPW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAO3B","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"Hotel.js","sourceRoot":"/","sources":["src/models/Client/Hotel/Hotel.ts"],"names":[],"mappings":";;;AAgBA,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IACxB,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,8BAAU,CAAA;IACV,0CAAsB,CAAA;IACtB,qCAAiB,CAAA;IACjB,mCAAe,CAAA;AACnB,CAAC,EAPW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAO3B","sourcesContent":["import type { EnvironmentName } from '@planpay/web';\nimport { EBookingPaymentMethod, IHotelColorScheme } from '@roomstay/core';\nimport type { ReactChild } from 'react';\n\nimport type { MemberOnlyModalInputs } from '@/components/steps/room/MemberSignInModal/MemberSignInModal.types';\nimport type { HotelRoomGroupsDTO, HotelRoomsDTO, HotelServiceDTO } from '@/models/Api/HotelDTO';\nimport type { TransportDistances } from '@/models/Api/HotelOverrideDTO';\nimport type { HasDatalayerTags } from '@/models/Client/Hotel/Company';\nimport type { DistanceUnitType } from '@/models/Client/Hotel/DistanceUnitType.types';\nimport type HotelAddress from '@/models/Client/Hotel/HotelAddress';\nimport type { HotelDataSource } from '@/models/Client/Hotel/HotelDataSource.types';\nimport type { HotelPerk } from '@/models/Client/Hotel/HotelPerk';\nimport type { HotelRoomOverwrite } from '@/models/Client/Hotel/HotelRoomOverwrite';\nimport type { WeekdayStartsOn } from '@/models/Client/Hotel/WeekdayStartsOn.types';\nimport type { Language } from '@/providers/LanguageProvider';\n\nexport enum EPaymentCardType {\n Visa = 'VI',\n Mastercard = 'MC',\n JCB = 'JC',\n AmericanExpress = 'AX',\n DinersClub = 'DN',\n UnionPay = 'UP',\n}\n\nexport interface IVGSVaultNames {\n standard: string;\n members: string;\n}\n\n/**\n * This config comes from admin\n */\nexport interface AdminHotelConfig {\n hotelID: string;\n name: string;\n address?: HotelAddress;\n latitude?: number;\n longitude?: number;\n phone?: string;\n email?: string;\n checkInTime?: string;\n checkOutTime?: string;\n paymentCardTypes?: EPaymentCardType[];\n description?: string;\n locationDescription?: string;\n policies?: string;\n hotelServices: HotelServiceDTO[];\n businessServices: HotelServiceDTO[];\n rooms: HotelRoomsDTO;\n hasLoadedDetails?: boolean;\n dataSource: HotelDataSource;\n defaultCurrency: string;\n paymentMethods: EBookingPaymentMethod[];\n planpay?: {\n username: string;\n minDaysShowPlanpay: number;\n env: EnvironmentName;\n };\n hotelUrl: string;\n heroImage: string;\n memberOnlyModalImage?: string;\n images?: string[];\n logo: string | ReactChild;\n colors: IHotelColorScheme;\n distanceUnitType: DistanceUnitType;\n startsWeekOnDay?: WeekdayStartsOn;\n crossSellHotelIds?: string[];\n maxOccupancy?: number;\n hideByLine?: boolean;\n transportDistances?: TransportDistances;\n\n roomGroups: HotelRoomGroupsDTO;\n}\n\nexport interface ClientHotelConfig {\n providerHotelID: string;\n shortName?: string;\n defaultDatepickerType?: 'Month' | 'Week';\n // TODO: need to do magic to see if we need to append / prepend stuff, for now we assume that it's only used while on the site.\n checkoutUrl?: string;\n defaultLanguage: Language;\n privacyPolicyUrl: string;\n bookNowPayLaterUrl?: string;\n bestRateNoBSUrl?: string;\n\n memberOnlyRates?: string[];\n memberOnlyPromoCode?: string;\n memberOnlySignupInputs?: MemberOnlyModalInputs;\n googleMapsImage?: string;\n /**\n * Wether to show the Breakfast / Lunch / Dinner included\n */\n showMealPill?: boolean;\n /**\n * Distances for the Summary, and Hotel Info pages\n */\n perks: HotelPerk[];\n\n /** @deprecated Use the vgs.vaultNames.standard property now */\n vgsVaultName?: string;\n\n vgs?: {\n vaultNames: IVGSVaultNames;\n };\n\n showAddonLoader: boolean;\n overwrites?: { [code: string]: Partial<HotelRoomOverwrite> };\n forwardFindReservationToSynxis?: boolean;\n additionalOptions?: { [name: string]: any };\n googleReCaptcha?: {\n loadForMembers?: boolean;\n siteKey?: string;\n };\n\n /**\n * Customize the Member modal colours. Specifically replacing the green (success) with the primary color of hotel (accent)\n */\n memberOnlyModalUsePrimaryColor?: boolean;\n /**\n * Callback to trigger specific events on load of a hotel.\n *\n * This is where you can specify custom fields, language overrides, feature toggles etc.\n */\n onLoad?: () => void;\n}\n\nexport interface ConfigHotel extends ClientHotelConfig, AdminHotelConfig, HasDatalayerTags {}\n\nexport type Hotel = ConfigHotel & {\n lowestPrice?: {\n value: number;\n isLoading: boolean;\n };\n};\n\n/**\n * Used for DetailsHotel event\n */\nexport type InitialHotelDetailsEventPayload = {\n name: string;\n hotelID: number | string;\n hotelUrl: string;\n currency: string;\n language: Language;\n address?: HotelAddress;\n};\n"]}
|
|
@@ -70,7 +70,7 @@ function StepThanksComponent() {
|
|
|
70
70
|
priceCurrency: ccx.currentCurrency,
|
|
71
71
|
};
|
|
72
72
|
});
|
|
73
|
-
const event = new events_1.StepThanksViewEvent(reservations);
|
|
73
|
+
const event = new events_1.StepThanksViewEvent(reservations, basketContext.currentBasketRows);
|
|
74
74
|
raise(event);
|
|
75
75
|
return (0, TotalCalculator_1.calculateTotalForReservation)(checkoutData, !isFromRoomstay);
|
|
76
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepThanksComponent.js","sourceRoot":"/","sources":["src/pages/steps/StepThanks/StepThanksComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmE;AACnE,2CAA4D;AAC5D,kDAA0B;AAC1B,+CAAkE;AAClE,iDAA+C;AAC/C,uDAAwC;AACxC,0DAAuD;AAEvD,6EAAqD;AACrD,6EAAqD;AACrD,6EAAqD;AACrD,uEAAgE;AAChE,+EAAuD;AACvD,kEAA2D;AAC3D,wGAAqG;AACrG,qCAA+C;AAG/C,4FAAoE;AACpE,wCAAqC;AACrC,wDAAiD;AACjD,4DAAsE;AAEtE,SAAwB,mBAAmB;;IACvC,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,wBAAa,CAAC,CAAC;IAEhD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,uBAAe,GAAE,CAAC;IACpC,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,yBAAc,CAAC,CAAC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IAAA,eAAK,EAAC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAEvE,OAAO,CACH,0CAAQ,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,qBAAqB,IACzC,IAAI,CAAC,SAAS,CAAC;gBACZ,UAAU,EAAE,mBAAmB;gBAC/B,OAAO,EAAE,oBAAoB;gBAC7B,aAAa,EAAE,GAAG,CAAC,iBAAiB;gBACpC,iBAAiB,EAAE,wCAAwC;gBAC3D,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,qBAAqB,CAAC;gBACrD,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,qBAAqB,CAAC;gBACrD,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ;gBAC9B,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS;gBAC9B,aAAa,EAAE,GAAG,CAAC,eAAe;aACrC,CAAC,CACG,CACZ,CAAC;QACN,CAAC,CAAC,CACA,CACT,CAAC;AACN,CAAC;AA1JD,sCA0JC","sourcesContent":["import { BasketContext, CompanyContext } from '@frontend/contexts';\nimport { useCurrentHotel, useEvent } from '@frontend/hooks';\nimport dayjs from 'dayjs';\nimport React, { useCallback, useContext, useEffect } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Link } from 'react-router-dom';\nimport { Translation } from 'translations/Translation';\n\nimport BEButton from '@/components/generic/BEButton';\nimport Currency from '@/components/generic/Currency';\nimport Headline from '@/components/generic/Headline';\nimport Icon, { IconType } from '@/components/generic/Icon/Icon';\nimport LineBreak from '@/components/generic/LineBreak';\nimport Text, { TextType } from '@/components/generic/Text';\nimport { CommonAddonSummary } from '@/components/steps/common/CommonAddonSummary/CommonAddonSummary';\nimport { StepThanksViewEvent } from '@/events';\nimport { IEventReservation } from '@/models/Api/IEventReservation';\nimport { ReservationAddonDTO, ReservationDTO } from '@/models/Api/ReservationsDTO';\nimport ReservationRow from '@/pages/findReservation/ReservationRow';\nimport { Color } from '@/util/Color';\nimport { TextAlign } from '@/util/TextAlignment';\nimport { calculateTotalForReservation } from '@/util/TotalCalculator';\n\nexport default function StepThanksComponent() {\n const basketContext = useContext(BasketContext);\n\n const { hotel } = useCurrentHotel();\n const ccx = useContext(CompanyContext);\n const { raise } = useEvent();\n\n const checkoutData = basketContext.reservationData;\n\n const isFromRoomstay = checkoutData?.itineraryNumber?.startsWith('RS');\n\n const { t } = useTranslation();\n\n const total = useCallback(() => {\n if (checkoutData?.reservations) {\n const reservations: IEventReservation[] = checkoutData?.reservations?.map((obj: ReservationDTO) => {\n const nightKeys = Object.keys(obj.nights);\n const dateFormat = 'YYYY-MM-DDTHH:mm:ss';\n\n return {\n reservationId: obj.reservationNumber,\n checkInTime: dayjs(nightKeys[0]).format(dateFormat),\n checkOutTime: dayjs(nightKeys[nightKeys.length - 1])\n .add(1, 'day')\n .format(dateFormat),\n totalPrice: obj.total.afterTax,\n priceCurrency: ccx.currentCurrency,\n };\n });\n\n const event = new StepThanksViewEvent(reservations);\n raise(event);\n\n return calculateTotalForReservation(checkoutData, !isFromRoomstay);\n }\n\n return 0;\n }, [checkoutData]);\n\n const addons: ReservationAddonDTO[] = [];\n const comments: string[] = [];\n\n useEffect(() => {\n return () => {\n basketContext.finish();\n };\n }, []);\n\n return (\n <div className=\"container u-marg-top--heavy\">\n <div className=\"row justify-content-center\">\n <div className=\"col-lg-8 col-md-12 u-flex align-items-center u-flex-direction-column\">\n <div className=\"u-marg-bottom\">\n <Icon icon={IconType.Check} size=\"48px\" color={Color.White} backgroundColor={Color.Accent} borderRadius=\"round\" noPadding />\n </div>\n <div className=\"u-marg-bottom\" style={{ maxWidth: '530px' }}>\n <Headline size=\"large\" align={TextAlign.Center}>\n {t(Translation.Step.Thanks.ThankYouHeadline, { hotel: hotel?.name })}\n </Headline>\n </div>\n <div className=\"u-marg-bottom--heavy\">\n <Text color={Color.DarkGrey}>\n {t(Translation.Step.Thanks.InvoiceNumber)} {checkoutData.itineraryNumber}\n </Text>\n </div>\n <div className=\"u-marg-bottom--massive\">\n <Link to=\"/\">\n <BEButton>{t(Translation.Step.Thanks.GoBackHome)}</BEButton>\n </Link>\n </div>\n <>\n <div className=\"u-marg-top w-100\">\n {checkoutData?.reservations?.map((obj: ReservationDTO) => {\n if (obj.addons) {\n const nights = Object.keys(obj.nights);\n obj.addons.forEach((addon) => {\n if (isFromRoomstay) {\n addons.push({ ...addon, nights: nights.length });\n } else {\n addons.push(addon);\n }\n });\n }\n\n if (obj.comments) {\n obj.comments.map((comment: string) => {\n comments.push(comment);\n });\n }\n\n return <ReservationRow reservation={obj} key={obj.reservationNumber} />;\n })}\n </div>\n <LineBreak />\n\n <div className=\"w-100\">\n <CommonAddonSummary addons={addons} />\n {comments.length >= 1 && (\n <div className=\"u-marg-bottom--heavy\">\n <div className=\"u-marg-bottom\">\n <Text type={TextType.Label} color={Color.Grey}>\n {t(Translation.Step.Confirmation.Comments)}\n </Text>\n </div>\n {comments.map((comment, index) => (\n <Text\n style={{\n whiteSpace: 'pre',\n }}\n key={index}\n type={TextType.Small}\n >\n {comment}\n </Text>\n ))}\n </div>\n )}\n <Text type={TextType.Small} align={TextAlign.Right}>\n {t(Translation.Misc.Total)}\n </Text>\n <Headline bold size=\"large\" align={TextAlign.Right}>\n <Currency>{total}</Currency>\n </Headline>\n <Text type={TextType.Small} align={TextAlign.Right} color={Color.DarkGrey}>\n {t(Translation.Step.Thanks.IncludingTaxes)}\n </Text>\n </div>\n </>\n </div>\n </div>\n {checkoutData?.reservations?.map((obj: ReservationDTO, index) => {\n const nightKeys = Object.keys(obj.nights);\n\n const firstNight = dayjs(nightKeys[0]);\n const lastNight = dayjs(nightKeys[nightKeys.length - 1]).add(1, 'day');\n\n return (\n <script key={index} type=\"application/ld+json\">\n {JSON.stringify({\n '@context': 'http://schema.org',\n '@type': 'LodgingReservation',\n reservationId: obj.reservationNumber,\n reservationStatus: 'http://schema.org/ReservationConfirmed',\n checkinTime: firstNight.format('YYYY-MM-DDTHH:mm:ss'),\n checkoutTime: lastNight.format('YYYY-MM-DDTHH:mm:ss'),\n totalPrice: obj.total.afterTax,\n basePrice: obj.total.beforeTax,\n priceCurrency: ccx.currentCurrency,\n })}\n </script>\n );\n })}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"StepThanksComponent.js","sourceRoot":"/","sources":["src/pages/steps/StepThanks/StepThanksComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmE;AACnE,2CAA4D;AAC5D,kDAA0B;AAC1B,+CAAkE;AAClE,iDAA+C;AAC/C,uDAAwC;AACxC,0DAAuD;AAEvD,6EAAqD;AACrD,6EAAqD;AACrD,6EAAqD;AACrD,uEAAgE;AAChE,+EAAuD;AACvD,kEAA2D;AAC3D,wGAAqG;AACrG,qCAA+C;AAG/C,4FAAoE;AACpE,wCAAqC;AACrC,wDAAiD;AACjD,4DAAsE;AAEtE,SAAwB,mBAAmB;;IACvC,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,wBAAa,CAAC,CAAC;IAEhD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,uBAAe,GAAE,CAAC;IACpC,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,yBAAc,CAAC,CAAC;IACvC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,gBAAQ,GAAE,CAAC;IAE7B,MAAM,YAAY,GAAG,aAAa,CAAC,eAAe,CAAC;IAEnD,MAAM,cAAc,GAAG,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,eAAe,0CAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAEvE,MAAM,EAAE,CAAC,EAAE,GAAG,IAAA,8BAAc,GAAE,CAAC;IAE/B,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;;QAC3B,IAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,YAAY,E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AAM,CAAC,qBAAqB,CAAC;gBACrD,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,qBAAqB,CAAC;gBACrD,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ;gBAC9B,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS;gBAC9B,aAAa,EAAE,GAAG,CAAC,eAAe;aACrC,CAAC,CACG,CACZ,CAAC;QACN,CAAC,CAAC,CACA,CACT,CAAC;AACN,CAAC;AAzJD,sCAyJC","sourcesContent":["import { BasketContext, CompanyContext } from '@frontend/contexts';\nimport { useCurrentHotel, useEvent } from '@frontend/hooks';\nimport dayjs from 'dayjs';\nimport React, { useCallback, useContext, useEffect } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Link } from 'react-router-dom';\nimport { Translation } from 'translations/Translation';\n\nimport BEButton from '@/components/generic/BEButton';\nimport Currency from '@/components/generic/Currency';\nimport Headline from '@/components/generic/Headline';\nimport Icon, { IconType } from '@/components/generic/Icon/Icon';\nimport LineBreak from '@/components/generic/LineBreak';\nimport Text, { TextType } from '@/components/generic/Text';\nimport { CommonAddonSummary } from '@/components/steps/common/CommonAddonSummary/CommonAddonSummary';\nimport { StepThanksViewEvent } from '@/events';\nimport { IEventReservation } from '@/models/Api/IEventReservation';\nimport { ReservationAddonDTO, ReservationDTO } from '@/models/Api/ReservationsDTO';\nimport ReservationRow from '@/pages/findReservation/ReservationRow';\nimport { Color } from '@/util/Color';\nimport { TextAlign } from '@/util/TextAlignment';\nimport { calculateTotalForReservation } from '@/util/TotalCalculator';\n\nexport default function StepThanksComponent() {\n const basketContext = useContext(BasketContext);\n\n const { hotel } = useCurrentHotel();\n const ccx = useContext(CompanyContext);\n const { raise } = useEvent();\n\n const checkoutData = basketContext.reservationData;\n\n const isFromRoomstay = checkoutData?.itineraryNumber?.startsWith('RS');\n\n const { t } = useTranslation();\n\n const total = useCallback(() => {\n if (checkoutData?.reservations) {\n const reservations: IEventReservation[] = checkoutData?.reservations?.map((obj: ReservationDTO) => {\n const nightKeys = Object.keys(obj.nights);\n const dateFormat = 'YYYY-MM-DDTHH:mm:ss';\n\n return {\n reservationId: obj.reservationNumber,\n checkInTime: dayjs(nightKeys[0]).format(dateFormat),\n checkOutTime: dayjs(nightKeys[nightKeys.length - 1])\n .add(1, 'day')\n .format(dateFormat),\n totalPrice: obj.total.afterTax,\n priceCurrency: ccx.currentCurrency,\n };\n });\n const event = new StepThanksViewEvent(reservations, basketContext.currentBasketRows);\n raise(event);\n\n return calculateTotalForReservation(checkoutData, !isFromRoomstay);\n }\n\n return 0;\n }, [checkoutData]);\n\n const addons: ReservationAddonDTO[] = [];\n const comments: string[] = [];\n\n useEffect(() => {\n return () => {\n basketContext.finish();\n };\n }, []);\n\n return (\n <div className=\"container u-marg-top--heavy\">\n <div className=\"row justify-content-center\">\n <div className=\"col-lg-8 col-md-12 u-flex align-items-center u-flex-direction-column\">\n <div className=\"u-marg-bottom\">\n <Icon icon={IconType.Check} size=\"48px\" color={Color.White} backgroundColor={Color.Accent} borderRadius=\"round\" noPadding />\n </div>\n <div className=\"u-marg-bottom\" style={{ maxWidth: '530px' }}>\n <Headline size=\"large\" align={TextAlign.Center}>\n {t(Translation.Step.Thanks.ThankYouHeadline, { hotel: hotel?.name })}\n </Headline>\n </div>\n <div className=\"u-marg-bottom--heavy\">\n <Text color={Color.DarkGrey}>\n {t(Translation.Step.Thanks.InvoiceNumber)} {checkoutData.itineraryNumber}\n </Text>\n </div>\n <div className=\"u-marg-bottom--massive\">\n <Link to=\"/\">\n <BEButton>{t(Translation.Step.Thanks.GoBackHome)}</BEButton>\n </Link>\n </div>\n <>\n <div className=\"u-marg-top w-100\">\n {checkoutData?.reservations?.map((obj: ReservationDTO) => {\n if (obj.addons) {\n const nights = Object.keys(obj.nights);\n obj.addons.forEach((addon) => {\n if (isFromRoomstay) {\n addons.push({ ...addon, nights: nights.length });\n } else {\n addons.push(addon);\n }\n });\n }\n\n if (obj.comments) {\n obj.comments.map((comment: string) => {\n comments.push(comment);\n });\n }\n\n return <ReservationRow reservation={obj} key={obj.reservationNumber} />;\n })}\n </div>\n <LineBreak />\n\n <div className=\"w-100\">\n <CommonAddonSummary addons={addons} />\n {comments.length >= 1 && (\n <div className=\"u-marg-bottom--heavy\">\n <div className=\"u-marg-bottom\">\n <Text type={TextType.Label} color={Color.Grey}>\n {t(Translation.Step.Confirmation.Comments)}\n </Text>\n </div>\n {comments.map((comment, index) => (\n <Text\n style={{\n whiteSpace: 'pre',\n }}\n key={index}\n type={TextType.Small}\n >\n {comment}\n </Text>\n ))}\n </div>\n )}\n <Text type={TextType.Small} align={TextAlign.Right}>\n {t(Translation.Misc.Total)}\n </Text>\n <Headline bold size=\"large\" align={TextAlign.Right}>\n <Currency>{total}</Currency>\n </Headline>\n <Text type={TextType.Small} align={TextAlign.Right} color={Color.DarkGrey}>\n {t(Translation.Step.Thanks.IncludingTaxes)}\n </Text>\n </div>\n </>\n </div>\n </div>\n {checkoutData?.reservations?.map((obj: ReservationDTO, index) => {\n const nightKeys = Object.keys(obj.nights);\n\n const firstNight = dayjs(nightKeys[0]);\n const lastNight = dayjs(nightKeys[nightKeys.length - 1]).add(1, 'day');\n\n return (\n <script key={index} type=\"application/ld+json\">\n {JSON.stringify({\n '@context': 'http://schema.org',\n '@type': 'LodgingReservation',\n reservationId: obj.reservationNumber,\n reservationStatus: 'http://schema.org/ReservationConfirmed',\n checkinTime: firstNight.format('YYYY-MM-DDTHH:mm:ss'),\n checkoutTime: lastNight.format('YYYY-MM-DDTHH:mm:ss'),\n totalPrice: obj.total.afterTax,\n basePrice: obj.total.beforeTax,\n priceCurrency: ccx.currentCurrency,\n })}\n </script>\n );\n })}\n </div>\n );\n}\n"]}
|