kupos-ui-components-lib 9.1.10 → 9.2.0

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.
@@ -1,42 +1,43 @@
1
1
  import React from "react";
2
2
  import commonService from "../../utils/CommonService";
3
3
  import ServiceFilter from "./ServiceFilter";
4
+ let cachedStageOptions = null;
4
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
6
  const getEnrichedFilters = () => {
6
- if (!isAllinBus || !(allSchedules === null || allSchedules === void 0 ? void 0 : allSchedules.length))
7
- return filtersArray;
8
7
  const hasSpecialDeparture = filtersArray.some((f) => { var _a; return f.type === "special_departure" && ((_a = f.options) === null || _a === void 0 ? void 0 : _a.length) > 0; });
9
8
  if (hasSpecialDeparture)
10
9
  return filtersArray;
11
- const stageMap = new Map();
12
- allSchedules.forEach((schedule) => {
13
- var _a, _b, _c;
14
- if ((_a = schedule.stage_details_arr) === null || _a === void 0 ? void 0 : _a.length) {
15
- const stageObj = schedule.stage_details_arr[0];
16
- const stageId = Object.keys(stageObj)[0];
17
- const stageName = (_c = (_b = stageObj[stageId]) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.split(", ")[0];
18
- if (stageId && stageName) {
19
- stageMap.set(stageId, stageName);
10
+ if (isAllinBus && (allSchedules === null || allSchedules === void 0 ? void 0 : allSchedules.length)) {
11
+ const stageMap = new Map();
12
+ allSchedules.forEach((schedule) => {
13
+ var _a, _b, _c;
14
+ if ((_a = schedule.stage_details_arr) === null || _a === void 0 ? void 0 : _a.length) {
15
+ const stageObj = schedule.stage_details_arr[0];
16
+ const stageId = Object.keys(stageObj)[0];
17
+ const stageName = (_c = (_b = stageObj[stageId]) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.split(", ")[0];
18
+ if (stageId && stageName) {
19
+ stageMap.set(stageId, stageName);
20
+ }
20
21
  }
22
+ });
23
+ if (stageMap.size > 0) {
24
+ cachedStageOptions = Array.from(stageMap.entries()).map(([id, name]) => ({
25
+ label: name,
26
+ value: id,
27
+ active: false,
28
+ }));
21
29
  }
22
- });
23
- if (stageMap.size === 0)
24
- return filtersArray;
25
- const specialDeptOptions = Array.from(stageMap.entries()).map(([id, name]) => ({
26
- label: name,
27
- value: id,
28
- active: false,
29
- }));
30
- return [
31
- ...filtersArray,
32
- {
33
- type: "special_departure",
34
- title: "SPECIAL_DEPARTURE",
35
- options: specialDeptOptions,
36
- },
37
- ];
30
+ }
31
+ if (cachedStageOptions === null || cachedStageOptions === void 0 ? void 0 : cachedStageOptions.length) {
32
+ return filtersArray.map((f) => f.type === "special_departure"
33
+ ? Object.assign(Object.assign({}, f), { options: cachedStageOptions }) : f);
34
+ }
35
+ return filtersArray;
38
36
  };
39
37
  const enrichedFilters = getEnrichedFilters();
38
+ if (enrichedFilters !== filtersArray) {
39
+ setFiltersArray(enrichedFilters);
40
+ }
40
41
  const filterBy = (filters) => {
41
42
  try {
42
43
  let routes = allSchedules;
@@ -283,7 +283,11 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
283
283
  } },
284
284
  React.createElement("div", {
285
285
  // className="grid text-[#464647] w-full [grid-template-columns:18%_28%_2.5%_28%_15.5%] gap-x-[2%] items-center"
286
- className: "grid text-[#464647] w-full [grid-template-columns:22%_28%_2.5%_24%_15.5%] gap-x-[2%] items-center" },
286
+ className: "grid text-[#464647] w-full [grid-template-columns:22%_28%_2.5%_24%_15.5%] gap-x-[2%] items-center",
287
+ // style={{ marginTop: showTopLabel ? "8px" : "" }}
288
+ style: {
289
+ marginTop: showTopLabel && (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.is_direct_trip) ? "8px" : "",
290
+ } },
287
291
  React.createElement("div", { style: {
288
292
  display: "flex",
289
293
  flexDirection: "column",
@@ -322,7 +326,7 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
322
326
  zIndex: -1,
323
327
  } },
324
328
  React.createElement("div", { style: { overflow: "hidden", minHeight: 0, marginTop: "-10px" } },
325
- React.createElement(ExpandedDropdown, { serviceItem: serviceItem }))),
329
+ React.createElement(ExpandedDropdown, { serviceItem: serviceItem, isPeru: isPeru, translation: translation, getAnimationIcon: getAnimationIcon }))),
326
330
  children,
327
331
  (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.offer_text) && (React.createElement("div", { className: "text-white p-[10px_15px] text-left w-full flex items-center absolute -bottom-[36px] pt-[50px] -z-10 rounded-b-[14px] text-[14px]", style: {
328
332
  backgroundColor: colors === null || colors === void 0 ? void 0 : colors.bottomStripColor,
@@ -229,6 +229,6 @@ function ServiceItemMobile({ serviceItem, onBookButtonPress, colors, busStage, o
229
229
  zIndex: (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.offer_text) ? -3 : undefined,
230
230
  marginTop: (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.offer_text) ? "-15px" : "-10px",
231
231
  } },
232
- React.createElement(ExpandedDropdownMobile, { serviceItem: serviceItem })))));
232
+ React.createElement(ExpandedDropdownMobile, { serviceItem: serviceItem, isPeru: isPeru })))));
233
233
  }
