ublo-lib 1.19.4 → 1.19.5
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/es/esf/components/magic-box/index.d.ts +3 -0
- package/es/esf/components/magic-box/index.d.ts.map +1 -0
- package/es/esf/components/magic-box/index.js +1 -1
- package/es/esf/components/magic-box/magic-box.d.ts +3 -1
- package/es/esf/components/magic-box/magic-box.d.ts.map +1 -1
- package/es/esf/components/magic-box/magic-box.js +18 -7
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/magic-box/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,eAAe,QAAQ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import MagicBox from "./magic-box";
|
|
2
|
-
export default MagicBox;
|
|
2
|
+
export default MagicBox;
|
|
@@ -12,8 +12,10 @@ type Props = {
|
|
|
12
12
|
maxCPDuration?: number;
|
|
13
13
|
minDays?: number;
|
|
14
14
|
maxDays?: number;
|
|
15
|
+
allowedActivities?: string[];
|
|
15
16
|
children?: React.ReactNode;
|
|
16
17
|
};
|
|
17
|
-
declare const _default: React.MemoExoticComponent<
|
|
18
|
+
declare const _default: React.MemoExoticComponent<typeof MagicBox>;
|
|
18
19
|
export default _default;
|
|
20
|
+
declare function MagicBox({ stay, cartUrl, channel, className, alignContent, maxCPDuration, minDays, maxDays, allowedActivities, children, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
19
21
|
//# sourceMappingURL=magic-box.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magic-box.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/magic-box/magic-box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM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ACZ,aAAa,EACb,OAAW,EACX,OAAkB,EAClB,iBAAiB,EACjB,QAAQ,GACT,EAAE,KAAK,2CA4HP"}
|
|
@@ -9,7 +9,8 @@ import Booking from "./booking";
|
|
|
9
9
|
import { message } from "./messages";
|
|
10
10
|
import * as API from "./services/api";
|
|
11
11
|
import css from "./magic-box.module.css";
|
|
12
|
-
|
|
12
|
+
export default React.memo(MagicBox);
|
|
13
|
+
function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, maxCPDuration, minDays = 0, maxDays = Infinity, allowedActivities, children, }) {
|
|
13
14
|
const [filters, setFilters] = React.useState();
|
|
14
15
|
const [values, setValues] = React.useState();
|
|
15
16
|
const [currentStep, setCurrentStep] = React.useState(0);
|
|
@@ -49,12 +50,23 @@ const MagicBox = ({ stay, cartUrl, channel = "ESF", className, alignContent, max
|
|
|
49
50
|
});
|
|
50
51
|
const newFilters = Object.keys(filtersResult.filters).reduce((acc, key) => {
|
|
51
52
|
const filter = filtersResult.filters[key];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
: filter.filter((item) => {
|
|
53
|
+
if (key === "days") {
|
|
54
|
+
const days = filter.filter((item) => {
|
|
55
55
|
return item.value >= minDays && item.value <= maxDays;
|
|
56
56
|
});
|
|
57
|
-
|
|
57
|
+
return { ...acc, [key]: days };
|
|
58
|
+
}
|
|
59
|
+
if (key === "activities") {
|
|
60
|
+
const mustFilterActivites = allowedActivities && allowedActivities.length > 0;
|
|
61
|
+
const activities = filter.filter((item) => {
|
|
62
|
+
if (mustFilterActivites) {
|
|
63
|
+
return (!item.restricted && allowedActivities.includes(item.value));
|
|
64
|
+
}
|
|
65
|
+
return !item.restricted;
|
|
66
|
+
});
|
|
67
|
+
return { ...acc, activities };
|
|
68
|
+
}
|
|
69
|
+
return { ...acc, [key]: filter };
|
|
58
70
|
}, {});
|
|
59
71
|
setFilters(newFilters);
|
|
60
72
|
const defaultValues = Object.keys(newFilters).reduce((acc, key) => ({ ...acc, [key]: "" }), {});
|
|
@@ -68,5 +80,4 @@ const MagicBox = ({ stay, cartUrl, channel = "ESF", className, alignContent, max
|
|
|
68
80
|
const showFilter = stay && filters && values;
|
|
69
81
|
const classes = classNames(css.root, className);
|
|
70
82
|
return (_jsx("div", { className: classes, "data-align": alignContent, children: _jsxs("div", { className: css.top, children: [children, currentStep === 0 && (_jsxs(_Fragment, { children: [!filters && _jsx("div", { className: css.loader }), showFilter && (_jsx(Filters, { filters: filters, values: values, setValues: setValues })), _jsxs(Button, { className: css.confirm, onClick: () => setCurrentStep(1), disabled: !isValid, children: [message(lang, "confirm"), _jsx(Icons.Search, {})] })] })), currentStep === 1 && (_jsx(Booking, { stay: stay, cartUrl: cartUrl, channel: channel, values: values, maxCPDuration: maxCPDuration, setCurrentStep: setCurrentStep }))] }) }));
|
|
71
|
-
}
|
|
72
|
-
export default React.memo(MagicBox);
|
|
83
|
+
}
|