kupos-ui-components-lib 9.0.4 → 9.0.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.
|
@@ -38,6 +38,7 @@ import StageTooltip from "../../ui/StagesTooltip";
|
|
|
38
38
|
const SEAT_EXCEPTIONS = ["Asiento mascota"];
|
|
39
39
|
function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, children, busStage, serviceDetailsLoading, cityOrigin, cityDestination, translation, orignLabel, destinationLabel, currencySign, isCiva, showRating, showLastSeats, removeArrivalTime, removeDuplicateSeats, isPeruSites, showAvailableSeats, isSeatIcon, isLinatal, isPeru, t = (key) => key, siteType, isAllinBus, }) {
|
|
40
40
|
var _a, _b;
|
|
41
|
+
console.log("🚀 ~ ServiceItemPB ~ serviceItem:", serviceItem);
|
|
41
42
|
const animationMap = {
|
|
42
43
|
promoAnim: {
|
|
43
44
|
kupos: promoAnimation,
|
package/dist/styles.css
CHANGED
|
@@ -1,78 +1,83 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import LottiePlayer from "../assets/LottiePlayer";
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const priorityAmenities = amenities.filter((id) => PRIORITY_IDS.includes(id));
|
|
13
|
-
const nonPriorityAmenities = amenities.filter((id) => !PRIORITY_IDS.includes(id));
|
|
14
|
-
const hasPriority = priorityAmenities.length > 0;
|
|
3
|
+
const DEFAULT_PRIORITY_IDS = ["2", "3", "13"];
|
|
4
|
+
const TOOLTIP_CLASS = "hidden group-hover:block absolute top-[30px] left-1/2 -translate-x-1/2 text-white rounded-[14px] whitespace-nowrap mt-2.5 text-center shadow-service text-[13.33px]";
|
|
5
|
+
const getAmenityBaseName = (amenityStr) => { var _a; return (_a = amenityStr === null || amenityStr === void 0 ? void 0 : amenityStr.split(".")[0]) !== null && _a !== void 0 ? _a : ""; };
|
|
6
|
+
const isWater = (amenityStr) => { var _a; return ((_a = getAmenityBaseName(amenityStr)) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === "WATER"; };
|
|
7
|
+
const TooltipArrow = ({ color }) => (React.createElement("div", { className: "tooltip-arrow absolute -top-[7px] left-1/2 -translate-x-1/2 w-0 h-0 border-l-8 border-r-8 border-b-8 border-l-transparent border-r-transparent", style: { borderBottomColor: color } }));
|
|
8
|
+
const getAmenitySplit = ({ isPeru, amenities, priorityIds }) => {
|
|
9
|
+
const priority = amenities.filter((id) => priorityIds.includes(id));
|
|
10
|
+
const nonPriority = amenities.filter((id) => !priorityIds.includes(id));
|
|
11
|
+
const hasPriority = priority.length > 0;
|
|
15
12
|
/* ============================
|
|
16
13
|
🇵🇪 PERU LOGIC
|
|
17
14
|
============================ */
|
|
18
|
-
let visibleAmenities = [];
|
|
19
|
-
let shouldShowPlus = false;
|
|
20
|
-
let plusAmenities = [];
|
|
21
15
|
if (isPeru) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
plusAmenities = nonPriorityAmenities;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
visibleAmenities = [];
|
|
29
|
-
shouldShowPlus = amenities.length > 0;
|
|
30
|
-
plusAmenities = amenities;
|
|
31
|
-
}
|
|
16
|
+
return hasPriority
|
|
17
|
+
? { visible: priority, plus: nonPriority }
|
|
18
|
+
: { visible: [], plus: amenities };
|
|
32
19
|
}
|
|
33
20
|
/* ============================
|
|
34
21
|
🌍 NON-PERU LOGIC
|
|
35
22
|
============================ */
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
const sorted = [...amenities].sort((a, b) => Number(priorityIds.includes(b)) - Number(priorityIds.includes(a)));
|
|
24
|
+
return {
|
|
25
|
+
visible: sorted.slice(0, 3),
|
|
26
|
+
plus: sorted.slice(3),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const AmenitiesBlock = ({ serviceItem, metaData, isSoldOut, colors, isPeru, getAnimationIcon, getAmenityName, SvgAmenities, }) => {
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
if (!metaData ||
|
|
32
|
+
!((_a = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.operator_details) === null || _a === void 0 ? void 0 : _a[4]) ||
|
|
33
|
+
!serviceItem.operator_details[4].length) {
|
|
34
|
+
return null;
|
|
41
35
|
}
|
|
36
|
+
const operatorPriorityIds = (_b = serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.operator_details) === null || _b === void 0 ? void 0 : _b[5];
|
|
37
|
+
const priorityIds = (operatorPriorityIds === null || operatorPriorityIds === void 0 ? void 0 : operatorPriorityIds.length) > 0
|
|
38
|
+
? operatorPriorityIds
|
|
39
|
+
: DEFAULT_PRIORITY_IDS;
|
|
40
|
+
const amenities = [...serviceItem.operator_details[4]];
|
|
41
|
+
const { visible: visibleAmenities, plus: plusAmenities } = getAmenitySplit({
|
|
42
|
+
isPeru,
|
|
43
|
+
amenities,
|
|
44
|
+
priorityIds,
|
|
45
|
+
});
|
|
46
|
+
const shouldShowPlus = plusAmenities.length > 0;
|
|
47
|
+
const grayscaleClass = isSoldOut ? "grayscale" : "";
|
|
42
48
|
return (React.createElement("div", { className: "flex items-center gap-[6px]" },
|
|
43
|
-
(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.is_tracking_enabled) && (React.createElement("div", { className:
|
|
49
|
+
(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.is_tracking_enabled) && (React.createElement("div", { className: grayscaleClass },
|
|
44
50
|
React.createElement(LottiePlayer, { animationData: getAnimationIcon("locationAnim"), width: "20px", height: "20px" }))),
|
|
45
51
|
visibleAmenities.map((val, key) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
const raw = metaData.amenities[val];
|
|
53
|
+
if (isWater(raw))
|
|
54
|
+
return null;
|
|
55
|
+
const baseName = getAmenityBaseName(raw);
|
|
56
|
+
return (React.createElement("div", { key: key, className: "relative group cursor-pointer" },
|
|
57
|
+
React.createElement("div", { className: grayscaleClass },
|
|
58
|
+
React.createElement(SvgAmenities, { moreAnemities: false, name: baseName.toLowerCase() })),
|
|
59
|
+
React.createElement("div", { className: TOOLTIP_CLASS, style: {
|
|
51
60
|
backgroundColor: colors.tooltipColor,
|
|
52
61
|
zIndex: 21,
|
|
53
62
|
padding: "12px",
|
|
54
63
|
} },
|
|
55
|
-
React.createElement(
|
|
56
|
-
|
|
57
|
-
} }),
|
|
58
|
-
getAmenityName((_g = (_f = (_e = metaData.amenities[val]) === null || _e === void 0 ? void 0 : _e.split(".")[0]) === null || _f === void 0 ? void 0 : _f.split("_")) === null || _g === void 0 ? void 0 : _g.join(" "))))) : null;
|
|
64
|
+
React.createElement(TooltipArrow, { color: colors.tooltipColor }),
|
|
65
|
+
getAmenityName(baseName.split("_").join(" ")))));
|
|
59
66
|
}),
|
|
60
67
|
shouldShowPlus && (React.createElement("div", { className: "relative ml-1 cursor-pointer" },
|
|
61
68
|
React.createElement("div", { className: "group" },
|
|
62
|
-
React.createElement("img", { src: ((
|
|
69
|
+
React.createElement("img", { src: ((_c = serviceItem.icons) === null || _c === void 0 ? void 0 : _c.plus) ||
|
|
63
70
|
"/images/icons/amenities/icon_plus.svg", className: "w-[16px] h-[16px]", alt: "plus" }),
|
|
64
|
-
React.createElement("div", { style: { zIndex: 100 }, className:
|
|
65
|
-
React.createElement(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
React.createElement(SvgAmenities, { moreAnemities: true, name: (_d = (_c = metaData.amenities[val]) === null || _c === void 0 ? void 0 : _c.split(".")[0]) === null || _d === void 0 ? void 0 : _d.toUpperCase(), color: "white" }),
|
|
75
|
-
getAmenityName((_g = (_f = (_e = metaData.amenities[val]) === null || _e === void 0 ? void 0 : _e.split(".")[0]) === null || _f === void 0 ? void 0 : _f.split("_")) === null || _g === void 0 ? void 0 : _g.join(" ")))) : null;
|
|
71
|
+
React.createElement("div", { style: { zIndex: 100 }, className: TOOLTIP_CLASS },
|
|
72
|
+
React.createElement(TooltipArrow, { color: colors.tooltipColor }),
|
|
73
|
+
React.createElement("div", { className: "flex flex-col gap-[10px] p-3 rounded-[8px] shadow-md", style: { backgroundColor: colors.tooltipColor } }, plusAmenities.map((val, key) => {
|
|
74
|
+
const raw = metaData.amenities[val];
|
|
75
|
+
if (isWater(raw))
|
|
76
|
+
return null;
|
|
77
|
+
const baseName = getAmenityBaseName(raw);
|
|
78
|
+
return (React.createElement("div", { key: key, className: "flex items-center gap-[5px] text-xs whitespace-nowrap" },
|
|
79
|
+
React.createElement(SvgAmenities, { moreAnemities: true, name: baseName.toUpperCase(), color: "white" }),
|
|
80
|
+
getAmenityName(baseName.split("_").join(" "))));
|
|
76
81
|
}))))))));
|
|
77
82
|
};
|
|
78
83
|
export default AmenitiesBlock;
|
package/package.json
CHANGED
|
@@ -72,6 +72,7 @@ function ServiceItemPB({
|
|
|
72
72
|
siteType,
|
|
73
73
|
isAllinBus,
|
|
74
74
|
}: ServiceItemProps & { currencySign?: string }): React.ReactElement {
|
|
75
|
+
console.log("🚀 ~ ServiceItemPB ~ serviceItem:", serviceItem);
|
|
75
76
|
const animationMap: Record<string, Record<string, any>> = {
|
|
76
77
|
promoAnim: {
|
|
77
78
|
kupos: promoAnimation,
|
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import LottiePlayer from "../assets/LottiePlayer";
|
|
3
3
|
|
|
4
|
+
const DEFAULT_PRIORITY_IDS = ["2", "3", "13"];
|
|
5
|
+
|
|
6
|
+
const TOOLTIP_CLASS =
|
|
7
|
+
"hidden group-hover:block absolute top-[30px] left-1/2 -translate-x-1/2 text-white rounded-[14px] whitespace-nowrap mt-2.5 text-center shadow-service text-[13.33px]";
|
|
8
|
+
|
|
9
|
+
const getAmenityBaseName = (amenityStr) => amenityStr?.split(".")[0] ?? "";
|
|
10
|
+
|
|
11
|
+
const isWater = (amenityStr) =>
|
|
12
|
+
getAmenityBaseName(amenityStr)?.toUpperCase() === "WATER";
|
|
13
|
+
|
|
14
|
+
const TooltipArrow = ({ color }) => (
|
|
15
|
+
<div
|
|
16
|
+
className="tooltip-arrow absolute -top-[7px] left-1/2 -translate-x-1/2 w-0 h-0 border-l-8 border-r-8 border-b-8 border-l-transparent border-r-transparent"
|
|
17
|
+
style={{ borderBottomColor: color }}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const getAmenitySplit = ({ isPeru, amenities, priorityIds }) => {
|
|
22
|
+
const priority = amenities.filter((id) => priorityIds.includes(id));
|
|
23
|
+
const nonPriority = amenities.filter((id) => !priorityIds.includes(id));
|
|
24
|
+
const hasPriority = priority.length > 0;
|
|
25
|
+
|
|
26
|
+
/* ============================
|
|
27
|
+
🇵🇪 PERU LOGIC
|
|
28
|
+
============================ */
|
|
29
|
+
if (isPeru) {
|
|
30
|
+
return hasPriority
|
|
31
|
+
? { visible: priority, plus: nonPriority }
|
|
32
|
+
: { visible: [], plus: amenities };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* ============================
|
|
36
|
+
🌍 NON-PERU LOGIC
|
|
37
|
+
============================ */
|
|
38
|
+
const sorted = [...amenities].sort(
|
|
39
|
+
(a, b) => Number(priorityIds.includes(b)) - Number(priorityIds.includes(a)),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
visible: sorted.slice(0, 3),
|
|
44
|
+
plus: sorted.slice(3),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
4
48
|
const AmenitiesBlock = ({
|
|
5
49
|
serviceItem,
|
|
6
50
|
metaData,
|
|
@@ -19,56 +63,28 @@ const AmenitiesBlock = ({
|
|
|
19
63
|
return null;
|
|
20
64
|
}
|
|
21
65
|
|
|
22
|
-
const
|
|
66
|
+
const operatorPriorityIds = serviceItem?.operator_details?.[5];
|
|
67
|
+
const priorityIds =
|
|
68
|
+
operatorPriorityIds?.length > 0
|
|
69
|
+
? operatorPriorityIds
|
|
70
|
+
: DEFAULT_PRIORITY_IDS;
|
|
23
71
|
|
|
24
72
|
const amenities = [...serviceItem.operator_details[4]];
|
|
25
73
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
);
|
|
74
|
+
const { visible: visibleAmenities, plus: plusAmenities } = getAmenitySplit({
|
|
75
|
+
isPeru,
|
|
76
|
+
amenities,
|
|
77
|
+
priorityIds,
|
|
78
|
+
});
|
|
31
79
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
/* ============================
|
|
35
|
-
🇵🇪 PERU LOGIC
|
|
36
|
-
============================ */
|
|
37
|
-
let visibleAmenities = [];
|
|
38
|
-
let shouldShowPlus = false;
|
|
39
|
-
let plusAmenities = [];
|
|
40
|
-
|
|
41
|
-
if (isPeru) {
|
|
42
|
-
if (hasPriority) {
|
|
43
|
-
visibleAmenities = priorityAmenities;
|
|
44
|
-
shouldShowPlus = nonPriorityAmenities.length > 0;
|
|
45
|
-
plusAmenities = nonPriorityAmenities;
|
|
46
|
-
} else {
|
|
47
|
-
visibleAmenities = [];
|
|
48
|
-
shouldShowPlus = amenities.length > 0;
|
|
49
|
-
plusAmenities = amenities;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* ============================
|
|
54
|
-
🌍 NON-PERU LOGIC
|
|
55
|
-
============================ */
|
|
56
|
-
if (!isPeru) {
|
|
57
|
-
const sortedAmenities = [...amenities].sort(
|
|
58
|
-
(a, b) =>
|
|
59
|
-
Number(PRIORITY_IDS.includes(b)) - Number(PRIORITY_IDS.includes(a)),
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
visibleAmenities = sortedAmenities.slice(0, 3);
|
|
63
|
-
shouldShowPlus = sortedAmenities.length > 3;
|
|
64
|
-
plusAmenities = sortedAmenities.slice(3);
|
|
65
|
-
}
|
|
80
|
+
const shouldShowPlus = plusAmenities.length > 0;
|
|
81
|
+
const grayscaleClass = isSoldOut ? "grayscale" : "";
|
|
66
82
|
|
|
67
83
|
return (
|
|
68
84
|
<div className="flex items-center gap-[6px]">
|
|
69
85
|
{/* GPS */}
|
|
70
86
|
{serviceItem?.is_tracking_enabled && (
|
|
71
|
-
<div className={
|
|
87
|
+
<div className={grayscaleClass}>
|
|
72
88
|
<LottiePlayer
|
|
73
89
|
animationData={getAnimationIcon("locationAnim")}
|
|
74
90
|
width="20px"
|
|
@@ -78,38 +94,35 @@ const AmenitiesBlock = ({
|
|
|
78
94
|
)}
|
|
79
95
|
|
|
80
96
|
{/* AMENITIES */}
|
|
81
|
-
{visibleAmenities.map((val, key) =>
|
|
82
|
-
metaData.amenities[val]
|
|
97
|
+
{visibleAmenities.map((val, key) => {
|
|
98
|
+
const raw = metaData.amenities[val];
|
|
99
|
+
if (isWater(raw)) return null;
|
|
100
|
+
const baseName = getAmenityBaseName(raw);
|
|
101
|
+
|
|
102
|
+
return (
|
|
83
103
|
<div key={key} className="relative group cursor-pointer">
|
|
84
|
-
<div className={
|
|
104
|
+
<div className={grayscaleClass}>
|
|
85
105
|
<SvgAmenities
|
|
86
106
|
moreAnemities={false}
|
|
87
|
-
name={
|
|
107
|
+
name={baseName.toLowerCase()}
|
|
88
108
|
/>
|
|
89
109
|
</div>
|
|
90
110
|
|
|
91
111
|
{/* Tooltip */}
|
|
92
112
|
<div
|
|
93
|
-
className=
|
|
113
|
+
className={TOOLTIP_CLASS}
|
|
94
114
|
style={{
|
|
95
115
|
backgroundColor: colors.tooltipColor,
|
|
96
116
|
zIndex: 21,
|
|
97
117
|
padding: "12px",
|
|
98
118
|
}}
|
|
99
119
|
>
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
style={{
|
|
103
|
-
borderBottomColor: colors.tooltipColor,
|
|
104
|
-
}}
|
|
105
|
-
/>
|
|
106
|
-
{getAmenityName(
|
|
107
|
-
metaData.amenities[val]?.split(".")[0]?.split("_")?.join(" "),
|
|
108
|
-
)}
|
|
120
|
+
<TooltipArrow color={colors.tooltipColor} />
|
|
121
|
+
{getAmenityName(baseName.split("_").join(" "))}
|
|
109
122
|
</div>
|
|
110
123
|
</div>
|
|
111
|
-
)
|
|
112
|
-
)}
|
|
124
|
+
);
|
|
125
|
+
})}
|
|
113
126
|
|
|
114
127
|
{/* PLUS ICON */}
|
|
115
128
|
{shouldShowPlus && (
|
|
@@ -124,46 +137,32 @@ const AmenitiesBlock = ({
|
|
|
124
137
|
alt="plus"
|
|
125
138
|
/>
|
|
126
139
|
|
|
127
|
-
<div
|
|
128
|
-
|
|
129
|
-
className="hidden group-hover:block absolute top-[30px] left-1/2 -translate-x-1/2 text-white rounded-[14px] whitespace-nowrap mt-2.5 text-center shadow-service text-[13.33px]"
|
|
130
|
-
>
|
|
131
|
-
<div
|
|
132
|
-
className="tooltip-arrow absolute -top-[7px] left-1/2 -translate-x-1/2 w-0 h-0 border-l-8 border-r-8 border-b-8 border-l-transparent border-r-transparent"
|
|
133
|
-
style={{
|
|
134
|
-
borderBottomColor: colors.tooltipColor,
|
|
135
|
-
}}
|
|
136
|
-
></div>
|
|
140
|
+
<div style={{ zIndex: 100 }} className={TOOLTIP_CLASS}>
|
|
141
|
+
<TooltipArrow color={colors.tooltipColor} />
|
|
137
142
|
|
|
138
143
|
<div
|
|
139
144
|
className="flex flex-col gap-[10px] p-3 rounded-[8px] shadow-md"
|
|
140
|
-
style={{
|
|
141
|
-
backgroundColor: colors.tooltipColor,
|
|
142
|
-
}}
|
|
145
|
+
style={{ backgroundColor: colors.tooltipColor }}
|
|
143
146
|
>
|
|
144
|
-
{plusAmenities.map((val, key) =>
|
|
145
|
-
metaData.amenities[val]
|
|
146
|
-
|
|
147
|
+
{plusAmenities.map((val, key) => {
|
|
148
|
+
const raw = metaData.amenities[val];
|
|
149
|
+
if (isWater(raw)) return null;
|
|
150
|
+
const baseName = getAmenityBaseName(raw);
|
|
151
|
+
|
|
152
|
+
return (
|
|
147
153
|
<div
|
|
148
154
|
key={key}
|
|
149
155
|
className="flex items-center gap-[5px] text-xs whitespace-nowrap"
|
|
150
156
|
>
|
|
151
157
|
<SvgAmenities
|
|
152
158
|
moreAnemities={true}
|
|
153
|
-
name={
|
|
154
|
-
?.split(".")[0]
|
|
155
|
-
?.toUpperCase()}
|
|
159
|
+
name={baseName.toUpperCase()}
|
|
156
160
|
color="white"
|
|
157
161
|
/>
|
|
158
|
-
{getAmenityName(
|
|
159
|
-
metaData.amenities[val]
|
|
160
|
-
?.split(".")[0]
|
|
161
|
-
?.split("_")
|
|
162
|
-
?.join(" "),
|
|
163
|
-
)}
|
|
162
|
+
{getAmenityName(baseName.split("_").join(" "))}
|
|
164
163
|
</div>
|
|
165
|
-
)
|
|
166
|
-
)}
|
|
164
|
+
);
|
|
165
|
+
})}
|
|
167
166
|
</div>
|
|
168
167
|
</div>
|
|
169
168
|
</div>
|