@roomstay/frontend 2.5.20 → 2.5.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/468.bundle.js +1 -1
- package/dist/572.bundle.js +1 -1
- package/dist/main.bundle.js +1 -1
- package/dist/src/components/generic/PlanpayPrice/PlanpayPrice.js +7 -3
- package/dist/src/components/generic/PlanpayPrice/PlanpayPrice.js.map +1 -1
- package/dist/src/hooks/Planpay.d.ts +1 -0
- package/dist/src/hooks/Planpay.js +10 -1
- package/dist/src/hooks/Planpay.js.map +1 -1
- package/dist/test.bundle.js +1 -1
- package/dist/vendors.bundle.js +1 -1
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.PlanpayPrice = void 0;
|
|
30
|
+
const contexts_1 = require("../../../contexts/index.js");
|
|
30
31
|
const hooks_1 = require("../../../hooks/index.js");
|
|
31
32
|
const web_1 = require("@planpay/web");
|
|
32
33
|
const react_1 = __importStar(require("react"));
|
|
@@ -37,9 +38,10 @@ const debounceReload = (0, Debounce_1.debounce)(() => {
|
|
|
37
38
|
web_1.planpay.pricePreview.refresh({});
|
|
38
39
|
}, 150);
|
|
39
40
|
const PlanpayPrice = ({ price, checkin, currency }) => {
|
|
40
|
-
var _a;
|
|
41
|
+
var _a, _b, _c;
|
|
41
42
|
const { hotel } = (0, hooks_1.useCurrentHotel)();
|
|
42
|
-
const { hasPlanpay, loadPlanPaySDK } = (0, Planpay_1.default)();
|
|
43
|
+
const { hasPlanpay, loadPlanPaySDK, shouldShowPlanpay } = (0, Planpay_1.default)();
|
|
44
|
+
const { selectedBasketRow } = (0, react_1.useContext)(contexts_1.BasketContext);
|
|
43
45
|
(0, react_1.useEffect)(() => {
|
|
44
46
|
if (hasPlanpay) {
|
|
45
47
|
loadPlanPaySDK();
|
|
@@ -54,7 +56,9 @@ const PlanpayPrice = ({ price, checkin, currency }) => {
|
|
|
54
56
|
return null;
|
|
55
57
|
if (!(hotel === null || hotel === void 0 ? void 0 : hotel.planpay))
|
|
56
58
|
return null;
|
|
57
|
-
|
|
59
|
+
if (!shouldShowPlanpay((_b = (_a = selectedBasketRow === null || selectedBasketRow === void 0 ? void 0 : selectedBasketRow.getStartDate()) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''))
|
|
60
|
+
return null;
|
|
61
|
+
return (react_1.default.createElement("div", { style: { whiteSpace: 'nowrap', marginRight: -16, marginTop: -10, marginBottom: -8, marginLeft: -12 }, "data-planpay-data-type": "price-preview", "data-planpay-total-cost": price, "data-planpay-currency-code": currency, "data-planpay-redemption-date": checkin, "data-planpay-payment-deadline": "0", "data-planpay-total-minimum-deposit": "0", "data-planpay-merchant-id": (_c = hotel === null || hotel === void 0 ? void 0 : hotel.planpay) === null || _c === void 0 ? void 0 : _c.username, "data-planpay-size": "x-small", "data-planpay-variant": "text" }));
|
|
58
62
|
};
|
|
59
63
|
exports.PlanpayPrice = PlanpayPrice;
|
|
60
64
|
//# sourceMappingURL=PlanpayPrice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanpayPrice.js","sourceRoot":"/","sources":["src/components/generic/PlanpayPrice/PlanpayPrice.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAkD;AAClD,sCAAuC;AACvC,+
|
|
1
|
+
{"version":3,"file":"PlanpayPrice.js","sourceRoot":"/","sources":["src/components/generic/PlanpayPrice/PlanpayPrice.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmD;AACnD,2CAAkD;AAClD,sCAAuC;AACvC,+CAA4E;AAE5E,8DAAyC;AACzC,gHAAwF;AACxF,8CAA2C;AAE3C,MAAM,cAAc,GAAG,IAAA,mBAAQ,EAAC,GAAG,EAAE;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AE,4BAC7E,eAAe,6BACb,KAAK,gCACF,QAAQ,kCACN,OAAO,mCACP,GAAG,wCACE,GAAG,8BACZ,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,QAAQ,uBAChC,SAAS,0BACN,MAAM,GAC7B,CACL,CAAC;AACN,CAAC,CAAC;AArCW,QAAA,YAAY,gBAqCvB","sourcesContent":["import { BasketContext } from '@frontend/contexts';\nimport { useCurrentHotel } from '@frontend/hooks';\nimport { planpay } from '@planpay/web';\nimport React, { FC, PropsWithChildren, useContext, useEffect } from 'react';\n\nimport usePlanpay from '@/hooks/Planpay';\nimport PlanPayPricePreviewFeature from '@/providers/feature/PlanPayPricePreviewFeature';\nimport { debounce } from '@/util/Debounce';\n\nconst debounceReload = debounce(() => {\n planpay.pricePreview.refresh({});\n}, 150);\n\nexport interface PlanpayPriceProps extends PropsWithChildren<any> {\n price: number;\n checkin: string;\n currency: string;\n}\n\nexport const PlanpayPrice: FC<PlanpayPriceProps> = ({ price, checkin, currency }) => {\n const { hotel } = useCurrentHotel();\n const { hasPlanpay, loadPlanPaySDK, shouldShowPlanpay } = usePlanpay();\n const { selectedBasketRow } = useContext(BasketContext);\n\n useEffect(() => {\n if (hasPlanpay) {\n loadPlanPaySDK();\n }\n }, [hasPlanpay]);\n\n useEffect(() => {\n if (hasPlanpay) {\n debounceReload();\n }\n }, [price, currency, checkin]);\n\n if (!PlanPayPricePreviewFeature.isActive()) return null;\n\n if (!hotel?.planpay) return null;\n\n if (!shouldShowPlanpay(selectedBasketRow?.getStartDate()?.toString() ?? '')) return null;\n\n return (\n <div\n style={{ whiteSpace: 'nowrap', marginRight: -16, marginTop: -10, marginBottom: -8, marginLeft: -12 }}\n data-planpay-data-type=\"price-preview\"\n data-planpay-total-cost={price}\n data-planpay-currency-code={currency}\n data-planpay-redemption-date={checkin}\n data-planpay-payment-deadline=\"0\"\n data-planpay-total-minimum-deposit=\"0\"\n data-planpay-merchant-id={hotel?.planpay?.username}\n data-planpay-size=\"x-small\"\n data-planpay-variant=\"text\"\n />\n );\n};\n"]}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const web_1 = require("@planpay/web");
|
|
4
7
|
const core_1 = require("@roomstay/core");
|
|
8
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
5
9
|
const react_1 = require("react");
|
|
6
10
|
const contexts_1 = require("../contexts");
|
|
7
11
|
const CurrentHotelHook_1 = require("./CurrentHotelHook");
|
|
@@ -20,11 +24,16 @@ const usePlanpay = () => {
|
|
|
20
24
|
const { hotel } = (0, CurrentHotelHook_1.useCurrentHotel)();
|
|
21
25
|
const ccx = (0, react_1.useContext)(contexts_1.CompanyContext);
|
|
22
26
|
const hasPlanpay = !!(((_a = hotel === null || hotel === void 0 ? void 0 : hotel.paymentMethods) === null || _a === void 0 ? void 0 : _a.includes(core_1.EBookingPaymentMethod.Planpay)) && hotel.planpay);
|
|
27
|
+
const planpayConfig = hasPlanpay ? hotel.planpay : undefined;
|
|
28
|
+
const shouldShowPlanpay = (startDate) => {
|
|
29
|
+
return planpayConfig && planpayConfig.minDaysShowPlanpay && (0, dayjs_1.default)(startDate).diff((0, dayjs_1.default)(), 'day') > planpayConfig.minDaysShowPlanpay;
|
|
30
|
+
};
|
|
23
31
|
return {
|
|
24
32
|
hasPricePreview: hasPlanpay ? ccx.currentCurrency === 'AUD' : undefined,
|
|
25
33
|
hasPlanpay,
|
|
26
34
|
planpay: web_1.planpay,
|
|
27
|
-
planpayConfig
|
|
35
|
+
planpayConfig,
|
|
36
|
+
shouldShowPlanpay,
|
|
28
37
|
loadPlanPaySDK: () => {
|
|
29
38
|
var _a;
|
|
30
39
|
loadPlanpayOnce((_a = hotel === null || hotel === void 0 ? void 0 : hotel.planpay) === null || _a === void 0 ? void 0 : _a.env);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Planpay.js","sourceRoot":"/","sources":["src/hooks/Planpay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Planpay.js","sourceRoot":"/","sources":["src/hooks/Planpay.ts"],"names":[],"mappings":";;;;;AAAA,sCAAuC;AACvC,yCAAuD;AACvD,kDAA0B;AAC1B,iCAAmC;AAEnC,yCAA4C;AAC5C,+DAA2D;AAG3D,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAC7B,MAAM,eAAe,GAAG,CAAC,WAAW,GAAG,MAAM,EAAE,EAAE;IAC7C,IAAI,gBAAgB;QAAE,OAAO;IAE7B,aAAO,CAAC,IAAI,CAAC;QACT,WAAW;QACX,SAAS,EAAE,KAAK;KACnB,CAAC,CAAC;IAEH,gBAAgB,GAAG,IAAI,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,GAAG,EAAE;;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,kCAAe,GAAE,CAAC;IAEpC,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,yBAAc,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC,CAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,0CAAE,QAAQ,CAAC,4BAAqB,CAAC,OAAO,CAAC,KAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAEvG,MAAM,aAAa,GAAG,UAAU,CAAC,CAAC,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IAExE,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE;QAC5C,OAAO,aAAa,IAAI,aAAa,CAAC,kBAAkB,IAAI,IAAA,eAAK,EAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAA,eAAK,GAAE,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,kBAAkB,CAAC;IACzI,CAAC,CAAC;IAEF,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;QACb,iBAAiB;QACjB,cAAc,EAAE,GAAG,EAAE;;YACjB,eAAe,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,GAAG,CAAC,CAAC;QACzC,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC","sourcesContent":["import { planpay } from '@planpay/web';\nimport { EBookingPaymentMethod } from '@roomstay/core';\nimport dayjs from 'dayjs';\nimport { useContext } from 'react';\n\nimport { CompanyContext } from '@/contexts';\nimport { useCurrentHotel } from '@/hooks/CurrentHotelHook';\nimport { Hotel } from '@/models/Client/Hotel/Hotel';\n\nlet planpaySdkLoaded = false;\nconst loadPlanpayOnce = (environment = 'prod') => {\n if (planpaySdkLoaded) return;\n\n planpay.init({\n environment,\n showDebug: false,\n });\n\n planpaySdkLoaded = true;\n};\n\nconst usePlanpay = () => {\n const { hotel } = useCurrentHotel();\n\n const ccx = useContext(CompanyContext);\n const hasPlanpay = !!(hotel?.paymentMethods?.includes(EBookingPaymentMethod.Planpay) && hotel.planpay);\n\n const planpayConfig = hasPlanpay ? (hotel as Hotel).planpay : undefined;\n\n const shouldShowPlanpay = (startDate: string) => {\n return planpayConfig && planpayConfig.minDaysShowPlanpay && dayjs(startDate).diff(dayjs(), 'day') > planpayConfig.minDaysShowPlanpay;\n };\n\n return {\n hasPricePreview: hasPlanpay ? ccx.currentCurrency === 'AUD' : undefined,\n hasPlanpay,\n planpay,\n planpayConfig,\n shouldShowPlanpay,\n loadPlanPaySDK: () => {\n loadPlanpayOnce(hotel?.planpay?.env);\n },\n };\n};\n\nexport default usePlanpay;\n"]}
|