234
234
  export default ServiceItemMobile;
@@ -6,6 +6,9 @@ interface ExpandedDropdownProps {
6
6
  is_change_ticket?: boolean;
7
7
  is_tracking_enabled?: boolean;
8
8
  };
9
+ isPeru?: boolean;
10
+ translation?: Record<string, string>;
11
+ getAnimationIcon?: (iconName: string) => any;
9
12
  }
10
- declare function ExpandedDropdown({ serviceItem, }: ExpandedDropdownProps): React.ReactElement;
13
+ declare function ExpandedDropdown({ serviceItem, isPeru, translation, getAnimationIcon, }: ExpandedDropdownProps): React.ReactElement;
11
14
  export default ExpandedDropdown;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- function ExpandedDropdown({ serviceItem, }) {
2
+ import LottiePlayer from "../../assets/LottiePlayer";
3
+ function ExpandedDropdown({ serviceItem, isPeru = false, translation = {}, getAnimationIcon, }) {
3
4
  const hasPetInfo = serviceItem.pet_seat_info &&
4
5
  Object.keys(serviceItem.pet_seat_info).length > 0;
5
6
  return (React.createElement("div", { className: "px-[15px] pt-[26px] pb-[14px] -mt-[16px] pt-[35px] relative -z-9", style: {
@@ -10,6 +11,10 @@ function ExpandedDropdown({ serviceItem, }) {
10
11
  // borderTop: "none",
11
12
  } },
12
13
  React.createElement("div", { className: "flex flex-col gap-[10px] text-[13px] text-[#464647]", style: { lineHeight: 1.6 } },
14
+ hasPetInfo && (React.createElement("div", { className: "flex items-center gap-[10px]" },
15
+ React.createElement(LottiePlayer, { animationData: getAnimationIcon("petFriendlyAnim"), width: "20px", height: "20px" }),
16
+ React.createElement("div", { className: "h-auto mr-[4px] text-[13px] text-[#464647] bold-text" },
17
+ React.createElement("span", null, translation === null || translation === void 0 ? void 0 : translation.petFriendly)))),
13
18
  React.createElement("div", { className: "flex gap-[8px] text-[13.33px]" },
14
19
  React.createElement("span", { style: { marginTop: "2px" } }, "\u2022"),
15
20
  React.createElement("span", null,
@@ -22,7 +27,7 @@ function ExpandedDropdown({ serviceItem, }) {
22
27
  " horas antes"),
23
28
  " ",
24
29
  "de la salida del bus. Al anular tu pasaje recibir\u00E1s una devoluci\u00F3n del 85% del monto de tu compra.")),
25
- React.createElement("div", { className: "flex gap-[8px]" },
30
+ isPeru ? null : (React.createElement("div", { className: "flex gap-[8px]" },
26
31
  React.createElement("span", { style: { marginTop: "2px" } }, "\u2022"),
27
32
  React.createElement("span", null,
28
33
  React.createElement("span", { className: "bold-text" }, "Pol\u00EDticas de cambios:"),
@@ -33,6 +38,6 @@ function ExpandedDropdown({ serviceItem, }) {
33
38
  (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.change_ticket_hours) || 6,
34
39
  " horas antes"),
35
40
  " ",
36
- "de la salida del bus. El monto ser\u00E1 reembolsado a tu billetera kupospay.")))));
41
+ "de la salida del bus. El monto ser\u00E1 reembolsado a tu billetera kupospay."))))));
37
42
  }
