kupos-ui-components-lib 9.8.5 → 9.8.6
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/ServiceItem/ServiceItemDesktop.d.ts +1 -1
- package/dist/components/ServiceItem/ServiceItemDesktop.js +20 -2
- package/dist/components/ServiceItem/types.d.ts +7 -0
- package/dist/styles.css +3 -0
- package/dist/ui/SeatSection/SeatSection.d.ts +7 -1
- package/dist/ui/SeatSection/SeatSection.js +31 -6
- package/package.json +1 -1
- package/src/components/ServiceItem/ServiceItemDesktop.tsx +43 -0
- package/src/components/ServiceItem/types.ts +24 -12
- package/src/ui/SeatSection/SeatSection.tsx +76 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ServiceItemProps } from "./types";
|
|
3
|
-
declare 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, siteType, isAllinBus, isExpand, setIsExpand, coachKey, viewersConfig, showLoginModal, isLoggedIn, showLoginOption, isFlores, }: ServiceItemProps & {
|
|
3
|
+
declare 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, siteType, isAllinBus, isExpand, setIsExpand, coachKey, viewersConfig, showLoginModal, isLoggedIn, showLoginOption, isTrain, selectedSeatKey, onSeatSelect, onTrainButtonClick, showSeatSelectionError, onShowSeatSelectionError, onClearSeatSelectionError, isFlores, }: ServiceItemProps & {
|
|
4
4
|
currencySign?: string;
|
|
5
5
|
}): React.ReactElement;
|
|
6
6
|
export default ServiceItemPB;
|
|
@@ -74,8 +74,12 @@ const ANIMATION_MAP = {
|
|
|
74
74
|
kupos: femaleAnimation,
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
|
-
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, isExpand, setIsExpand, coachKey, viewersConfig, showLoginModal, isLoggedIn, showLoginOption, isFlores, }) {
|
|
77
|
+
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, isExpand, setIsExpand, coachKey, viewersConfig, showLoginModal, isLoggedIn, showLoginOption, isTrain, selectedSeatKey, onSeatSelect, onTrainButtonClick, showSeatSelectionError, onShowSeatSelectionError, onClearSeatSelectionError, isFlores, }) {
|
|
78
78
|
var _a;
|
|
79
|
+
const handleSeatSelect = (key, price, seatKey, apiSeatType) => {
|
|
80
|
+
onClearSeatSelectionError === null || onClearSeatSelectionError === void 0 ? void 0 : onClearSeatSelectionError();
|
|
81
|
+
onSeatSelect === null || onSeatSelect === void 0 ? void 0 : onSeatSelect(key, price, seatKey, apiSeatType);
|
|
82
|
+
};
|
|
79
83
|
const getAnimationIcon = (icon) => {
|
|
80
84
|
var _a;
|
|
81
85
|
const animation = ANIMATION_MAP[icon];
|
|
@@ -213,6 +217,16 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
|
|
|
213
217
|
});
|
|
214
218
|
return;
|
|
215
219
|
}
|
|
220
|
+
if (isTrain) {
|
|
221
|
+
if (!selectedSeatKey) {
|
|
222
|
+
onShowSeatSelectionError === null || onShowSeatSelectionError === void 0 ? void 0 : onShowSeatSelectionError(serviceItem.id);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (onTrainButtonClick) {
|
|
226
|
+
onTrainButtonClick();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
216
230
|
onBookButtonPress();
|
|
217
231
|
};
|
|
218
232
|
const items = [
|
|
@@ -275,9 +289,13 @@ function ServiceItemPB({ serviceItem, onBookButtonPress, colors, metaData, child
|
|
|
275
289
|
backgroundColor: "#ccc",
|
|
276
290
|
} }),
|
|
277
291
|
React.createElement("div", { className: "content-center" },
|
|
278
|
-
React.createElement(SeatSection, { seatTypes: serviceItem.seat_types, serviceItem: serviceItem, availableSeats: serviceItem.available_seats, isSoldOut: isSoldOut, priceColor: colors.priceColor, dpSeatColor: colors.seatPriceColor, currencySign: currencySign, removeDuplicateSeats: removeDuplicateSeats, isPeru: isPeru, renderIcon: renderIcon, discountSeatPriceColor: colors.discountSeatPriceColor })),
|
|
292
|
+
React.createElement(SeatSection, { seatTypes: serviceItem.seat_types, serviceItem: serviceItem, availableSeats: serviceItem.available_seats, isSoldOut: isSoldOut, priceColor: colors.priceColor, dpSeatColor: colors.seatPriceColor, currencySign: currencySign, removeDuplicateSeats: removeDuplicateSeats, isPeru: isPeru, renderIcon: renderIcon, discountSeatPriceColor: colors.discountSeatPriceColor, isTrain: isTrain, selectedSeatKey: selectedSeatKey, onSeatSelect: handleSeatSelect, topLabelColor: colors.topLabelColor })),
|
|
279
293
|
React.createElement("div", { className: "relative" },
|
|
280
294
|
React.createElement(KuposButton, { isSoldOut: isSoldOut, isLoading: serviceDetailsLoading, buttonColor: colors.kuposButtonColor, buyLabel: translation === null || translation === void 0 ? void 0 : translation.buyButton, soldOutLabel: translation === null || translation === void 0 ? void 0 : translation.soldOutButton, soldOutIcon: renderIcon("soldOutIcon", "14px"), onClick: checkMidnight }),
|
|
295
|
+
showSeatSelectionError === serviceItem.id && isTrain && (React.createElement("div", { className: "flex justify-center mr-[11px] w-[100%] right-[0px] absolute left-[0] top-[40px]" },
|
|
296
|
+
React.createElement("div", { className: "text-[9px] text-center whitespace-nowrap", style: {
|
|
297
|
+
color: colors.seatPriceColor,
|
|
298
|
+
} }, "Selecciona el tipo de servicio"))),
|
|
281
299
|
showLastSeats ? (React.createElement("div", { className: "flex justify-center mr-[11px] w-[100%] right-[0px] absolute left-[0] top-[40px]" }, (serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.available_seats) < 10 &&
|
|
282
300
|
(serviceItem === null || serviceItem === void 0 ? void 0 : serviceItem.available_seats) > 0 && (React.createElement("div", { className: "text-[12px] mt-1 text-center", style: {
|
|
283
301
|
color: colors.seatPriceColor,
|
|
@@ -224,5 +224,12 @@ export interface ServiceItemProps {
|
|
|
224
224
|
showLoginModal?: any;
|
|
225
225
|
isLoggedIn?: any;
|
|
226
226
|
showLoginOption?: boolean;
|
|
227
|
+
isTrain?: boolean;
|
|
228
|
+
selectedSeatKey?: any;
|
|
229
|
+
onSeatSelect?: (key: any, price: number, seatKey: string, apiSeatType?: string) => void;
|
|
230
|
+
onTrainButtonClick?: any;
|
|
231
|
+
showSeatSelectionError?: string | null;
|
|
232
|
+
onShowSeatSelectionError?: (serviceId: string) => void;
|
|
233
|
+
onClearSeatSelectionError?: () => void;
|
|
227
234
|
isFlores?: boolean;
|
|
228
235
|
}
|
package/dist/styles.css
CHANGED
|
@@ -3,6 +3,8 @@ interface SeatType {
|
|
|
3
3
|
label: string;
|
|
4
4
|
fare: number;
|
|
5
5
|
key: any;
|
|
6
|
+
apiSeatType?: string;
|
|
7
|
+
api_seat_type?: string;
|
|
6
8
|
}
|
|
7
9
|
interface SeatSectionProps {
|
|
8
10
|
seatTypes: SeatType[];
|
|
@@ -16,6 +18,10 @@ interface SeatSectionProps {
|
|
|
16
18
|
serviceItem?: any;
|
|
17
19
|
renderIcon?: (iconKey: string, size?: string) => React.ReactNode;
|
|
18
20
|
discountSeatPriceColor?: string;
|
|
21
|
+
isTrain?: boolean;
|
|
22
|
+
selectedSeatKey?: any;
|
|
23
|
+
onSeatSelect?: (key: any, price: number, seatKey: string, apiSeatType?: string) => void;
|
|
24
|
+
topLabelColor?: string;
|
|
19
25
|
}
|
|
20
|
-
declare function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currencySign, removeDuplicateSeats, isPeru, serviceItem, renderIcon, dpSeatColor, discountSeatPriceColor, }: SeatSectionProps): React.ReactElement;
|
|
26
|
+
declare function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currencySign, removeDuplicateSeats, selectedSeatKey, onSeatSelect, isPeru, serviceItem, renderIcon, dpSeatColor, discountSeatPriceColor, isTrain, topLabelColor, }: SeatSectionProps): React.ReactElement;
|
|
21
27
|
export default SeatSection;
|
|
@@ -8,6 +8,8 @@ function getAllSeatTypes(seatTypes) {
|
|
|
8
8
|
let seatTypesWithPrices = seatTypes.filter(Boolean).map((val) => ({
|
|
9
9
|
label: val === null || val === void 0 ? void 0 : val.label,
|
|
10
10
|
price: val === null || val === void 0 ? void 0 : val.fare,
|
|
11
|
+
key: val === null || val === void 0 ? void 0 : val.key,
|
|
12
|
+
apiSeatType: (val === null || val === void 0 ? void 0 : val.apiSeatType) || (val === null || val === void 0 ? void 0 : val.api_seat_type),
|
|
11
13
|
}));
|
|
12
14
|
seatTypesWithPrices.sort((a, b) => a.price - b.price);
|
|
13
15
|
return seatTypesWithPrices;
|
|
@@ -54,7 +56,7 @@ function getUniqueSeats(seatTypes) {
|
|
|
54
56
|
function getNumberOfSeats(seatTypes) {
|
|
55
57
|
return seatTypes.filter((val) => !SEAT_EXCEPTIONS.includes(val.label)).length;
|
|
56
58
|
}
|
|
57
|
-
function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currencySign, removeDuplicateSeats, isPeru, serviceItem, renderIcon, dpSeatColor, discountSeatPriceColor, }) {
|
|
59
|
+
function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currencySign, removeDuplicateSeats, selectedSeatKey, onSeatSelect, isPeru, serviceItem, renderIcon, dpSeatColor, discountSeatPriceColor, isTrain, topLabelColor, }) {
|
|
58
60
|
var _a;
|
|
59
61
|
const uniqueSeats = getUniqueSeats(seatTypes);
|
|
60
62
|
const sortedSeatTypes = getSortedSeatTypes(seatTypes);
|
|
@@ -65,11 +67,34 @@ function SeatSection({ seatTypes, availableSeats, isSoldOut, priceColor, currenc
|
|
|
65
67
|
: CommonService.currency(price, currencySign);
|
|
66
68
|
const renderSeatNames = () => {
|
|
67
69
|
const seats = removeDuplicateSeats ? uniqueSeats : sortedSeatTypes;
|
|
68
|
-
return seats.map((val, key) =>
|
|
69
|
-
?
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
return seats.map((val, key) => {
|
|
71
|
+
return SEAT_EXCEPTIONS.includes(val.label) ? null : (React.createElement("div", { className: "flex items-center", style: isTrain ? { cursor: "pointer" } : undefined, onClick: isTrain && !isSoldOut
|
|
72
|
+
? () => val.label === selectedSeatKey
|
|
73
|
+
? onSeatSelect === null || onSeatSelect === void 0 ? void 0 : onSeatSelect(null, 0, "", "")
|
|
74
|
+
: onSeatSelect === null || onSeatSelect === void 0 ? void 0 : onSeatSelect(val.label, val.price, val.key, val.apiSeatType)
|
|
75
|
+
: undefined },
|
|
76
|
+
isTrain && (React.createElement("div", { style: {
|
|
77
|
+
border: `1px solid ${val.label === selectedSeatKey ? topLabelColor : "#ccc"}`,
|
|
78
|
+
borderRadius: "50%",
|
|
79
|
+
width: "14px",
|
|
80
|
+
height: "14px",
|
|
81
|
+
minWidth: "14px",
|
|
82
|
+
marginRight: "10px",
|
|
83
|
+
display: "flex",
|
|
84
|
+
alignItems: "center",
|
|
85
|
+
justifyContent: "center",
|
|
86
|
+
} }, val.label === selectedSeatKey && (React.createElement("div", { style: {
|
|
87
|
+
backgroundColor: topLabelColor,
|
|
88
|
+
borderRadius: "50%",
|
|
89
|
+
width: "7px",
|
|
90
|
+
height: "7px",
|
|
91
|
+
} })))),
|
|
92
|
+
React.createElement("span", { key: key, className: `flex items-center justify-between text-[13.33px] ${isSoldOut ? "text-[#c0c0c0]" : ""}` }, typeof val.label === "string" || typeof val.label === "number"
|
|
93
|
+
? removeDuplicateSeats && isPeru
|
|
94
|
+
? CommonService.truncateSeatLabel(val.label)
|
|
95
|
+
: val.label
|
|
96
|
+
: null)));
|
|
97
|
+
});
|
|
73
98
|
};
|
|
74
99
|
const renderSeatPrices = () => {
|
|
75
100
|
if (isPeru) {
|
package/package.json
CHANGED
|
@@ -116,8 +116,24 @@ function ServiceItemPB({
|
|
|
116
116
|
showLoginModal,
|
|
117
117
|
isLoggedIn,
|
|
118
118
|
showLoginOption,
|
|
119
|
+
isTrain,
|
|
120
|
+
selectedSeatKey,
|
|
121
|
+
onSeatSelect,
|
|
122
|
+
onTrainButtonClick,
|
|
123
|
+
showSeatSelectionError,
|
|
124
|
+
onShowSeatSelectionError,
|
|
125
|
+
onClearSeatSelectionError,
|
|
119
126
|
isFlores,
|
|
120
127
|
}: ServiceItemProps & { currencySign?: string }): React.ReactElement {
|
|
128
|
+
const handleSeatSelect = (
|
|
129
|
+
key: any,
|
|
130
|
+
price: number,
|
|
131
|
+
seatKey: string,
|
|
132
|
+
apiSeatType?: string,
|
|
133
|
+
) => {
|
|
134
|
+
onClearSeatSelectionError?.();
|
|
135
|
+
onSeatSelect?.(key, price, seatKey, apiSeatType);
|
|
136
|
+
};
|
|
121
137
|
const getAnimationIcon = (icon: string) => {
|
|
122
138
|
const animation = ANIMATION_MAP[icon];
|
|
123
139
|
if (!animation) return null;
|
|
@@ -314,6 +330,17 @@ function ServiceItemPB({
|
|
|
314
330
|
return;
|
|
315
331
|
}
|
|
316
332
|
|
|
333
|
+
if (isTrain) {
|
|
334
|
+
if (!selectedSeatKey) {
|
|
335
|
+
onShowSeatSelectionError?.(serviceItem.id);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (onTrainButtonClick) {
|
|
339
|
+
onTrainButtonClick();
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
317
344
|
onBookButtonPress();
|
|
318
345
|
};
|
|
319
346
|
|
|
@@ -527,6 +554,10 @@ function ServiceItemPB({
|
|
|
527
554
|
isPeru={isPeru}
|
|
528
555
|
renderIcon={renderIcon}
|
|
529
556
|
discountSeatPriceColor={colors.discountSeatPriceColor}
|
|
557
|
+
isTrain={isTrain}
|
|
558
|
+
selectedSeatKey={selectedSeatKey}
|
|
559
|
+
onSeatSelect={handleSeatSelect}
|
|
560
|
+
topLabelColor={colors.topLabelColor}
|
|
530
561
|
/>
|
|
531
562
|
</div>
|
|
532
563
|
|
|
@@ -542,6 +573,18 @@ function ServiceItemPB({
|
|
|
542
573
|
soldOutIcon={renderIcon("soldOutIcon", "14px")}
|
|
543
574
|
onClick={checkMidnight}
|
|
544
575
|
/>
|
|
576
|
+
{showSeatSelectionError === serviceItem.id && isTrain && (
|
|
577
|
+
<div className="flex justify-center mr-[11px] w-[100%] right-[0px] absolute left-[0] top-[40px]">
|
|
578
|
+
<div
|
|
579
|
+
className="text-[9px] text-center whitespace-nowrap"
|
|
580
|
+
style={{
|
|
581
|
+
color: colors.seatPriceColor,
|
|
582
|
+
}}
|
|
583
|
+
>
|
|
584
|
+
Selecciona el tipo de servicio
|
|
585
|
+
</div>
|
|
586
|
+
</div>
|
|
587
|
+
)}
|
|
545
588
|
{showLastSeats ? (
|
|
546
589
|
<div className="flex justify-center mr-[11px] w-[100%] right-[0px] absolute left-[0] top-[40px]">
|
|
547
590
|
{serviceItem?.available_seats < 10 &&
|
|
@@ -125,12 +125,12 @@ export interface ServiceItemProps {
|
|
|
125
125
|
seatFallBackIcon: string;
|
|
126
126
|
headPhoneIcon?: string;
|
|
127
127
|
allowCancellationIcon?: string;
|
|
128
|
-
whiteBoardingIcon?: string
|
|
129
|
-
bombJson?:string
|
|
130
|
-
downArrow?:string
|
|
131
|
-
personIcon?: string
|
|
132
|
-
whiteFireIcon?: string
|
|
133
|
-
fireIcon?: string
|
|
128
|
+
whiteBoardingIcon?: string;
|
|
129
|
+
bombJson?: string;
|
|
130
|
+
downArrow?: string;
|
|
131
|
+
personIcon?: string;
|
|
132
|
+
whiteFireIcon?: string;
|
|
133
|
+
fireIcon?: string;
|
|
134
134
|
|
|
135
135
|
[key: string]: string | Record<string, string | undefined> | undefined;
|
|
136
136
|
};
|
|
@@ -161,7 +161,7 @@ export interface ServiceItemProps {
|
|
|
161
161
|
seatPriceColor?: string;
|
|
162
162
|
rightGradiantColor?: string;
|
|
163
163
|
leftGradiantColor?: string;
|
|
164
|
-
discountSeatPriceColor?: string
|
|
164
|
+
discountSeatPriceColor?: string;
|
|
165
165
|
};
|
|
166
166
|
cityOrigin?: { value: number; label: string };
|
|
167
167
|
cityDestination?: { value: number; label: string };
|
|
@@ -215,7 +215,7 @@ export interface ServiceItemProps {
|
|
|
215
215
|
isAllinBus?: boolean;
|
|
216
216
|
isExpand?: any;
|
|
217
217
|
setIsExpand?: (value: any) => void;
|
|
218
|
-
coachKey?: number
|
|
218
|
+
coachKey?: number;
|
|
219
219
|
viewersConfig?: {
|
|
220
220
|
min: number;
|
|
221
221
|
max: number;
|
|
@@ -223,8 +223,20 @@ export interface ServiceItemProps {
|
|
|
223
223
|
label?: string; // e.g. "personas están viendo este viaje"
|
|
224
224
|
icon?: string; // optional icon URL
|
|
225
225
|
};
|
|
226
|
-
showLoginModal?: any
|
|
227
|
-
isLoggedIn?: any
|
|
228
|
-
showLoginOption?: boolean
|
|
229
|
-
|
|
226
|
+
showLoginModal?: any;
|
|
227
|
+
isLoggedIn?: any;
|
|
228
|
+
showLoginOption?: boolean;
|
|
229
|
+
isTrain?: boolean;
|
|
230
|
+
selectedSeatKey?: any;
|
|
231
|
+
onSeatSelect?: (
|
|
232
|
+
key: any,
|
|
233
|
+
price: number,
|
|
234
|
+
seatKey: string,
|
|
235
|
+
apiSeatType?: string,
|
|
236
|
+
) => void;
|
|
237
|
+
onTrainButtonClick?: any;
|
|
238
|
+
showSeatSelectionError?: string | null;
|
|
239
|
+
onShowSeatSelectionError?: (serviceId: string) => void;
|
|
240
|
+
onClearSeatSelectionError?: () => void;
|
|
241
|
+
isFlores?: boolean;
|
|
230
242
|
}
|
|
@@ -7,6 +7,8 @@ interface SeatType {
|
|
|
7
7
|
label: string;
|
|
8
8
|
fare: number;
|
|
9
9
|
key: any;
|
|
10
|
+
apiSeatType?: string;
|
|
11
|
+
api_seat_type?: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
interface SeatSectionProps {
|
|
@@ -21,6 +23,15 @@ interface SeatSectionProps {
|
|
|
21
23
|
serviceItem?: any;
|
|
22
24
|
renderIcon?: (iconKey: string, size?: string) => React.ReactNode;
|
|
23
25
|
discountSeatPriceColor?: string;
|
|
26
|
+
isTrain?: boolean;
|
|
27
|
+
selectedSeatKey?: any;
|
|
28
|
+
onSeatSelect?: (
|
|
29
|
+
key: any,
|
|
30
|
+
price: number,
|
|
31
|
+
seatKey: string,
|
|
32
|
+
apiSeatType?: string,
|
|
33
|
+
) => void;
|
|
34
|
+
topLabelColor?: string;
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
function getAllSeatTypes(seatTypes: SeatType[]) {
|
|
@@ -31,6 +42,8 @@ function getAllSeatTypes(seatTypes: SeatType[]) {
|
|
|
31
42
|
let seatTypesWithPrices = seatTypes.filter(Boolean).map((val) => ({
|
|
32
43
|
label: val?.label,
|
|
33
44
|
price: val?.fare,
|
|
45
|
+
key: val?.key,
|
|
46
|
+
apiSeatType: val?.apiSeatType || val?.api_seat_type,
|
|
34
47
|
}));
|
|
35
48
|
|
|
36
49
|
seatTypesWithPrices.sort((a, b) => a.price - b.price);
|
|
@@ -97,11 +110,15 @@ function SeatSection({
|
|
|
97
110
|
priceColor,
|
|
98
111
|
currencySign,
|
|
99
112
|
removeDuplicateSeats,
|
|
113
|
+
selectedSeatKey,
|
|
114
|
+
onSeatSelect,
|
|
100
115
|
isPeru,
|
|
101
116
|
serviceItem,
|
|
102
117
|
renderIcon,
|
|
103
118
|
dpSeatColor,
|
|
104
119
|
discountSeatPriceColor,
|
|
120
|
+
isTrain,
|
|
121
|
+
topLabelColor,
|
|
105
122
|
}: SeatSectionProps): React.ReactElement {
|
|
106
123
|
const uniqueSeats = getUniqueSeats(seatTypes);
|
|
107
124
|
const sortedSeatTypes = getSortedSeatTypes(seatTypes);
|
|
@@ -116,22 +133,66 @@ function SeatSection({
|
|
|
116
133
|
const renderSeatNames = () => {
|
|
117
134
|
const seats = removeDuplicateSeats ? uniqueSeats : sortedSeatTypes;
|
|
118
135
|
|
|
119
|
-
return seats.map((val, key: number) =>
|
|
120
|
-
SEAT_EXCEPTIONS.includes(val.label) ? null : (
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
return seats.map((val, key: number) => {
|
|
137
|
+
return SEAT_EXCEPTIONS.includes(val.label) ? null : (
|
|
138
|
+
<div
|
|
139
|
+
className="flex items-center"
|
|
140
|
+
style={isTrain ? { cursor: "pointer" } : undefined}
|
|
141
|
+
onClick={
|
|
142
|
+
isTrain && !isSoldOut
|
|
143
|
+
? () =>
|
|
144
|
+
val.label === selectedSeatKey
|
|
145
|
+
? onSeatSelect?.(null, 0, "", "")
|
|
146
|
+
: onSeatSelect?.(
|
|
147
|
+
val.label,
|
|
148
|
+
val.price,
|
|
149
|
+
val.key,
|
|
150
|
+
(val as any).apiSeatType,
|
|
151
|
+
)
|
|
152
|
+
: undefined
|
|
153
|
+
}
|
|
126
154
|
>
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
155
|
+
{isTrain && (
|
|
156
|
+
<div
|
|
157
|
+
style={{
|
|
158
|
+
border: `1px solid ${val.label === selectedSeatKey ? topLabelColor : "#ccc"}`,
|
|
159
|
+
borderRadius: "50%",
|
|
160
|
+
width: "14px",
|
|
161
|
+
height: "14px",
|
|
162
|
+
minWidth: "14px",
|
|
163
|
+
marginRight: "10px",
|
|
164
|
+
display: "flex",
|
|
165
|
+
alignItems: "center",
|
|
166
|
+
justifyContent: "center",
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
{val.label === selectedSeatKey && (
|
|
170
|
+
<div
|
|
171
|
+
style={{
|
|
172
|
+
backgroundColor: topLabelColor,
|
|
173
|
+
borderRadius: "50%",
|
|
174
|
+
width: "7px",
|
|
175
|
+
height: "7px",
|
|
176
|
+
}}
|
|
177
|
+
/>
|
|
178
|
+
)}
|
|
179
|
+
</div>
|
|
180
|
+
)}
|
|
181
|
+
<span
|
|
182
|
+
key={key}
|
|
183
|
+
className={`flex items-center justify-between text-[13.33px] ${
|
|
184
|
+
isSoldOut ? "text-[#c0c0c0]" : ""
|
|
185
|
+
}`}
|
|
186
|
+
>
|
|
187
|
+
{typeof val.label === "string" || typeof val.label === "number"
|
|
188
|
+
? removeDuplicateSeats && isPeru
|
|
189
|
+
? CommonService.truncateSeatLabel(val.label)
|
|
190
|
+
: val.label
|
|
191
|
+
: null}
|
|
192
|
+
</span>
|
|
193
|
+
</div>
|
|
194
|
+
);
|
|
195
|
+
});
|
|
135
196
|
};
|
|
136
197
|
|
|
137
198
|
const renderSeatPrices = () => {
|