mautourco-components 0.2.155 → 0.2.156
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/molecules/BookingPax/BookingPaxAccom.js +5 -18
- package/dist/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.js +1 -1
- package/dist/components/organisms/Booking/BookingPaxList.d.ts +7 -1
- package/dist/components/organisms/Booking/BookingPaxList.js +16 -5
- package/package.json +1 -1
- package/src/components/molecules/BookingPax/BookingPaxAccom.tsx +5 -18
- package/src/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.tsx +1 -1
- package/src/components/organisms/Booking/BookingPaxList.tsx +24 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import useBookingPax from '../../../hooks/useBookingPax';
|
|
3
|
-
import { useEffect, useMemo
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
4
|
import TextWithIcon from '../TextWithIcon/TextWithIcon';
|
|
5
5
|
import { BookingPaxClient, } from './BookingPaxClient/BookingPaxClient';
|
|
6
6
|
import { BookingPaxHeader } from './BookingPaxHeader';
|
|
@@ -24,27 +24,14 @@ export function BookingPaxAccom(props) {
|
|
|
24
24
|
isPaxCountError: isPaxCountError,
|
|
25
25
|
};
|
|
26
26
|
});
|
|
27
|
-
}, [rooms, selectedClientsInfoIds, isSubmitted, isSelectedClient]);
|
|
28
|
-
// Track previous error states to only call onError when it changes
|
|
29
|
-
var previousErrorsRef = useRef({});
|
|
30
|
-
// Call onError only when error state changes
|
|
31
|
-
useEffect(function () {
|
|
32
|
-
if (!onError)
|
|
33
|
-
return;
|
|
34
|
-
roomData.forEach(function (_a) {
|
|
35
|
-
var roomIndex = _a.roomIndex, isPaxCountError = _a.isPaxCountError;
|
|
36
|
-
var previousError = previousErrorsRef.current[roomIndex];
|
|
37
|
-
if (previousError !== isPaxCountError) {
|
|
38
|
-
onError(roomIndex, isPaxCountError);
|
|
39
|
-
previousErrorsRef.current[roomIndex] = isPaxCountError;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}, [roomData, onError]);
|
|
27
|
+
}, [rooms, selectedClientsInfoIds, changeOptions, isSubmitted, isSelectedClient]);
|
|
43
28
|
useEffect(function () {
|
|
44
29
|
onSelectedClients(clientsInfo, onPaxChange);
|
|
45
30
|
}, [changeOptions, onPaxChange]);
|
|
46
31
|
return (_jsxs(BookingPaxLayout, { title: "Accommodation", icon: "accom", className: "booking-pax-accom", header: _jsx(BookingPaxHeader, { children: _jsx(BookingPaxHeader.Name, { name: hotelName, icon: "accom", location: roomName }) }), children: [roomData.map(function (_a) {
|
|
47
32
|
var room = _a.room, roomIndex = _a.roomIndex;
|
|
48
|
-
return (_jsxs("div", { className: "space-y-2", children: [_jsxs(TextWithIcon, { icon: "accom", children: ["Room ", roomIndex + 1] }), _jsx(BookingPaxClient, { id: "accommodation-".concat(roomIndex), clients: clientsInfo, selectedClientsInfoIds: selectedClientsInfoIds, selectedIndex: roomIndex, paxCount: room.paxCount, onPaxChange: onPaxOptionsChange, isSubmitted: isSubmitted
|
|
33
|
+
return (_jsxs("div", { className: "space-y-2", children: [_jsxs(TextWithIcon, { icon: "accom", children: ["Room ", roomIndex + 1] }), _jsx(BookingPaxClient, { id: "accommodation-".concat(roomIndex), clients: clientsInfo, selectedClientsInfoIds: selectedClientsInfoIds, selectedIndex: roomIndex, paxCount: room.paxCount, onPaxChange: onPaxOptionsChange, isSubmitted: isSubmitted, onError: function (hasError) {
|
|
34
|
+
onError === null || onError === void 0 ? void 0 : onError(roomIndex, hasError);
|
|
35
|
+
} })] }, "rm-".concat(roomIndex)));
|
|
49
36
|
}), _jsx(BookingPaxRemarks, { onChange: onRemarkChange })] }));
|
|
50
37
|
}
|
|
@@ -101,7 +101,7 @@ export function BookingPaxClient(props) {
|
|
|
101
101
|
}, [defaultSelectedClientsInfoIds]);
|
|
102
102
|
useEffect(function () {
|
|
103
103
|
onError === null || onError === void 0 ? void 0 : onError(hasError);
|
|
104
|
-
}, [hasError
|
|
104
|
+
}, [hasError]);
|
|
105
105
|
return (_jsxs("div", { className: "space-y-2", children: [_jsxs(Text, { children: ["Please confirm the pax which applies on this service (", paxCount, " Pax)", ' ', _jsx(Text, { color: "state-error", as: "span", children: "*" })] }), _jsx("div", { className: cn('booking-pax-client', {
|
|
106
106
|
'booking-pax-accom--error': hasError,
|
|
107
107
|
}), children: clients.map(function (client) {
|
|
@@ -28,6 +28,12 @@ export interface BookingPaxAutoFilledData {
|
|
|
28
28
|
*/
|
|
29
29
|
selectedClients: BookingPaxClientInfo[];
|
|
30
30
|
}
|
|
31
|
+
export interface BookingPaxErrorData {
|
|
32
|
+
parentIndex: number;
|
|
33
|
+
childIndex?: number;
|
|
34
|
+
type: BookingPaxData['type'];
|
|
35
|
+
hasError: boolean;
|
|
36
|
+
}
|
|
31
37
|
export interface BookingPaxProps {
|
|
32
38
|
/**
|
|
33
39
|
* The data of the booking pax.
|
|
@@ -52,7 +58,7 @@ export interface BookingPaxProps {
|
|
|
52
58
|
/**
|
|
53
59
|
* The callback function to call when the error changes.
|
|
54
60
|
*/
|
|
55
|
-
onError?: (
|
|
61
|
+
onError?: (data: BookingPaxErrorData) => void;
|
|
56
62
|
/**
|
|
57
63
|
* The callback function to call when the time changes.
|
|
58
64
|
*/
|
|
@@ -60,8 +60,8 @@ export function BookingPaxList(props) {
|
|
|
60
60
|
var handleRemarkChange = useCallback(function (type, index, value) {
|
|
61
61
|
onRemarkChange === null || onRemarkChange === void 0 ? void 0 : onRemarkChange(index, type, value);
|
|
62
62
|
}, [onRemarkChange]);
|
|
63
|
-
var handleError = useCallback(function (
|
|
64
|
-
onError === null || onError === void 0 ? void 0 : onError(
|
|
63
|
+
var handleError = useCallback(function (errorData) {
|
|
64
|
+
onError === null || onError === void 0 ? void 0 : onError(errorData);
|
|
65
65
|
}, [onError]);
|
|
66
66
|
var handleTimeChange = useCallback(function (value, index) {
|
|
67
67
|
// Don't need type because only transfer has this callback
|
|
@@ -123,13 +123,24 @@ export function BookingPaxList(props) {
|
|
|
123
123
|
onRemarkChange: function (value) { return handleRemarkChange(type, index, value); },
|
|
124
124
|
};
|
|
125
125
|
if (type === 'accommodation' && isAccommodationData(itemData)) {
|
|
126
|
-
return (_jsx(BookingPax.Accom, __assign({}, itemData, callbacks, { clientsInfo: clientsInfo, isSubmitted: isSubmitted, onError: function (roomIndex, hasError) {
|
|
126
|
+
return (_jsx(BookingPax.Accom, __assign({}, itemData, callbacks, { clientsInfo: clientsInfo, isSubmitted: isSubmitted, onError: function (roomIndex, hasError) {
|
|
127
|
+
return handleError({ parentIndex: index, childIndex: roomIndex, type: type, hasError: hasError });
|
|
128
|
+
} }), "bp-accom-".concat(index)));
|
|
127
129
|
}
|
|
128
130
|
if (type === 'excursion' && isExcursionData(itemData)) {
|
|
129
|
-
return (_jsx(BookingPax.Excursion, __assign({}, itemData, { clientsInfo: clientsInfo, isSubmitted: isSubmitted, onError: function (hasError) {
|
|
131
|
+
return (_jsx(BookingPax.Excursion, __assign({}, itemData, { clientsInfo: clientsInfo, isSubmitted: isSubmitted, onError: function (hasError) {
|
|
132
|
+
handleError({
|
|
133
|
+
parentIndex: index,
|
|
134
|
+
childIndex: undefined,
|
|
135
|
+
type: type,
|
|
136
|
+
hasError: hasError,
|
|
137
|
+
});
|
|
138
|
+
} }, callbacks), "bp-excursion-".concat(index)));
|
|
130
139
|
}
|
|
131
140
|
if (type === 'transfer' && isTransferData(itemData)) {
|
|
132
|
-
return (_jsx(BookingPax.Transfer, __assign({}, itemData, { onTimeChange: function (value) { return handleTimeChange(value, index); }, onFlightNumberChange: function (value) { return handleFlightNumberChange(value, index); }, clientsInfo: clientsInfo, isSubmitted: isSubmitted, onError: function (hasError) {
|
|
141
|
+
return (_jsx(BookingPax.Transfer, __assign({}, itemData, { onTimeChange: function (value) { return handleTimeChange(value, index); }, onFlightNumberChange: function (value) { return handleFlightNumberChange(value, index); }, clientsInfo: clientsInfo, isSubmitted: isSubmitted, onError: function (hasError) {
|
|
142
|
+
return handleError({ parentIndex: index, childIndex: undefined, type: type, hasError: hasError });
|
|
143
|
+
} }, callbacks), "bp-transfer-".concat(index)));
|
|
133
144
|
}
|
|
134
145
|
return null;
|
|
135
146
|
}) }));
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import useBookingPax from '@/src/hooks/useBookingPax';
|
|
2
|
-
import { useEffect, useMemo
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
3
|
import TextWithIcon from '../TextWithIcon/TextWithIcon';
|
|
4
4
|
import {
|
|
5
5
|
BookingPaxClient,
|
|
@@ -101,23 +101,7 @@ export function BookingPaxAccom(props: BookingPaxAccomProps) {
|
|
|
101
101
|
isPaxCountError,
|
|
102
102
|
};
|
|
103
103
|
});
|
|
104
|
-
}, [rooms, selectedClientsInfoIds, isSubmitted, isSelectedClient]);
|
|
105
|
-
|
|
106
|
-
// Track previous error states to only call onError when it changes
|
|
107
|
-
const previousErrorsRef = useRef<Record<number, boolean>>({});
|
|
108
|
-
|
|
109
|
-
// Call onError only when error state changes
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
if (!onError) return;
|
|
112
|
-
|
|
113
|
-
roomData.forEach(({ roomIndex, isPaxCountError }) => {
|
|
114
|
-
const previousError = previousErrorsRef.current[roomIndex];
|
|
115
|
-
if (previousError !== isPaxCountError) {
|
|
116
|
-
onError(roomIndex, isPaxCountError);
|
|
117
|
-
previousErrorsRef.current[roomIndex] = isPaxCountError;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}, [roomData, onError]);
|
|
104
|
+
}, [rooms, selectedClientsInfoIds, changeOptions, isSubmitted, isSelectedClient]);
|
|
121
105
|
|
|
122
106
|
useEffect(() => {
|
|
123
107
|
onSelectedClients(clientsInfo, onPaxChange);
|
|
@@ -145,6 +129,9 @@ export function BookingPaxAccom(props: BookingPaxAccomProps) {
|
|
|
145
129
|
paxCount={room.paxCount}
|
|
146
130
|
onPaxChange={onPaxOptionsChange}
|
|
147
131
|
isSubmitted={isSubmitted}
|
|
132
|
+
onError={(hasError) => {
|
|
133
|
+
onError?.(roomIndex, hasError);
|
|
134
|
+
}}
|
|
148
135
|
/>
|
|
149
136
|
</div>
|
|
150
137
|
))}
|
|
@@ -43,6 +43,13 @@ export interface BookingPaxAutoFilledData {
|
|
|
43
43
|
selectedClients: BookingPaxClientInfo[];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
export interface BookingPaxErrorData {
|
|
47
|
+
parentIndex: number;
|
|
48
|
+
childIndex?: number;
|
|
49
|
+
type: BookingPaxData['type'];
|
|
50
|
+
hasError: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
export interface BookingPaxProps {
|
|
47
54
|
/**
|
|
48
55
|
* The data of the booking pax.
|
|
@@ -71,7 +78,7 @@ export interface BookingPaxProps {
|
|
|
71
78
|
/**
|
|
72
79
|
* The callback function to call when the error changes.
|
|
73
80
|
*/
|
|
74
|
-
onError?: (
|
|
81
|
+
onError?: (data: BookingPaxErrorData) => void;
|
|
75
82
|
/**
|
|
76
83
|
* The callback function to call when the time changes.
|
|
77
84
|
*/
|
|
@@ -162,8 +169,8 @@ export function BookingPaxList(props: BookingPaxProps) {
|
|
|
162
169
|
);
|
|
163
170
|
|
|
164
171
|
const handleError = useCallback(
|
|
165
|
-
(
|
|
166
|
-
onError?.(
|
|
172
|
+
(errorData: BookingPaxErrorData) => {
|
|
173
|
+
onError?.(errorData);
|
|
167
174
|
},
|
|
168
175
|
[onError]
|
|
169
176
|
);
|
|
@@ -248,7 +255,9 @@ export function BookingPaxList(props: BookingPaxProps) {
|
|
|
248
255
|
{...callbacks}
|
|
249
256
|
clientsInfo={clientsInfo}
|
|
250
257
|
isSubmitted={isSubmitted}
|
|
251
|
-
onError={(roomIndex, hasError) =>
|
|
258
|
+
onError={(roomIndex, hasError) =>
|
|
259
|
+
handleError({ parentIndex: index, childIndex: roomIndex, type, hasError })
|
|
260
|
+
}
|
|
252
261
|
/>
|
|
253
262
|
);
|
|
254
263
|
}
|
|
@@ -260,7 +269,14 @@ export function BookingPaxList(props: BookingPaxProps) {
|
|
|
260
269
|
{...itemData}
|
|
261
270
|
clientsInfo={clientsInfo}
|
|
262
271
|
isSubmitted={isSubmitted}
|
|
263
|
-
onError={(hasError) =>
|
|
272
|
+
onError={(hasError) => {
|
|
273
|
+
handleError({
|
|
274
|
+
parentIndex: index,
|
|
275
|
+
childIndex: undefined,
|
|
276
|
+
type,
|
|
277
|
+
hasError,
|
|
278
|
+
});
|
|
279
|
+
}}
|
|
264
280
|
{...callbacks}
|
|
265
281
|
/>
|
|
266
282
|
);
|
|
@@ -275,7 +291,9 @@ export function BookingPaxList(props: BookingPaxProps) {
|
|
|
275
291
|
onFlightNumberChange={(value) => handleFlightNumberChange(value, index)}
|
|
276
292
|
clientsInfo={clientsInfo}
|
|
277
293
|
isSubmitted={isSubmitted}
|
|
278
|
-
onError={(hasError) =>
|
|
294
|
+
onError={(hasError) =>
|
|
295
|
+
handleError({ parentIndex: index, childIndex: undefined, type, hasError })
|
|
296
|
+
}
|
|
279
297
|
{...callbacks}
|
|
280
298
|
/>
|
|
281
299
|
);
|