kupos-ui-components-lib 10.4.36 → 10.4.38
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/components/FilterBar/FilterBarDesktop.d.ts +1 -1
- package/dist/components/FilterBar/FilterBarDesktop.js +55 -11
- package/dist/components/FilterBar/tyoes.d.ts +1 -0
- package/dist/components/ServiceItem/ServiceItemDesktop.js +1 -1
- package/dist/ui/DiscountBanners/defaultBackgrounds.js +2 -3
- package/dist/ui/ServiceBadges/ServiceBadges.js +1 -1
- package/dist/ui/mobileweb/ServiceBadgesMobile.js +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBarDesktop.tsx +60 -15
- package/src/components/FilterBar/tyoes.ts +2 -1
- package/src/components/ServiceItem/ServiceItemDesktop.tsx +1 -0
- package/src/ui/DiscountBanners/defaultBackgrounds.ts +2 -2
- package/src/ui/ServiceBadges/ServiceBadges.tsx +1 -1
- package/src/ui/mobileweb/ServiceBadgesMobile.tsx +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FilterBarProps } from "./tyoes";
|
|
3
|
-
declare const FilterBarDesktop: ({ t, serviceList, setServiceList, allSchedules, showReturnTripModal, filterArrData, isBlankTicket, operatorId, filtersArray, setFiltersArray, metaData, busTerminals, setTypes, colors, icons, translation, isTrain, isPeru, hideOperator, setCoachLoading, setCoachKey, isAllinBus, }: FilterBarProps) => React.JSX.Element;
|
|
3
|
+
declare const FilterBarDesktop: ({ t, serviceList, setServiceList, allSchedules, showReturnTripModal, filterArrData, isBlankTicket, operatorId, filtersArray, setFiltersArray, metaData, busTerminals, setTypes, colors, icons, translation, isTrain, isPeru, hideOperator, setCoachLoading, setCoachKey, isAllinBus, priority_stage_ids, }: FilterBarProps) => React.JSX.Element;
|
|
4
4
|
export default FilterBarDesktop;
|
|
@@ -2,21 +2,45 @@ import React from "react";
|
|
|
2
2
|
import commonService from "../../utils/CommonService";
|
|
3
3
|
import ServiceFilter from "./ServiceFilter";
|
|
4
4
|
let cachedStageOptions = null;
|
|
5
|
-
const FilterBarDesktop = ({ t, serviceList, setServiceList, allSchedules, showReturnTripModal, filterArrData, isBlankTicket, operatorId, filtersArray, setFiltersArray, metaData, busTerminals, setTypes, colors, icons, translation, isTrain, isPeru, hideOperator, setCoachLoading, setCoachKey, isAllinBus, }) => {
|
|
5
|
+
const FilterBarDesktop = ({ t, serviceList, setServiceList, allSchedules, showReturnTripModal, filterArrData, isBlankTicket, operatorId, filtersArray, setFiltersArray, metaData, busTerminals, setTypes, colors, icons, translation, isTrain, isPeru, hideOperator, setCoachLoading, setCoachKey, isAllinBus, priority_stage_ids, }) => {
|
|
6
|
+
// Same rule as showTopLabel in ServiceItemDesktop: a visible bus terminal
|
|
7
|
+
// label, restricted to priority_stage_ids when that list is non-empty.
|
|
8
|
+
const getTopLabel = (labelId) => {
|
|
9
|
+
const stageValue = busTerminals === null || busTerminals === void 0 ? void 0 : busTerminals[labelId];
|
|
10
|
+
if (!stageValue)
|
|
11
|
+
return false;
|
|
12
|
+
const [label, visible] = stageValue.split("|");
|
|
13
|
+
if (visible !== "true" || !label)
|
|
14
|
+
return false;
|
|
15
|
+
if (priority_stage_ids && priority_stage_ids.length > 0) {
|
|
16
|
+
return priority_stage_ids.includes(labelId) ? label : false;
|
|
17
|
+
}
|
|
18
|
+
return label;
|
|
19
|
+
};
|
|
6
20
|
const getEnrichedFilters = () => {
|
|
7
|
-
|
|
8
|
-
if (hasSpecialDeparture)
|
|
21
|
+
if (!isAllinBus)
|
|
9
22
|
return filtersArray;
|
|
10
|
-
if (
|
|
23
|
+
if (allSchedules === null || allSchedules === void 0 ? void 0 : allSchedules.length) {
|
|
24
|
+
// Mirror what each service card shows: the top label if there is one,
|
|
25
|
+
// otherwise the boarding name.
|
|
11
26
|
const stageMap = new Map();
|
|
12
27
|
allSchedules.forEach((schedule) => {
|
|
13
28
|
var _a, _b, _c;
|
|
29
|
+
const labelId = typeof schedule.boarding_stages === "string"
|
|
30
|
+
? schedule.boarding_stages.split("|")[0]
|
|
31
|
+
: "";
|
|
32
|
+
const topLabel = labelId && getTopLabel(labelId);
|
|
33
|
+
if (topLabel) {
|
|
34
|
+
stageMap.set(labelId, topLabel);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
14
37
|
if ((_a = schedule.stage_details_arr) === null || _a === void 0 ? void 0 : _a.length) {
|
|
15
38
|
const stageObj = schedule.stage_details_arr[0];
|
|
16
39
|
const stageId = Object.keys(stageObj)[0];
|
|
17
40
|
const stageName = (_c = (_b = stageObj[stageId]) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.split(", ")[0];
|
|
18
|
-
|
|
19
|
-
|
|
41
|
+
const id = labelId || stageId;
|
|
42
|
+
if (id && stageName) {
|
|
43
|
+
stageMap.set(id, stageName);
|
|
20
44
|
}
|
|
21
45
|
}
|
|
22
46
|
});
|
|
@@ -28,11 +52,31 @@ const FilterBarDesktop = ({ t, serviceList, setServiceList, allSchedules, showRe
|
|
|
28
52
|
}));
|
|
29
53
|
}
|
|
30
54
|
}
|
|
31
|
-
if (cachedStageOptions === null || cachedStageOptions === void 0 ? void 0 : cachedStageOptions.length)
|
|
32
|
-
return filtersArray
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
if (!(cachedStageOptions === null || cachedStageOptions === void 0 ? void 0 : cachedStageOptions.length))
|
|
56
|
+
return filtersArray;
|
|
57
|
+
// Replace the special departure options with the computed ones, keeping
|
|
58
|
+
// the active state of options already selected. Stays a no-op once the
|
|
59
|
+
// options match, so the setFiltersArray call below doesn't loop.
|
|
60
|
+
let changed = false;
|
|
61
|
+
const enriched = filtersArray.map((f) => {
|
|
62
|
+
if (f.type !== "special_departure")
|
|
63
|
+
return f;
|
|
64
|
+
const existing = f.options || [];
|
|
65
|
+
const isSame = existing.length === cachedStageOptions.length &&
|
|
66
|
+
cachedStageOptions.every((opt, i) => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
return String((_a = existing[i]) === null || _a === void 0 ? void 0 : _a.value) === opt.value &&
|
|
69
|
+
((_b = existing[i]) === null || _b === void 0 ? void 0 : _b.label) === opt.label;
|
|
70
|
+
});
|
|
71
|
+
if (isSame)
|
|
72
|
+
return f;
|
|
73
|
+
changed = true;
|
|
74
|
+
return Object.assign(Object.assign({}, f), { options: cachedStageOptions.map((opt) => {
|
|
75
|
+
var _a;
|
|
76
|
+
return (Object.assign(Object.assign({}, opt), { active: !!((_a = existing.find((o) => String(o.value) === opt.value)) === null || _a === void 0 ? void 0 : _a.active) }));
|
|
77
|
+
}) });
|
|
78
|
+
});
|
|
79
|
+
return changed ? enriched : filtersArray;
|
|
36
80
|
};
|
|
37
81
|
const enrichedFilters = getEnrichedFilters();
|
|
38
82
|
if (enrichedFilters !== filtersArray) {
|
|
@@ -305,7 +305,7 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
|
|
|
305
305
|
},
|
|
306
306
|
];
|
|
307
307
|
const otherItems = items.filter((i) => i.key !== "pet" && i.key !== "flexible" && !!i.condition);
|
|
308
|
-
return (React.createElement(React.Fragment, null, isPeruSites ? (React.createElement(PeruServiceItemDesktop, { serviceItem: serviceItem, onBookButtonPress: onBookButtonPress, colors: colors, metaData: metaData, children: children, busStage: busStage, serviceDetailsLoading: serviceDetailsLoading, cityOrigin: cityOrigin, cityDestination: cityDestination, translation: translation, orignLabel: orignLabel, destinationLabel: destinationLabel, currencySign: currencySign, isCiva: isCiva, showRating: showRating, showLastSeats: showLastSeats, removeArrivalTime: removeArrivalTime, removeDuplicateSeats: removeDuplicateSeats, isPeruSites: isPeruSites, t: (key) => t(key), showAvailableSeats: showAvailableSeats, isSeatIcon: isSeatIcon, isPeru: isPeru, siteType: siteType, isAllinBus: isAllinBus, viewersConfig: viewersConfig, isLoggedIn: isLoggedIn, showLoginModal: showLoginModal, isExpand: isExpand, setIsExpand: setIsExpand, coachKey: coachKey, isFlores: isFlores, isNewUiEnabled: isNewUiEnabledPeru, showLoginOption: showLoginOption })) : isNewUi && !isTrain ? (React.createElement(FeatureServiceUi, { serviceItem: serviceItem, showTopLabel: showTopLabel, getAnimationIcon: getAnimationIcon, cityOrigin: cityOrigin, cityDestination: cityDestination, renderIcon: renderIcon, viewersConfig: viewersConfig, isFeatureDropDownExpand: isFeatureDropDownExpand, ticketQuantity: ticketQuantity, onIncreaseTicketQuantity: onIncreaseTicketQuantity, onDecreaseTicketQuantity: onDecreaseTicketQuantity, onBookButtonPress: onRemateUiButtonClick, onToggleExpand: () => setIsFeatureDropDownExpand &&
|
|
308
|
+
return (React.createElement(React.Fragment, null, isPeruSites ? (React.createElement(PeruServiceItemDesktop, { serviceItem: serviceItem, onBookButtonPress: onBookButtonPress, colors: colors, metaData: metaData, children: children, busStage: busStage, serviceDetailsLoading: serviceDetailsLoading, cityOrigin: cityOrigin, cityDestination: cityDestination, translation: translation, orignLabel: orignLabel, destinationLabel: destinationLabel, currencySign: currencySign, isCiva: isCiva, showRating: showRating, showLastSeats: showLastSeats, removeArrivalTime: removeArrivalTime, removeDuplicateSeats: removeDuplicateSeats, isPeruSites: isPeruSites, t: (key) => t(key), showAvailableSeats: showAvailableSeats, isSeatIcon: isSeatIcon, isPeru: isPeru, siteType: siteType, isAllinBus: isAllinBus, viewersConfig: viewersConfig, isLoggedIn: isLoggedIn, showLoginModal: showLoginModal, isExpand: isExpand, setIsExpand: setIsExpand, coachKey: coachKey, isFlores: isFlores, isNewUiEnabled: isNewUiEnabledPeru, showLoginOption: showLoginOption, priority_stage_ids: priority_stage_ids })) : isNewUi && !isTrain ? (React.createElement(FeatureServiceUi, { serviceItem: serviceItem, showTopLabel: showTopLabel, getAnimationIcon: getAnimationIcon, cityOrigin: cityOrigin, cityDestination: cityDestination, renderIcon: renderIcon, viewersConfig: viewersConfig, isFeatureDropDownExpand: isFeatureDropDownExpand, ticketQuantity: ticketQuantity, onIncreaseTicketQuantity: onIncreaseTicketQuantity, onDecreaseTicketQuantity: onDecreaseTicketQuantity, onBookButtonPress: onRemateUiButtonClick, onToggleExpand: () => setIsFeatureDropDownExpand &&
|
|
309
309
|
setIsFeatureDropDownExpand(isFeatureDropDownExpand === serviceItem.id ||
|
|
310
310
|
isFeatureDropDownExpand === true
|
|
311
311
|
? null
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import greenArt from "../../assets/images/discount/
|
|
1
|
+
import greenArt from "../../assets/images/discount/instant.png";
|
|
2
2
|
import yellowArt from "../../assets/images/discount/yellow.png";
|
|
3
3
|
import blueArt from "../../assets/images/discount/blue.png";
|
|
4
4
|
import lastMinuteArt from "../../assets/images/discount/last.png";
|
|
@@ -7,7 +7,6 @@ import cashbackArt from "../../assets/images/discount/cash.png";
|
|
|
7
7
|
import roundTripArt from "../../assets/images/discount/round.png";
|
|
8
8
|
import promoCodeArt from "../../assets/images/discount/promo.png";
|
|
9
9
|
import seatLevelArt from "../../assets/images/discount/seat.png";
|
|
10
|
-
import instantArt from "../../assets/images/discount/instant.png";
|
|
11
10
|
export function toImageUrl(art) {
|
|
12
11
|
if (typeof art === "string")
|
|
13
12
|
return art;
|
|
@@ -34,5 +33,5 @@ export const CAMPAIGN_ART = {
|
|
|
34
33
|
round_trip: { image: toImageUrl(roundTripArt), accent: "#5C8A00" },
|
|
35
34
|
instant_discount: { image: toImageUrl(promoCodeArt), accent: "#E08A00" },
|
|
36
35
|
seat_level: { image: toImageUrl(seatLevelArt), accent: "#B87500" },
|
|
37
|
-
promo_code: { image: toImageUrl(
|
|
36
|
+
promo_code: { image: toImageUrl(seatLevelArt), accent: "#B87500" },
|
|
38
37
|
};
|
|
@@ -40,7 +40,7 @@ const ServiceBadges = ({ showTopLabel, isSoldOut, colors, renderIcon, translatio
|
|
|
40
40
|
} },
|
|
41
41
|
renderIcon("directo", "12px"),
|
|
42
42
|
React.createElement("div", null, "Tren Express"))),
|
|
43
|
-
boardingName && isAllinBus && (React.createElement("div", { className: `flex items-center gap-[10px] py-[4px] px-[14px] rounded-[38px] text-[12.5px] z-20`, style: {
|
|
43
|
+
boardingName && isAllinBus && !showTopLabel && (React.createElement("div", { className: `flex items-center gap-[10px] py-[4px] px-[14px] rounded-[38px] text-[12.5px] z-20`, style: {
|
|
44
44
|
backgroundColor: colors.topLabelBgColor || "#fff",
|
|
45
45
|
border: isSoldOut
|
|
46
46
|
? "1px solid #ccc"
|
|
@@ -40,7 +40,7 @@ const ServiceBadgesMobile = ({ showTopLabel, isSoldOut, colors, renderIcon, serv
|
|
|
40
40
|
} },
|
|
41
41
|
renderIcon("directo", "12px"),
|
|
42
42
|
React.createElement("div", null, "Tren Express"))),
|
|
43
|
-
boardingName && isAllinBus && (React.createElement("div", { className: `flex items-center gap-[2p x] py-[4px] px-[10px] rounded-[38px] min-[420]:text-[12px] text-[10px] h-[24px] z-20`, style: {
|
|
43
|
+
boardingName && isAllinBus && !showTopLabel && (React.createElement("div", { className: `flex items-center gap-[2p x] py-[4px] px-[10px] rounded-[38px] min-[420]:text-[12px] text-[10px] h-[24px] z-20`, style: {
|
|
44
44
|
backgroundColor: colors.topLabelBgColor || "#fff",
|
|
45
45
|
border: isSoldOut
|
|
46
46
|
? "1px solid #ccc"
|
package/package.json
CHANGED
|
@@ -28,22 +28,47 @@ const FilterBarDesktop = ({
|
|
|
28
28
|
setCoachLoading,
|
|
29
29
|
setCoachKey,
|
|
30
30
|
isAllinBus,
|
|
31
|
+
priority_stage_ids,
|
|
31
32
|
}: FilterBarProps) => {
|
|
33
|
+
// Same rule as showTopLabel in ServiceItemDesktop: a visible bus terminal
|
|
34
|
+
// label, restricted to priority_stage_ids when that list is non-empty.
|
|
35
|
+
const getTopLabel = (labelId: string) => {
|
|
36
|
+
const stageValue = busTerminals?.[labelId];
|
|
37
|
+
if (!stageValue) return false;
|
|
38
|
+
const [label, visible] = stageValue.split("|");
|
|
39
|
+
if (visible !== "true" || !label) return false;
|
|
40
|
+
if (priority_stage_ids && priority_stage_ids.length > 0) {
|
|
41
|
+
return priority_stage_ids.includes(labelId) ? label : false;
|
|
42
|
+
}
|
|
43
|
+
return label;
|
|
44
|
+
};
|
|
45
|
+
|
|
32
46
|
const getEnrichedFilters = () => {
|
|
33
|
-
|
|
34
|
-
(f: any) => f.type === "special_departure" && f.options?.length > 0,
|
|
35
|
-
);
|
|
36
|
-
if (hasSpecialDeparture) return filtersArray;
|
|
47
|
+
if (!isAllinBus) return filtersArray;
|
|
37
48
|
|
|
38
|
-
if (
|
|
49
|
+
if (allSchedules?.length) {
|
|
50
|
+
// Mirror what each service card shows: the top label if there is one,
|
|
51
|
+
// otherwise the boarding name.
|
|
39
52
|
const stageMap = new Map<string, string>();
|
|
40
53
|
allSchedules.forEach((schedule: any) => {
|
|
54
|
+
const labelId =
|
|
55
|
+
typeof schedule.boarding_stages === "string"
|
|
56
|
+
? schedule.boarding_stages.split("|")[0]
|
|
57
|
+
: "";
|
|
58
|
+
|
|
59
|
+
const topLabel = labelId && getTopLabel(labelId);
|
|
60
|
+
if (topLabel) {
|
|
61
|
+
stageMap.set(labelId, topLabel);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
41
65
|
if (schedule.stage_details_arr?.length) {
|
|
42
66
|
const stageObj = schedule.stage_details_arr[0];
|
|
43
67
|
const stageId = Object.keys(stageObj)[0];
|
|
44
68
|
const stageName = stageObj[stageId]?.[0]?.split(", ")[0];
|
|
45
|
-
|
|
46
|
-
|
|
69
|
+
const id = labelId || stageId;
|
|
70
|
+
if (id && stageName) {
|
|
71
|
+
stageMap.set(id, stageName);
|
|
47
72
|
}
|
|
48
73
|
}
|
|
49
74
|
});
|
|
@@ -59,15 +84,35 @@ const FilterBarDesktop = ({
|
|
|
59
84
|
}
|
|
60
85
|
}
|
|
61
86
|
|
|
62
|
-
if (cachedStageOptions?.length)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
87
|
+
if (!cachedStageOptions?.length) return filtersArray;
|
|
88
|
+
|
|
89
|
+
// Replace the special departure options with the computed ones, keeping
|
|
90
|
+
// the active state of options already selected. Stays a no-op once the
|
|
91
|
+
// options match, so the setFiltersArray call below doesn't loop.
|
|
92
|
+
let changed = false;
|
|
93
|
+
const enriched = filtersArray.map((f: any) => {
|
|
94
|
+
if (f.type !== "special_departure") return f;
|
|
95
|
+
const existing = f.options || [];
|
|
96
|
+
const isSame =
|
|
97
|
+
existing.length === cachedStageOptions!.length &&
|
|
98
|
+
cachedStageOptions!.every(
|
|
99
|
+
(opt, i) =>
|
|
100
|
+
String(existing[i]?.value) === opt.value &&
|
|
101
|
+
existing[i]?.label === opt.label,
|
|
102
|
+
);
|
|
103
|
+
if (isSame) return f;
|
|
104
|
+
changed = true;
|
|
105
|
+
return {
|
|
106
|
+
...f,
|
|
107
|
+
options: cachedStageOptions!.map((opt) => ({
|
|
108
|
+
...opt,
|
|
109
|
+
active: !!existing.find((o: any) => String(o.value) === opt.value)
|
|
110
|
+
?.active,
|
|
111
|
+
})),
|
|
112
|
+
};
|
|
113
|
+
});
|
|
69
114
|
|
|
70
|
-
return filtersArray;
|
|
115
|
+
return changed ? enriched : filtersArray;
|
|
71
116
|
};
|
|
72
117
|
|
|
73
118
|
const enrichedFilters = getEnrichedFilters();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import greenArt from "../../assets/images/discount/
|
|
1
|
+
import greenArt from "../../assets/images/discount/instant.png";
|
|
2
2
|
import yellowArt from "../../assets/images/discount/yellow.png";
|
|
3
3
|
import blueArt from "../../assets/images/discount/blue.png";
|
|
4
4
|
import lastMinuteArt from "../../assets/images/discount/last.png";
|
|
@@ -38,5 +38,5 @@ export const CAMPAIGN_ART: Record<string, { image: string; accent: string }> = {
|
|
|
38
38
|
round_trip: { image: toImageUrl(roundTripArt), accent: "#5C8A00" },
|
|
39
39
|
instant_discount: { image: toImageUrl(promoCodeArt), accent: "#E08A00" },
|
|
40
40
|
seat_level: { image: toImageUrl(seatLevelArt), accent: "#B87500" },
|
|
41
|
-
promo_code: { image: toImageUrl(
|
|
41
|
+
promo_code: { image: toImageUrl(seatLevelArt), accent: "#B87500" },
|
|
42
42
|
};
|
|
@@ -97,7 +97,7 @@ const ServiceBadges: React.FC<ServiceBadgesProps> = ({
|
|
|
97
97
|
<div>{"Tren Express"}</div>
|
|
98
98
|
</div>
|
|
99
99
|
)}
|
|
100
|
-
{boardingName && isAllinBus && (
|
|
100
|
+
{boardingName && isAllinBus && !showTopLabel && (
|
|
101
101
|
<div
|
|
102
102
|
className={`flex items-center gap-[10px] py-[4px] px-[14px] rounded-[38px] text-[12.5px] z-20`}
|
|
103
103
|
style={{
|
|
@@ -104,7 +104,7 @@ const ServiceBadgesMobile: React.FC<ServiceBadgesMobileProps> = ({
|
|
|
104
104
|
<div>{"Tren Express"}</div>
|
|
105
105
|
</div>
|
|
106
106
|
)}
|
|
107
|
-
{boardingName && isAllinBus && (
|
|
107
|
+
{boardingName && isAllinBus && !showTopLabel && (
|
|
108
108
|
<div
|
|
109
109
|
className={`flex items-center gap-[2p x] py-[4px] px-[10px] rounded-[38px] min-[420]:text-[12px] text-[10px] h-[24px] z-20`}
|
|
110
110
|
style={{
|