38
43
  export default ExpandedDropdown;
@@ -6,6 +6,7 @@ interface ExpandedDropdownMobileProps {
6
6
  is_change_ticket?: boolean;
7
7
  is_tracking_enabled?: boolean;
8
8
  };
9
+ isPeru?: boolean;
9
10
  }
10
- declare function ExpandedDropdownMobile({ serviceItem, }: ExpandedDropdownMobileProps): React.ReactElement;
11
+ declare function ExpandedDropdownMobile({ serviceItem, isPeru, }: ExpandedDropdownMobileProps): React.ReactElement;
11
12
  export default ExpandedDropdownMobile;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- function ExpandedDropdownMobile({ serviceItem, }) {
2
+ function ExpandedDropdownMobile({ serviceItem, isPeru, }) {
3
3
  return (React.createElement("div", { className: "px-[12px] pt-[22px] pb-[12px] relative -z-9", style: {
4
4
  backgroundColor: "#ffefef",
5
5
  borderRadius: "0 0 14px 14px",
@@ -17,7 +17,7 @@ function ExpandedDropdownMobile({ serviceItem, }) {
17
17
  " horas antes"),
18
18
  " ",
19
19
  "de la salida del bus. Al anular tu pasaje recibir\u00E1s una devoluci\u00F3n del 85% del monto de tu compra.")),
20
- React.createElement("div", { className: "flex gap-[6px]" },
20
+ isPeru ? null : (React.createElement("div", { className: "flex gap-[6px]" },
21
21
  React.createElement("span", { style: { marginTop: "2px" } }, "\u2022"),
22
22
  React.createElement("span", null,
23
23
  React.createElement("span", { className: "bold-text" }, "Pol\u00EDticas de cambios:"),
@@ -28,6 +28,6 @@ function ExpandedDropdownMobile({ serviceItem, }) {
28
28
  (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.change_ticket_hours) || 6,
29
29
  " horas antes"),
30
30
  " ",
31
- "de la salida del bus. El monto ser\u00E1 reembolsado a tu billetera kupospay.")))));
31
+ "de la salida del bus. El monto ser\u00E1 reembolsado a tu billetera kupospay."))))));
32
32
  }
33
33
  export default ExpandedDropdownMobile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "9.1.10",
3
+ "version": "9.2.0",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -3,6 +3,8 @@ import { FilterBarProps } from "./tyoes";
3
3
  import commonService from "../../utils/CommonService";
4
4
  import ServiceFilter from "./ServiceFilter";
5
5
 
