kupos-ui-components-lib 9.11.0 → 9.11.1

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.
@@ -74,6 +74,17 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
74
74
  };
75
75
  const renderSeatPrices = () => {
76
76
  if (isPeru) {
77
+ const isMovilBus = (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.operator_service_name) === "MovilBus";
78
+ // Multiple unique seat types → show a price row for each (MovilBus only)
79
+ if (isMovilBus && uniqueSeats.length > 1) {
80
+ return uniqueSeats
81
+ .filter((s) => !SEAT_EXCEPTIONS.includes(s.label))
82
+ .map((val, key) => {
83
+ const { discountedPrice } = CommonService.calculateDiscountedPrice(val.price, serviceItem);
84
+ return (React.createElement("span", { key: key, className: "flex items-center text-[13.33px] bold-text" }, formatPrice(discountedPrice)));
85
+ });
86
+ }
87
+ // Single seat type → original behaviour (one lowest-fare price)
77
88
  const allSeats = getAllSeatTypes(seatTypes);
78
89
  const lowestFare = allSeats.length > 0 ? allSeats[0].price : 0;
79
90
  const { discountedPrice } = CommonService.calculateDiscountedPrice(lowestFare, serviceItem);
@@ -117,6 +128,14 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
117
128
  })();
118
129
  const renderLabels = () => {
119
130
  if (isPeru) {
131
+ const isMovilBus = (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.operator_service_name) === "MovilBus";
132
+ // Multiple unique seat types → show a label row for each (MovilBus only)
133
+ if (isMovilBus && uniqueSeats.length > 1) {
134
+ return uniqueSeats
135
+ .filter((s) => !SEAT_EXCEPTIONS.includes(s.label))
136
+ .map((val, key) => (React.createElement("span", { key: key, className: `flex items-center justify-between text-[13.33px] ${isSoldOut ? "text-[#c0c0c0]" : ""}` }, CommonService.truncateSeatLabel(val.label))));
137
+ }
138
+ // Single seat type → original behaviour
120
139
  const seats = removeDuplicateSeats ? uniqueSeats : sortedSeatTypes;
121
140
  const filteredSeats = seats.filter((s) => !SEAT_EXCEPTIONS.includes(s.label));
122
141
  const seatLabel = filteredSeats.length > 0
@@ -125,7 +144,6 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
125
144
  : filteredSeats[0].label
126
145
  : null;
127
146
  const operatorServiceName = (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.operator_service_name) === "MovilBus";
128
- const bottomLabel = operatorServiceName || "Desde";
129
147
  return (React.createElement(React.Fragment, null,
130
148
  hasDiscount && (React.createElement("span", { className: "text-[13.33px]", style: {
131
149
  color: "#999",
@@ -64,21 +64,29 @@ function SeatSectionMobile({ seatTypes: seatTypesData, isSoldOut, isPeru, seatPr
64
64
  if (lowestFare === null)
65
65
  return null;
66
66
  const priceColor = isSoldOut ? "#bbb" : seatPriceColor;
67
- const { originalPrice, discountedPrice } = commonService.calculateDiscountedPrice(lowestFare, serviceItem);
68
67
  const isMovilBus = (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.operator_service_name) === "MovilBus";
69
- const uniqueSeats = getUniqueSeats(seatTypesData !== null && seatTypesData !== void 0 ? seatTypesData : [], 1);
68
+ // Fetch ALL unique seats (no slice limit) for the multi-row MovilBus case
69
+ const uniqueSeats = getUniqueSeats(seatTypesData !== null && seatTypesData !== void 0 ? seatTypesData : [], Infinity);
70
+ // MovilBus + multiple unique seat types → render a row per seat
71
+ if (isMovilBus && uniqueSeats.length > 1) {
72
+ return (React.createElement(React.Fragment, null, uniqueSeats.map((seat, key) => {
73
+ const { discountedPrice } = commonService.calculateDiscountedPrice(Number(seat.fare), serviceItem);
74
+ return (React.createElement("div", { key: key, className: "w-[100%] flex flex-row justify-between items-center" },
75
+ React.createElement("span", { className: "min-[420]:text-[13px] text-[12px] bold-text", style: { color: isSoldOut ? "#bbb" : "#464647" } }, commonService.truncateSeatLabel(seat.label)),
76
+ React.createElement("span", { className: "min-[420]:text-[13px] text-[12px] bold-text", style: { color: priceColor } }, commonService.currency(discountedPrice, currencySign))));
77
+ })));
78
+ }
79
+ // Single seat type (or non-MovilBus) → original behaviour
80
+ const { originalPrice, discountedPrice } = commonService.calculateDiscountedPrice(lowestFare, serviceItem);
70
81
  const seatLabel = uniqueSeats.length > 0
71
82
  ? commonService.truncateSeatLabel(uniqueSeats[0].label)
72
83
  : null;
73
- const bottomLabel = isMovilBus ? seatLabel || "Desde" : "Desde";
74
84
  return (React.createElement(React.Fragment, null,
75
85
  originalPrice !== discountedPrice && (React.createElement("div", { className: "w-[100%] flex flex-row justify-between items-center" },
76
86
  React.createElement("span", { className: "min-[420]:text-[13px] text-[12px]", style: { color: "#bbb" } }, "Antes"),
77
87
  React.createElement("span", { className: "min-[420]:text-[13px] text-[12px] line-through", style: { color: "#bbb" } }, commonService.currency(originalPrice, currencySign)))),
78
88
  React.createElement("div", { className: "w-[100%] flex flex-row justify-between items-center" },
79
- React.createElement("span", { className: "min-[420]:text-[13px] text-[12px] bold-text", style: { color: isSoldOut ? "#bbb" : "#464647" } }, (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.operator_service_name) === "MovilBus"
80
- ? seatLabel
81
- : "Desde"),
89
+ React.createElement("span", { className: "min-[420]:text-[13px] text-[12px] bold-text", style: { color: isSoldOut ? "#bbb" : "#464647" } }, isMovilBus ? seatLabel || "Desde" : "Desde"),
82
90
  React.createElement("span", { className: "min-[420]:text-[13px] text-[12px] bold-text", style: { color: priceColor } }, commonService.currency(discountedPrice, currencySign)))));
83
91
  };
84
92
  const renderDpSeats = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "9.11.0",
3
+ "version": "9.11.1",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -139,6 +139,26 @@ function SeatSection({
139
139
 
140
140
  const renderSeatPrices = () => {
141
141
  if (isPeru) {
142
+ const isMovilBus = serviceItem?.operator_service_name === "MovilBus";
143
+
144
+ // Multiple unique seat types → show a price row for each (MovilBus only)
145
+ if (isMovilBus && uniqueSeats.length > 1) {
146
+ return uniqueSeats
147
+ .filter((s) => !SEAT_EXCEPTIONS.includes(s.label))
148
+ .map((val, key) => {
149
+ const { discountedPrice } = CommonService.calculateDiscountedPrice(
150
+ val.price,
151
+ serviceItem,
152
+ );
153
+ return (
154
+ <span key={key} className="flex items-center text-[13.33px] bold-text">
155
+ {formatPrice(discountedPrice)}
156
+ </span>
157
+ );
158
+ });
159
+ }
160
+
161
+ // Single seat type → original behaviour (one lowest-fare price)
142
162
  const allSeats = getAllSeatTypes(seatTypes);
143
163
  const lowestFare = allSeats.length > 0 ? allSeats[0].price : 0;
144
164
  const { discountedPrice } = CommonService.calculateDiscountedPrice(
@@ -218,6 +238,25 @@ function SeatSection({
218
238
 
219
239
  const renderLabels = () => {
220
240
  if (isPeru) {
241
+ const isMovilBus = serviceItem?.operator_service_name === "MovilBus";
242
+
243
+ // Multiple unique seat types → show a label row for each (MovilBus only)
244
+ if (isMovilBus && uniqueSeats.length > 1) {
245
+ return uniqueSeats
246
+ .filter((s) => !SEAT_EXCEPTIONS.includes(s.label))
247
+ .map((val, key) => (
248
+ <span
249
+ key={key}
250
+ className={`flex items-center justify-between text-[13.33px] ${
251
+ isSoldOut ? "text-[#c0c0c0]" : ""
252
+ }`}
253
+ >
254
+ {CommonService.truncateSeatLabel(val.label)}
255
+ </span>
256
+ ));
257
+ }
258
+
259
+ // Single seat type → original behaviour
221
260
  const seats = removeDuplicateSeats ? uniqueSeats : sortedSeatTypes;
222
261
  const filteredSeats = seats.filter(
223
262
  (s) => !SEAT_EXCEPTIONS.includes(s.label),
@@ -231,7 +270,6 @@ function SeatSection({
231
270
 
232
271
  const operatorServiceName =
233
272
  serviceItem?.operator_service_name === "MovilBus";
234
- const bottomLabel = operatorServiceName || "Desde";
235
273
 
236
274
  return (
237
275
  <>
@@ -149,16 +149,52 @@ function SeatSectionMobile({
149
149
  if (lowestFare === null) return null;
150
150
 
151
151
  const priceColor = isSoldOut ? "#bbb" : seatPriceColor;
152
+ const isMovilBus = serviceItem?.operator_service_name === "MovilBus";
153
+
154
+ // Fetch ALL unique seats (no slice limit) for the multi-row MovilBus case
155
+ const uniqueSeats = getUniqueSeats(seatTypesData ?? [], Infinity as number);
156
+
157
+ // MovilBus + multiple unique seat types → render a row per seat
158
+ if (isMovilBus && uniqueSeats.length > 1) {
159
+ return (
160
+ <>
161
+ {uniqueSeats.map((seat, key) => {
162
+ const { discountedPrice } = commonService.calculateDiscountedPrice(
163
+ Number(seat.fare),
164
+ serviceItem,
165
+ );
166
+ return (
167
+ <div
168
+ key={key}
169
+ className="w-[100%] flex flex-row justify-between items-center"
170
+ >
171
+ <span
172
+ className="min-[420]:text-[13px] text-[12px] bold-text"
173
+ style={{ color: isSoldOut ? "#bbb" : "#464647" }}
174
+ >
175
+ {commonService.truncateSeatLabel(seat.label)}
176
+ </span>
177
+ <span
178
+ className="min-[420]:text-[13px] text-[12px] bold-text"
179
+ style={{ color: priceColor }}
180
+ >
181
+ {commonService.currency(discountedPrice, currencySign)}
182
+ </span>
183
+ </div>
184
+ );
185
+ })}
186
+ </>
187
+ );
188
+ }
189
+
190
+ // Single seat type (or non-MovilBus) → original behaviour
152
191
  const { originalPrice, discountedPrice } =
153
192
  commonService.calculateDiscountedPrice(lowestFare, serviceItem);
154
193
 
155
- const isMovilBus = serviceItem?.operator_service_name === "MovilBus";
156
- const uniqueSeats = getUniqueSeats(seatTypesData ?? [], 1);
157
194
  const seatLabel =
158
195
  uniqueSeats.length > 0
159
196
  ? commonService.truncateSeatLabel(uniqueSeats[0].label)
160
197
  : null;
161
- const bottomLabel = isMovilBus ? seatLabel || "Desde" : "Desde";
162
198
 
163
199
  return (
164
200
  <>
@@ -183,9 +219,7 @@ function SeatSectionMobile({
183
219
  className="min-[420]:text-[13px] text-[12px] bold-text"
184
220
  style={{ color: isSoldOut ? "#bbb" : "#464647" }}
185
221
  >
186
- {serviceItem?.operator_service_name === "MovilBus"
187
- ? seatLabel
188
- : "Desde"}
222
+ {isMovilBus ? seatLabel || "Desde" : "Desde"}
189
223
  </span>
190
224
  <span
191
225
  className="min-[420]:text-[13px] text-[12px] bold-text"