mautourco-components 0.2.18 → 0.2.20
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/atoms/Icon/icons/BookingIcon.d.ts +4 -0
- package/dist/components/atoms/Icon/icons/BookingIcon.js +36 -0
- package/dist/components/atoms/Icon/icons/BusIcon.js +1 -1
- package/dist/components/atoms/Icon/icons/CarFront.d.ts +4 -0
- package/dist/components/atoms/Icon/icons/CarFront.js +36 -0
- package/dist/components/atoms/Icon/icons/CatamaranIcon.d.ts +4 -0
- package/dist/components/atoms/Icon/icons/CatamaranIcon.js +36 -0
- package/dist/components/atoms/Icon/icons/ClockIcon.d.ts +4 -0
- package/dist/components/atoms/Icon/icons/ClockIcon.js +36 -0
- package/dist/components/atoms/Icon/icons/CloseCircleIcon.d.ts +4 -0
- package/dist/components/atoms/Icon/icons/CloseCircleIcon.js +36 -0
- package/dist/components/atoms/Icon/icons/Land.d.ts +4 -0
- package/dist/components/atoms/Icon/icons/Land.js +36 -0
- package/dist/components/atoms/Icon/icons/MapIcon.js +1 -1
- package/dist/components/atoms/Icon/icons/PlusCircleIcon.js +1 -1
- package/dist/components/atoms/Icon/icons/SeaIcon.d.ts +4 -0
- package/dist/components/atoms/Icon/icons/SeaIcon.js +36 -0
- package/dist/components/atoms/Icon/icons/registry.d.ts +7 -0
- package/dist/components/atoms/Icon/icons/registry.js +14 -0
- package/dist/components/atoms/Inputs/Input/Input.d.ts +2 -1
- package/dist/components/atoms/Inputs/Input/Input.js +1 -1
- package/dist/components/atoms/Inputs/Textarea/Textarea.d.ts +3 -1
- package/dist/components/atoms/Inputs/Textarea/Textarea.js +7 -5
- package/dist/components/molecules/BookingPax/BookingPax.d.ts +7 -0
- package/dist/components/molecules/BookingPax/BookingPax.js +21 -0
- package/dist/components/molecules/BookingPax/BookingPaxAccom.d.ts +22 -0
- package/dist/components/molecules/BookingPax/BookingPaxAccom.js +61 -0
- package/dist/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.css +2090 -0
- package/dist/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.d.ts +31 -0
- package/dist/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.js +96 -0
- package/dist/components/molecules/BookingPax/BookingPaxExcursion.d.ts +14 -0
- package/dist/components/molecules/BookingPax/BookingPaxExcursion.js +31 -0
- package/dist/components/molecules/BookingPax/BookingPaxHeader.d.ts +16 -0
- package/dist/components/molecules/BookingPax/BookingPaxHeader.js +28 -0
- package/dist/components/molecules/BookingPax/BookingPaxLayout/BookingPaxLayout.css +2103 -0
- package/dist/components/molecules/BookingPax/BookingPaxLayout/BookingPaxLayout.d.ts +11 -0
- package/dist/components/molecules/BookingPax/BookingPaxLayout/BookingPaxLayout.js +19 -0
- package/dist/components/molecules/BookingPax/BookingPaxRemarks.d.ts +5 -0
- package/dist/components/molecules/BookingPax/BookingPaxRemarks.js +37 -0
- package/dist/components/molecules/BookingPax/BookingPaxTransfer.d.ts +18 -0
- package/dist/components/molecules/BookingPax/BookingPaxTransfer.js +40 -0
- package/dist/components/molecules/BookingPax/index.d.ts +5 -0
- package/dist/components/molecules/BookingPax/index.js +1 -0
- package/dist/components/molecules/BookingResume/BookingResume.d.ts +9 -0
- package/dist/components/molecules/BookingResume/BookingResume.js +25 -0
- package/dist/components/molecules/BookingResume/BookingResumeLayout/BookingResumeLayout.css +2107 -0
- package/dist/components/molecules/BookingResume/BookingResumeLayout/BookingResumeLayout.d.ts +11 -0
- package/dist/components/molecules/BookingResume/BookingResumeLayout/BookingResumeLayout.js +19 -0
- package/dist/components/molecules/BookingResume/ResumeAccom/ResumeAccom.css +2094 -0
- package/dist/components/molecules/BookingResume/ResumeAccom/ResumeAccom.d.ts +13 -0
- package/dist/components/molecules/BookingResume/ResumeAccom/ResumeAccom.js +26 -0
- package/dist/components/molecules/BookingResume/ResumeExcursion/ResumeExcursion.css +2082 -0
- package/dist/components/molecules/BookingResume/ResumeExcursion/ResumeExcursion.d.ts +15 -0
- package/dist/components/molecules/BookingResume/ResumeExcursion/ResumeExcursion.js +28 -0
- package/dist/components/molecules/BookingResume/ResumeOtherService.d.ts +6 -0
- package/dist/components/molecules/BookingResume/ResumeOtherService.js +19 -0
- package/dist/components/molecules/BookingResume/ResumeTransfer.d.ts +12 -0
- package/dist/components/molecules/BookingResume/ResumeTransfer.js +23 -0
- package/dist/components/molecules/BookingResume/index.d.ts +6 -0
- package/dist/components/molecules/BookingResume/index.js +1 -0
- package/dist/components/molecules/Calendar/CalendarInput.d.ts +6 -3
- package/dist/components/molecules/Calendar/CalendarInput.js +10 -10
- package/dist/components/molecules/DateDisplay/DateDisplay.d.ts +2 -0
- package/dist/components/molecules/DateDisplay/DateDisplay.js +2 -2
- package/dist/components/molecules/DialogContentPolicy/CancellationLayout/CancellationLayout.css +2142 -0
- package/dist/components/molecules/DialogContentPolicy/CancellationLayout/CancellationLayout.d.ts +11 -0
- package/dist/components/molecules/DialogContentPolicy/CancellationLayout/CancellationLayout.js +19 -0
- package/dist/components/molecules/DialogContentPolicy/DialogCancellationAccom.d.ts +9 -0
- package/dist/components/molecules/DialogContentPolicy/DialogCancellationAccom.js +24 -0
- package/dist/components/molecules/DialogContentPolicy/DialogCancellationExcursion.d.ts +17 -0
- package/dist/components/molecules/DialogContentPolicy/DialogCancellationExcursion.js +20 -0
- package/dist/components/molecules/DialogContentPolicy/DialogCancellationList.d.ts +11 -0
- package/dist/components/molecules/DialogContentPolicy/DialogCancellationList.js +33 -0
- package/dist/components/molecules/DialogContentPolicy/DialogContentPolicy.d.ts +11 -0
- package/dist/components/molecules/DialogContentPolicy/DialogContentPolicy.js +27 -0
- package/dist/components/molecules/DialogContentPolicy/index.d.ts +4 -0
- package/dist/components/molecules/DialogContentPolicy/index.js +1 -0
- package/dist/components/molecules/PaxDisplay/PaxDisplay.css +2104 -0
- package/dist/components/molecules/PaxDisplay/PaxDisplay.d.ts +7 -0
- package/dist/components/molecules/PaxDisplay/PaxDisplay.js +32 -0
- package/dist/components/molecules/ServiceInfo/ServiceInfo.css +3 -7
- package/dist/components/molecules/ServiceInfo/ServiceInfo.d.ts +1 -0
- package/dist/components/molecules/ServiceInfo/ServiceInfo.js +5 -4
- package/dist/components/molecules/ServiceTitle/ServiceTitle.css +3 -0
- package/dist/components/molecules/ServiceTitle/ServiceTitle.d.ts +7 -1
- package/dist/components/molecules/ServiceTitle/ServiceTitle.js +4 -3
- package/dist/components/molecules/StepperTimeline/StepperTimeline.css +2151 -0
- package/dist/components/molecules/StepperTimeline/StepperTimeline.d.ts +23 -0
- package/dist/components/molecules/StepperTimeline/StepperTimeline.js +45 -0
- package/dist/components/organisms/Booking/Booking.css +2080 -0
- package/dist/components/organisms/Booking/Booking.d.ts +13 -0
- package/dist/components/organisms/Booking/Booking.js +37 -0
- package/dist/components/organisms/Booking/BookingDocket/BookingDocket.css +2159 -0
- package/dist/components/organisms/Booking/BookingDocket/BookingDocket.d.ts +13 -0
- package/dist/components/organisms/Booking/BookingDocket/BookingDocket.js +44 -0
- package/dist/components/organisms/Booking/BookingHeader.d.ts +8 -0
- package/dist/components/organisms/Booking/BookingHeader.js +17 -0
- package/dist/components/organisms/Booking/BookingPaxList.d.ts +25 -0
- package/dist/components/organisms/Booking/BookingPaxList.js +117 -0
- package/dist/components/organisms/Booking/BookingStep/BookingStep.css +2103 -0
- package/dist/components/organisms/Booking/BookingStep/BookingStep.d.ts +11 -0
- package/dist/components/organisms/Booking/BookingStep/BookingStep.js +30 -0
- package/dist/components/organisms/Booking/index.d.ts +3 -0
- package/dist/components/organisms/Booking/index.js +1 -0
- package/dist/components/organisms/DateTimePicker/DateTimePicker.d.ts +6 -3
- package/dist/components/organisms/DateTimePicker/DateTimePicker.js +28 -22
- package/dist/components/organisms/DialogBookingConfirm/DialogBookingConfirm.d.ts +10 -0
- package/dist/components/organisms/DialogBookingConfirm/DialogBookingConfirm.js +17 -0
- package/dist/components/organisms/TabCancellationPolicy/HeaderAccom.js +2 -8
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +31 -0
- package/dist/hooks/useBookingPax.d.ts +8 -0
- package/dist/hooks/useBookingPax.js +43 -0
- package/dist/hooks/useStays.d.ts +1 -0
- package/dist/hooks/useStays.js +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/types/table/booking.types.d.ts +12 -0
- package/dist/types/table/detail-resume.types.d.ts +3 -1
- package/package.json +4 -1
- package/src/components/atoms/Icon/icons/BookingIcon.tsx +40 -0
- package/src/components/atoms/Icon/icons/BusIcon.tsx +1 -1
- package/src/components/atoms/Icon/icons/CarFront.tsx +44 -0
- package/src/components/atoms/Icon/icons/CatamaranIcon.tsx +51 -0
- package/src/components/atoms/Icon/icons/ClockIcon.tsx +46 -0
- package/src/components/atoms/Icon/icons/CloseCircleIcon.tsx +55 -0
- package/src/components/atoms/Icon/icons/Land.tsx +40 -0
- package/src/components/atoms/Icon/icons/MapIcon.tsx +6 -2
- package/src/components/atoms/Icon/icons/PlusCircleIcon.tsx +1 -1
- package/src/components/atoms/Icon/icons/SeaIcon.tsx +47 -0
- package/src/components/atoms/Icon/icons/registry.tsx +14 -0
- package/src/components/atoms/Inputs/Input/Input.tsx +6 -5
- package/src/components/atoms/Inputs/Textarea/Textarea.tsx +18 -4
- package/src/components/molecules/BookingPax/BookingPax.tsx +12 -0
- package/src/components/molecules/BookingPax/BookingPaxAccom.tsx +120 -0
- package/src/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.css +4 -0
- package/src/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.tsx +188 -0
- package/src/components/molecules/BookingPax/BookingPaxExcursion.tsx +77 -0
- package/src/components/molecules/BookingPax/BookingPaxHeader.tsx +47 -0
- package/src/components/molecules/BookingPax/BookingPaxLayout/BookingPaxLayout.css +15 -0
- package/src/components/molecules/BookingPax/BookingPaxLayout/BookingPaxLayout.tsx +25 -0
- package/src/components/molecules/BookingPax/BookingPaxRemarks.tsx +46 -0
- package/src/components/molecules/BookingPax/BookingPaxTransfer.tsx +121 -0
- package/src/components/molecules/BookingPax/index.ts +9 -0
- package/src/components/molecules/BookingResume/BookingResume.tsx +16 -0
- package/src/components/molecules/BookingResume/BookingResumeLayout/BookingResumeLayout.css +28 -0
- package/src/components/molecules/BookingResume/BookingResumeLayout/BookingResumeLayout.tsx +37 -0
- package/src/components/molecules/BookingResume/ResumeAccom/ResumeAccom.css +12 -0
- package/src/components/molecules/BookingResume/ResumeAccom/ResumeAccom.tsx +63 -0
- package/src/components/molecules/BookingResume/ResumeExcursion/ResumeExcursion.css +5 -0
- package/src/components/molecules/BookingResume/ResumeExcursion/ResumeExcursion.tsx +75 -0
- package/src/components/molecules/BookingResume/ResumeOtherService.tsx +21 -0
- package/src/components/molecules/BookingResume/ResumeTransfer.tsx +49 -0
- package/src/components/molecules/BookingResume/index.ts +6 -0
- package/src/components/molecules/Calendar/CalendarInput.tsx +26 -24
- package/src/components/molecules/DateDisplay/DateDisplay.tsx +9 -5
- package/src/components/molecules/DialogContentPolicy/CancellationLayout/CancellationLayout.css +37 -0
- package/src/components/molecules/DialogContentPolicy/CancellationLayout/CancellationLayout.tsx +28 -0
- package/src/components/molecules/DialogContentPolicy/DialogCancellationAccom.tsx +65 -0
- package/src/components/molecules/DialogContentPolicy/DialogCancellationExcursion.tsx +59 -0
- package/src/components/molecules/DialogContentPolicy/DialogCancellationList.tsx +49 -0
- package/src/components/molecules/DialogContentPolicy/DialogContentPolicy.tsx +45 -0
- package/src/components/molecules/DialogContentPolicy/index.ts +5 -0
- package/src/components/molecules/PaxDisplay/PaxDisplay.css +19 -0
- package/src/components/molecules/PaxDisplay/PaxDisplay.tsx +59 -0
- package/src/components/molecules/ServiceInfo/ServiceInfo.css +3 -5
- package/src/components/molecules/ServiceInfo/ServiceInfo.tsx +18 -3
- package/src/components/molecules/ServiceTitle/ServiceTitle.css +1 -1
- package/src/components/molecules/ServiceTitle/ServiceTitle.tsx +25 -7
- package/src/components/molecules/StepperTimeline/StepperTimeline.css +59 -0
- package/src/components/molecules/StepperTimeline/StepperTimeline.tsx +105 -0
- package/src/components/organisms/Booking/Booking.css +3 -0
- package/src/components/organisms/Booking/Booking.tsx +25 -0
- package/src/components/organisms/Booking/BookingDocket/BookingDocket.css +67 -0
- package/src/components/organisms/Booking/BookingDocket/BookingDocket.tsx +165 -0
- package/src/components/organisms/Booking/BookingHeader.tsx +24 -0
- package/src/components/organisms/Booking/BookingPaxList.tsx +224 -0
- package/src/components/organisms/Booking/BookingStep/BookingStep.css +12 -0
- package/src/components/organisms/Booking/BookingStep/BookingStep.tsx +51 -0
- package/src/components/organisms/Booking/index.ts +3 -0
- package/src/components/organisms/CarBookingCard/index.ts +1 -0
- package/src/components/organisms/DateTimePicker/DateTimePicker.tsx +69 -49
- package/src/components/organisms/DialogBookingConfirm/DialogBookingConfirm.tsx +25 -0
- package/src/components/organisms/TabCancellationPolicy/HeaderAccom.tsx +2 -8
- package/src/components/ui/checkbox.tsx +32 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
BookingPax,
|
|
4
|
+
BookingPaxAccomProps,
|
|
5
|
+
BookingPaxExcursionProps,
|
|
6
|
+
BookingPaxTransferProps,
|
|
7
|
+
} from '../../molecules/BookingPax';
|
|
8
|
+
import {
|
|
9
|
+
BookingPaxClientInfo,
|
|
10
|
+
BookingPaxClientOptions,
|
|
11
|
+
} from '../../molecules/BookingPax/BookingPaxClient/BookingPaxClient';
|
|
12
|
+
|
|
13
|
+
export interface BookingPaxData {
|
|
14
|
+
type: 'accommodation' | 'excursion' | 'transfer';
|
|
15
|
+
data:
|
|
16
|
+
| Omit<BookingPaxAccomProps, 'clientsInfo'>
|
|
17
|
+
| Omit<BookingPaxExcursionProps, 'clientsInfo'>
|
|
18
|
+
| Omit<BookingPaxTransferProps, 'clientsInfo'>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface BookingPaxAutoFilledData {
|
|
22
|
+
type: BookingPaxData['type'];
|
|
23
|
+
parentIndex: number;
|
|
24
|
+
roomIndex?: number;
|
|
25
|
+
selectedClients: BookingPaxClientInfo[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface BookingPaxProps {
|
|
29
|
+
data: BookingPaxData[];
|
|
30
|
+
clientsInfo: BookingPaxClientInfo[];
|
|
31
|
+
isSubmitted?: boolean;
|
|
32
|
+
onPaxChange?: (
|
|
33
|
+
index: number,
|
|
34
|
+
type: BookingPaxData['type'],
|
|
35
|
+
options: BookingPaxClientOptions
|
|
36
|
+
) => void;
|
|
37
|
+
onRemarkChange?: (index: number, type: BookingPaxData['type'], value: string) => void;
|
|
38
|
+
onError?: (index: number, type: BookingPaxData['type'], hasError: boolean) => void;
|
|
39
|
+
onTimeChange?: (index: number, value: string | string[]) => void;
|
|
40
|
+
onFlightNumberChange?: (index: number, value: string) => void;
|
|
41
|
+
onAutoFilled?: (data: BookingPaxAutoFilledData[]) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Type guards for better type safety
|
|
45
|
+
const isAccommodationData = (
|
|
46
|
+
data: BookingPaxData['data']
|
|
47
|
+
): data is BookingPaxAccomProps => {
|
|
48
|
+
return 'rooms' in data && 'hotelName' in data && 'roomName' in data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const isExcursionData = (
|
|
52
|
+
data: BookingPaxData['data']
|
|
53
|
+
): data is BookingPaxExcursionProps => {
|
|
54
|
+
return 'name' in data && 'type' in data && !('from' in data);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const isTransferData = (
|
|
58
|
+
data: BookingPaxData['data']
|
|
59
|
+
): data is BookingPaxTransferProps => {
|
|
60
|
+
return 'from' in data && 'to' in data && 'type' in data;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const BookingPaxList: React.FC<BookingPaxProps> = (props) => {
|
|
64
|
+
const {
|
|
65
|
+
data,
|
|
66
|
+
isSubmitted,
|
|
67
|
+
clientsInfo,
|
|
68
|
+
onPaxChange,
|
|
69
|
+
onRemarkChange,
|
|
70
|
+
onError,
|
|
71
|
+
onTimeChange,
|
|
72
|
+
onFlightNumberChange,
|
|
73
|
+
onAutoFilled,
|
|
74
|
+
} = props;
|
|
75
|
+
|
|
76
|
+
const [autoFilledData, setAutoFilledData] = useState<
|
|
77
|
+
{
|
|
78
|
+
type: BookingPaxData['type'];
|
|
79
|
+
parentIndex: number;
|
|
80
|
+
roomIndex?: number;
|
|
81
|
+
selectedClients: BookingPaxClientInfo[];
|
|
82
|
+
}[]
|
|
83
|
+
>([]);
|
|
84
|
+
|
|
85
|
+
// Memoized callback handlers to reduce re-renders
|
|
86
|
+
const handlePaxChange = useCallback(
|
|
87
|
+
(type: BookingPaxData['type'], index: number, options: BookingPaxClientOptions) => {
|
|
88
|
+
onPaxChange?.(index, type, options);
|
|
89
|
+
},
|
|
90
|
+
[onPaxChange]
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const handleRemarkChange = useCallback(
|
|
94
|
+
(type: BookingPaxData['type'], index: number, value: string) => {
|
|
95
|
+
onRemarkChange?.(index, type, value);
|
|
96
|
+
},
|
|
97
|
+
[onRemarkChange]
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const handleError = useCallback(
|
|
101
|
+
(index: number, type: BookingPaxData['type'], hasError: boolean) => {
|
|
102
|
+
onError?.(index, type, hasError);
|
|
103
|
+
},
|
|
104
|
+
[onError]
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const handleTimeChange = useCallback(
|
|
108
|
+
(value: string | string[], index: number) => {
|
|
109
|
+
// Don't need type because only transfer has this callback
|
|
110
|
+
onTimeChange?.(index, value);
|
|
111
|
+
},
|
|
112
|
+
[onTimeChange]
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const handleFlightNumberChange = useCallback(
|
|
116
|
+
(value: string, index: number) => {
|
|
117
|
+
// Don't need type because only transfer has this callback
|
|
118
|
+
onFlightNumberChange?.(index, value);
|
|
119
|
+
},
|
|
120
|
+
[onFlightNumberChange]
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const handleAutoFilled = useCallback((type: BookingPaxData['type']) => {
|
|
124
|
+
return (paxCount: number, index: number, roomIndex?: number) => {
|
|
125
|
+
if (paxCount === clientsInfo.length) {
|
|
126
|
+
setAutoFilledData((prev) => {
|
|
127
|
+
const findParentIndex = prev.find((d) => d.parentIndex === index);
|
|
128
|
+
if (findParentIndex) {
|
|
129
|
+
return prev;
|
|
130
|
+
}
|
|
131
|
+
return [
|
|
132
|
+
...prev,
|
|
133
|
+
{
|
|
134
|
+
type,
|
|
135
|
+
parentIndex: index,
|
|
136
|
+
selectedClients: clientsInfo,
|
|
137
|
+
roomIndex,
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}, []);
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
data.forEach((item, index) => {
|
|
147
|
+
const { type, data: itemData } = item;
|
|
148
|
+
if (type === 'accommodation' && isAccommodationData(itemData)) {
|
|
149
|
+
const initAccom = handleAutoFilled('accommodation');
|
|
150
|
+
// if(itemData.clientsInfo.length === itemData)
|
|
151
|
+
itemData.rooms.forEach((room, roomIndex) => {
|
|
152
|
+
initAccom(room.paxCount, index, roomIndex);
|
|
153
|
+
});
|
|
154
|
+
} else if (type === 'excursion' && isExcursionData(itemData)) {
|
|
155
|
+
const initExcursion = handleAutoFilled('excursion');
|
|
156
|
+
initExcursion(itemData.paxCount, index);
|
|
157
|
+
} else if (type === 'transfer' && isTransferData(itemData)) {
|
|
158
|
+
const initTransfer = handleAutoFilled('transfer');
|
|
159
|
+
initTransfer(itemData.paxCount, index);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}, [data, handleAutoFilled]);
|
|
163
|
+
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
onAutoFilled?.(autoFilledData);
|
|
166
|
+
}, [autoFilledData, onAutoFilled]);
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<BookingPax>
|
|
170
|
+
{data.map((item, index) => {
|
|
171
|
+
const { type, data: itemData } = item;
|
|
172
|
+
|
|
173
|
+
const callbacks = {
|
|
174
|
+
onPaxChange: (options: BookingPaxClientOptions) =>
|
|
175
|
+
handlePaxChange(type, index, options),
|
|
176
|
+
onRemarkChange: (value: string) => handleRemarkChange(type, index, value),
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
if (type === 'accommodation' && isAccommodationData(itemData)) {
|
|
180
|
+
return (
|
|
181
|
+
<BookingPax.Accom
|
|
182
|
+
key={`bp-accom-${index}`}
|
|
183
|
+
{...itemData}
|
|
184
|
+
{...callbacks}
|
|
185
|
+
clientsInfo={clientsInfo}
|
|
186
|
+
isSubmitted={isSubmitted}
|
|
187
|
+
onError={(roomIndex, hasError) => handleError(roomIndex, type, hasError)}
|
|
188
|
+
/>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (type === 'excursion' && isExcursionData(itemData)) {
|
|
193
|
+
return (
|
|
194
|
+
<BookingPax.Excursion
|
|
195
|
+
key={`bp-excursion-${index}`}
|
|
196
|
+
{...itemData}
|
|
197
|
+
clientsInfo={clientsInfo}
|
|
198
|
+
isSubmitted={isSubmitted}
|
|
199
|
+
onError={(hasError) => handleError(index, type, hasError)}
|
|
200
|
+
{...callbacks}
|
|
201
|
+
/>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (type === 'transfer' && isTransferData(itemData)) {
|
|
206
|
+
return (
|
|
207
|
+
<BookingPax.Transfer
|
|
208
|
+
key={`bp-transfer-${index}`}
|
|
209
|
+
{...itemData}
|
|
210
|
+
onTimeChange={(value) => handleTimeChange(value, index)}
|
|
211
|
+
onFlightNumberChange={(value) => handleFlightNumberChange(value, index)}
|
|
212
|
+
clientsInfo={clientsInfo}
|
|
213
|
+
isSubmitted={isSubmitted}
|
|
214
|
+
onError={(hasError) => handleError(index, type, hasError)}
|
|
215
|
+
{...callbacks}
|
|
216
|
+
/>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return null;
|
|
221
|
+
})}
|
|
222
|
+
</BookingPax>
|
|
223
|
+
);
|
|
224
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Button from '@/src/components/atoms/Button/Button';
|
|
2
|
+
import {
|
|
3
|
+
StepperTimeline,
|
|
4
|
+
StepperTimelineItem,
|
|
5
|
+
} from '@/src/components/molecules/StepperTimeline/StepperTimeline';
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
import './BookingStep.css';
|
|
8
|
+
|
|
9
|
+
export interface BookingStepProps {
|
|
10
|
+
steps: StepperTimelineItem[];
|
|
11
|
+
className?: string;
|
|
12
|
+
nextDisabled?: boolean;
|
|
13
|
+
onStepChange?: (step: StepperTimelineItem, index: number) => void;
|
|
14
|
+
onNextClick?: (step: StepperTimelineItem, index: number) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const BookingStep: React.FC<BookingStepProps> = (props) => {
|
|
18
|
+
const { steps, className, nextDisabled, onStepChange, onNextClick } = props;
|
|
19
|
+
|
|
20
|
+
const [currentIndex, setCurrentIndex] = useState<number>(0);
|
|
21
|
+
|
|
22
|
+
const handleStepChange = (step: StepperTimelineItem, index: number) => {
|
|
23
|
+
setCurrentIndex(index);
|
|
24
|
+
onStepChange?.(step, index);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const handleNextClick = () => {
|
|
28
|
+
const currentStep = currentIndex + 1;
|
|
29
|
+
setCurrentIndex(currentStep);
|
|
30
|
+
onNextClick?.(steps[currentStep], currentStep);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className="booking-step">
|
|
35
|
+
<StepperTimeline
|
|
36
|
+
steps={steps}
|
|
37
|
+
className={className}
|
|
38
|
+
currentIndex={currentIndex}
|
|
39
|
+
onChange={handleStepChange}
|
|
40
|
+
/>
|
|
41
|
+
<Button
|
|
42
|
+
trailingIcon="arrow-right-outline"
|
|
43
|
+
variant="secondary"
|
|
44
|
+
className="w-[189px]"
|
|
45
|
+
disabled={nextDisabled}
|
|
46
|
+
onClick={handleNextClick}>
|
|
47
|
+
{currentIndex === steps.length - 1 ? 'Confirm' : 'Next'}
|
|
48
|
+
</Button>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import CalendarInput from
|
|
3
|
-
import DateTime, { DateTimeProps } from
|
|
4
|
-
import { Popover,
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import CalendarInput from '../../molecules/Calendar/CalendarInput';
|
|
3
|
+
import DateTime, { DateTimeProps } from '../../molecules/Calendar/DateTime';
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover';
|
|
5
5
|
|
|
6
|
-
import { format } from
|
|
6
|
+
import { format } from 'date-fns';
|
|
7
|
+
import { IconName } from '../../atoms/Icon/Icon';
|
|
7
8
|
|
|
8
9
|
export interface DateTimePickerProps extends Partial<DateTimeProps> {
|
|
9
10
|
placeholder?: string;
|
|
@@ -14,40 +15,43 @@ export interface DateTimePickerProps extends Partial<DateTimeProps> {
|
|
|
14
15
|
/** Whether the calendar icon has full bg*/
|
|
15
16
|
iconBGFull?: boolean;
|
|
16
17
|
/** Position of the calendar icon: left or right */
|
|
17
|
-
iconPosition?:
|
|
18
|
+
iconPosition?: 'left' | 'right';
|
|
18
19
|
/** Show chevron on the right when icon is on the left */
|
|
19
20
|
showChevron?: boolean;
|
|
21
|
+
/** Icon to display on the left of the input */
|
|
22
|
+
icon?: IconName;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
const formatDateRange = (dateRange: any) => {
|
|
23
|
-
if (!dateRange || !dateRange.from) return
|
|
26
|
+
if (!dateRange || !dateRange.from) return '';
|
|
24
27
|
const from = dateRange.from;
|
|
25
28
|
const to = dateRange.to ?? dateRange.from;
|
|
26
|
-
|
|
27
|
-
if (+from === +to) return format(from,
|
|
28
|
-
return `${format(from,
|
|
29
|
+
|
|
30
|
+
if (+from === +to) return format(from, 'dd/MM/yyyy');
|
|
31
|
+
return `${format(from, 'dd/MM/yyyy')} - ${format(to, 'dd/MM/yyyy')}`;
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
32
|
-
placeholder =
|
|
35
|
+
placeholder = 'Select date',
|
|
33
36
|
disabled = false,
|
|
34
|
-
mode =
|
|
35
|
-
selectionMode =
|
|
37
|
+
mode = 'both',
|
|
38
|
+
selectionMode = 'range',
|
|
36
39
|
numberOfMonths = 2,
|
|
37
40
|
disableBeforeToday = true,
|
|
38
41
|
disableToday = false,
|
|
39
42
|
onValueChange,
|
|
40
43
|
defaultValue,
|
|
41
44
|
iconBGFull = true,
|
|
42
|
-
iconPosition =
|
|
45
|
+
iconPosition = 'right',
|
|
43
46
|
showChevron = false,
|
|
47
|
+
icon,
|
|
44
48
|
}) => {
|
|
45
49
|
// Parse default value and set initial state
|
|
46
50
|
const parseDefaultValue = () => {
|
|
47
|
-
if (!defaultValue) return { value:
|
|
51
|
+
if (!defaultValue) return { value: '', dateRange: undefined };
|
|
48
52
|
|
|
49
53
|
try {
|
|
50
|
-
if (selectionMode ===
|
|
54
|
+
if (selectionMode === 'range' && Array.isArray(defaultValue)) {
|
|
51
55
|
// Handle range: ["yyyy-MM-dd", "yyyy-MM-dd"]
|
|
52
56
|
const [fromStr, toStr] = defaultValue;
|
|
53
57
|
const from = new Date(fromStr);
|
|
@@ -55,56 +59,71 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
|
55
59
|
const dateRange = { from, to };
|
|
56
60
|
const displayValue = formatDateRange(dateRange);
|
|
57
61
|
return { value: displayValue, dateRange };
|
|
58
|
-
} else if (selectionMode ===
|
|
62
|
+
} else if (selectionMode === 'single' && typeof defaultValue === 'string') {
|
|
59
63
|
// Handle single: "yyyy-MM-dd"
|
|
60
64
|
const date = new Date(defaultValue);
|
|
61
65
|
const dateRange = { from: date, to: date };
|
|
62
|
-
const displayValue = format(date,
|
|
66
|
+
const displayValue = format(date, 'dd/MM/yyyy');
|
|
63
67
|
return { value: displayValue, dateRange };
|
|
64
68
|
}
|
|
65
69
|
} catch (error) {
|
|
66
|
-
console.error(
|
|
70
|
+
console.error('Error parsing default date value:', error);
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
return { value:
|
|
73
|
+
return { value: '', dateRange: undefined };
|
|
70
74
|
};
|
|
71
75
|
|
|
72
76
|
const initialState = parseDefaultValue();
|
|
73
77
|
const [value, setValue] = useState<string>(initialState.value);
|
|
74
78
|
const [selectedDateRange, setSelectedDateRange] = useState<any>(initialState.dateRange);
|
|
75
|
-
const [selectedTime, setSelectedTime] = useState<
|
|
79
|
+
const [selectedTime, setSelectedTime] = useState<
|
|
80
|
+
{ hour: string; minute: string; meridiem: 'AM' | 'PM' } | undefined
|
|
81
|
+
>(undefined);
|
|
76
82
|
const [isOpen, setIsOpen] = useState(false);
|
|
77
83
|
|
|
78
|
-
const handleDtChange = React.useCallback(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
84
|
+
const handleDtChange = React.useCallback(
|
|
85
|
+
(payload: {
|
|
86
|
+
dateRange?: any;
|
|
87
|
+
time?: { hour: string; minute: string; meridiem: 'AM' | 'PM' };
|
|
88
|
+
}) => {
|
|
89
|
+
const datePart = formatDateRange(payload.dateRange);
|
|
90
|
+
const time = payload.time
|
|
91
|
+
? `${payload.time.hour}:${payload.time.minute} ${payload.time.meridiem}`
|
|
92
|
+
: '';
|
|
93
|
+
const combined = [datePart, time].filter(Boolean).join(' ');
|
|
94
|
+
setValue(combined);
|
|
95
|
+
setSelectedDateRange(payload.dateRange);
|
|
96
|
+
setSelectedTime(payload.time);
|
|
97
|
+
|
|
98
|
+
// Return date strings in yyyy-MM-dd format for both modes
|
|
99
|
+
if (payload.dateRange) {
|
|
100
|
+
if (selectionMode === 'range') {
|
|
101
|
+
// Return array of date strings for range mode
|
|
102
|
+
const from = payload.dateRange.from;
|
|
103
|
+
const to = payload.dateRange.to ?? payload.dateRange.from;
|
|
104
|
+
|
|
105
|
+
if (from && to) {
|
|
106
|
+
const fromStr = format(from, 'yyyy-MM-dd');
|
|
107
|
+
const toStr = format(to, 'yyyy-MM-dd');
|
|
108
|
+
onValueChange?.([fromStr, toStr]);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
// Return single date string in yyyy-MM-dd format for single mode
|
|
112
|
+
const date = payload.dateRange.from;
|
|
113
|
+
if (date) {
|
|
114
|
+
const dateStr = format(date, 'yyyy-MM-dd');
|
|
115
|
+
onValueChange?.(dateStr);
|
|
116
|
+
}
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
|
|
120
|
+
if (!payload.dateRange && payload.time) {
|
|
121
|
+
const timeStr = `${payload.time.hour}:${payload.time.minute} ${payload.time.meridiem}`;
|
|
122
|
+
onValueChange?.(timeStr);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
[onValueChange, selectionMode]
|
|
126
|
+
);
|
|
108
127
|
|
|
109
128
|
return (
|
|
110
129
|
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
|
@@ -118,6 +137,7 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
|
118
137
|
iconPosition={iconPosition}
|
|
119
138
|
showChevron={showChevron}
|
|
120
139
|
isOpen={isOpen}
|
|
140
|
+
icon={icon}
|
|
121
141
|
/>
|
|
122
142
|
</div>
|
|
123
143
|
</PopoverTrigger>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Dialog from '../Dialog/Dialog';
|
|
3
|
+
|
|
4
|
+
interface DialogBookingConfirmProps {
|
|
5
|
+
open: boolean;
|
|
6
|
+
title: string;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
setOpen: (open: boolean) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const DialogBookingConfirm = (props: DialogBookingConfirmProps) => {
|
|
13
|
+
const { open, title, children, setOpen, className } = props;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Dialog
|
|
17
|
+
isOpen={open}
|
|
18
|
+
onClose={() => setOpen(false)}
|
|
19
|
+
title={title}
|
|
20
|
+
className={className}
|
|
21
|
+
showFooter={false}>
|
|
22
|
+
{children}
|
|
23
|
+
</Dialog>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useMemo } from 'react';
|
|
1
|
+
import useStays from '@/src/hooks/useStays';
|
|
3
2
|
import { DateDisplay } from '../../molecules/DateDisplay/DateDisplay';
|
|
4
3
|
import { ServiceTitle } from '../../molecules/ServiceTitle/ServiceTitle';
|
|
5
4
|
import TextWithIcon from '../../molecules/TextWithIcon/TextWithIcon';
|
|
@@ -13,12 +12,7 @@ export interface HeaderAccomProps {
|
|
|
13
12
|
export default function HeaderAccom(props: HeaderAccomProps) {
|
|
14
13
|
const { hotelName, pax, dates } = props;
|
|
15
14
|
|
|
16
|
-
const stay =
|
|
17
|
-
if (dates.length) {
|
|
18
|
-
return differenceInDays(dates[1], dates[0]);
|
|
19
|
-
}
|
|
20
|
-
return 0;
|
|
21
|
-
}, [dates]);
|
|
15
|
+
const stay = useStays(dates);
|
|
22
16
|
|
|
23
17
|
return (
|
|
24
18
|
<div>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from '@/src/lib/utils';
|
|
5
|
+
import Icon from '../atoms/Icon/Icon';
|
|
6
|
+
|
|
7
|
+
function Checkbox({
|
|
8
|
+
className,
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
11
|
+
return (
|
|
12
|
+
<CheckboxPrimitive.Root
|
|
13
|
+
data-slot="checkbox"
|
|
14
|
+
className={cn(
|
|
15
|
+
'w-5 h-5 border border-[var(--checkbox-color-checkbox-border-default-default)] data-[state=checked]:border-[var(--checkbox-color-checkbox-border-selected-default)] rounded-[var(--border-radius-rounded-sm)] data-[error=true]:border-[var(--checkbox-color-checkbox-border-default-error)] data-[error=true]:bg-[var(--checkbox-color-checkbox-background-error)] disabled:opacity-50 disabled:cursor-not-allowed',
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
{...props}>
|
|
19
|
+
<CheckboxPrimitive.Indicator
|
|
20
|
+
data-slot="checkbox-indicator"
|
|
21
|
+
className="grid place-content-center text-current transition-none">
|
|
22
|
+
<Icon
|
|
23
|
+
name="check"
|
|
24
|
+
size="sm"
|
|
25
|
+
className="text-[var(--checkbox-color-checkbox-checked-default)]"
|
|
26
|
+
/>
|
|
27
|
+
</CheckboxPrimitive.Indicator>
|
|
28
|
+
</CheckboxPrimitive.Root>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { Checkbox };
|