6
+ let cachedStageOptions: any[] | null = null;
7
+
6
8
  const FilterBarDesktop = ({
7
9
  t,
8
10
  serviceList,
@@ -28,47 +30,52 @@ const FilterBarDesktop = ({
28
30
  isAllinBus,
29
31
  }: FilterBarProps) => {
30
32
  const getEnrichedFilters = () => {
31
- if (!isAllinBus || !allSchedules?.length) return filtersArray;
32
-
33
33
  const hasSpecialDeparture = filtersArray.some(
34
34
  (f: any) => f.type === "special_departure" && f.options?.length > 0,
35
35
  );
36
36
  if (hasSpecialDeparture) return filtersArray;
37
37
 
38
- const stageMap = new Map<string, string>();
39
- allSchedules.forEach((schedule: any) => {
40
- if (schedule.stage_details_arr?.length) {
41
- const stageObj = schedule.stage_details_arr[0];
42
- const stageId = Object.keys(stageObj)[0];
43
- const stageName = stageObj[stageId]?.[0]?.split(", ")[0];
44
- if (stageId && stageName) {
45
- stageMap.set(stageId, stageName);
38
+ if (isAllinBus && allSchedules?.length) {
39
+ const stageMap = new Map<string, string>();
40
+ allSchedules.forEach((schedule: any) => {
41
+ if (schedule.stage_details_arr?.length) {
42
+ const stageObj = schedule.stage_details_arr[0];
43
+ const stageId = Object.keys(stageObj)[0];
44
+ const stageName = stageObj[stageId]?.[0]?.split(", ")[0];
45
+ if (stageId && stageName) {
46
+ stageMap.set(stageId, stageName);
47
+ }
46
48
  }
47
- }
48
- });
49
+ });
49
50
 
50
- if (stageMap.size === 0) return filtersArray;
51
+ if (stageMap.size > 0) {
52
+ cachedStageOptions = Array.from(stageMap.entries()).map(
53
+ ([id, name]) => ({
54
+ label: name,
55
+ value: id,
56
+ active: false,
57
+ }),
58
+ );
59
+ }
60
+ }
51
61
 
52
- const specialDeptOptions = Array.from(stageMap.entries()).map(
53
- ([id, name]) => ({
54
- label: name,
55
- value: id,
56
- active: false,
57
- }),
58
- );
62
+ if (cachedStageOptions?.length) {
63
+ return filtersArray.map((f: any) =>
64
+ f.type === "special_departure"
65
+ ? { ...f, options: cachedStageOptions! }
66
+ : f,
67
+ );
68
+ }
59
69
 
60
- return [
61
- ...filtersArray,
62
- {
63
- type: "special_departure",
64
- title: "SPECIAL_DEPARTURE",
65
- options: specialDeptOptions,
66
- },
67
- ];
70
+ return filtersArray;
68
71
  };
69
72
 
70
73
  const enrichedFilters = getEnrichedFilters();
71
74
 
75
+ if (enrichedFilters !== filtersArray) {
76
+ setFiltersArray(enrichedFilters);
77
+ }
78
+
72
79
  const filterBy = (filters) => {
73
80
  try {
74
81
  let routes = allSchedules;
@@ -496,6 +496,10 @@ function ServiceItemPB({
496
496
  // className="grid text-[#464647] w-full [grid-template-columns:18%_28%_2.5%_28%_15.5%] gap-x-[2%] items-center"
497
497
  className="grid text-[#464647] w-full [grid-template-columns:22%_28%_2.5%_24%_15.5%] gap-x-[2%] items-center"
498
498
  // style={{ marginTop: showTopLabel ? "8px" : "" }}
499
+ style={{
500
+ marginTop:
501
+ showTopLabel && serviceItem?.is_direct_trip ? "8px" : "",
502
+ }}
499
503
  >
500
504
  {/* OPERATOR LOGO */}
501
505
  <div
@@ -631,7 +635,12 @@ function ServiceItemPB({
631
635
  <div
632
636
  style={{ overflow: "hidden", minHeight: 0, marginTop: "-10px" }}
633
637
  >
634
- <ExpandedDropdown serviceItem={serviceItem} />
638
+ <ExpandedDropdown
639
+ serviceItem={serviceItem}
640
+ isPeru={isPeru}
641
+ translation={translation}
642
+ getAnimationIcon={getAnimationIcon}
643
+ />
635
644
  </div>
636
645
  </div>
637
646
 
@@ -497,7 +497,7 @@ function ServiceItemMobile({
497
497
  marginTop: serviceItem?.offer_text ? "-15px" : "-10px",
498
498
  }}
499
499
  >
500
- <ExpandedDropdownMobile serviceItem={serviceItem} />
500
+ <ExpandedDropdownMobile serviceItem={serviceItem} isPeru={isPeru} />
501
501
  </div>
502
502
  </div>
503
503
  </div>
@@ -8,10 +8,16 @@ interface ExpandedDropdownProps {
8
8
  is_change_ticket?: boolean;
9
9
  is_tracking_enabled?: boolean;
10
10
  };
11
+ isPeru?: boolean;
12
+ translation?: Record<string, string>;
13
+ getAnimationIcon?: (iconName: string) => any;
11
14
  }
12
15
 
13
16
  function ExpandedDropdown({
14
17
  serviceItem,
18
+ isPeru = false,
19
+ translation = {},
20
+ getAnimationIcon,
15
21
  }: ExpandedDropdownProps): React.ReactElement {
16
22
  const hasPetInfo =
17
23
  serviceItem.pet_seat_info &&
@@ -71,6 +77,18 @@ function ExpandedDropdown({
71
77
  className="flex flex-col gap-[10px] text-[13px] text-[#464647]"
72
78
  style={{ lineHeight: 1.6 }}
73
79
  >
80
+ {hasPetInfo && (
81
+ <div className="flex items-center gap-[10px]">
82
+ <LottiePlayer
83
+ animationData={getAnimationIcon("petFriendlyAnim")}
84
+ width="20px"
85
+ height="20px"
86
+ />
87
+ <div className="h-auto mr-[4px] text-[13px] text-[#464647] bold-text">
88
+ <span>{translation?.petFriendly}</span>
89
+ </div>
90
+ </div>
91
+ )}
74
92
  <div className="flex gap-[8px] text-[13.33px]">
75
93
  <span style={{ marginTop: "2px" }}>•</span>
76
94
  <span>
@@ -83,18 +101,20 @@ function ExpandedDropdown({
83
101
  del 85% del monto de tu compra.
84
102
  </span>
85
103
  </div>
86
- <div className="flex gap-[8px]">
87
- <span style={{ marginTop: "2px" }}>•</span>
88
- <span>
89
- <span className="bold-text">Políticas de cambios:</span> Tu pasaje
90
- puede ser cambiado de manera online{" "}
91
- <span className="bold-text">
92
- hasta {serviceItem?.change_ticket_hours || 6} horas antes
93
- </span>{" "}
94
- de la salida del bus. El monto será reembolsado a tu billetera
95
- kupospay.
96
- </span>
97
- </div>
104
+ {isPeru ? null : (
105
+ <div className="flex gap-[8px]">
106
+ <span style={{ marginTop: "2px" }}>•</span>
107
+ <span>
108
+ <span className="bold-text">Políticas de cambios:</span> Tu pasaje
109
+ puede ser cambiado de manera online{" "}
110
+ <span className="bold-text">
111
+ hasta {serviceItem?.change_ticket_hours || 6} horas antes
112
+ </span>{" "}
113
+ de la salida del bus. El monto será reembolsado a tu billetera
114
+ kupospay.
115
+ </span>
116
+ </div>
117
+ )}
98
118
  </div>
99
119
  </div>
100
120
  );
@@ -7,10 +7,12 @@ interface ExpandedDropdownMobileProps {
7
7
  is_change_ticket?: boolean;
8
8
  is_tracking_enabled?: boolean;
9
9
  };
10
+ isPeru?: boolean;
10
11
  }
11
12
 
12
13
  function ExpandedDropdownMobile({
13
14
  serviceItem,
15
+ isPeru,
14
16
  }: ExpandedDropdownMobileProps): React.ReactElement {
15
17
  return (
16
18
  <div
@@ -36,18 +38,20 @@ function ExpandedDropdownMobile({
36
38
  del 85% del monto de tu compra.
37
39
  </span>
38
40
  </div>
39
- <div className="flex gap-[6px]">
40
- <span style={{ marginTop: "2px" }}>•</span>
41
- <span>
42
- <span className="bold-text">Políticas de cambios:</span> Tu pasaje
43
- puede ser cambiado de manera online{" "}
44
- <span className="bold-text">
45
- hasta {serviceItem?.change_ticket_hours || 6} horas antes
46
- </span>{" "}
47
- de la salida del bus. El monto será reembolsado a tu billetera
48
- kupospay.
49
- </span>
50
- </div>
41
+ {isPeru ? null : (
42
+ <div className="flex gap-[6px]">
43
+ <span style={{ marginTop: "2px" }}>•</span>
44
+ <span>
45
+ <span className="bold-text">Políticas de cambios:</span> Tu pasaje
46
+ puede ser cambiado de manera online{" "}
47
+ <span className="bold-text">
48
+ hasta {serviceItem?.change_ticket_hours || 6} horas antes
49
+ </span>{" "}
50
+ de la salida del bus. El monto será reembolsado a tu billetera
51
+ kupospay.
52
+ </span>
53
+ </div>
54
+ )}
51
55
  </div>
52
56
  </div>
53
57
  );