mautourco-components 0.2.21 → 0.2.23
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/Checkbox/Checkbox.d.ts +3 -2
- package/dist/components/atoms/Checkbox/Checkbox.js +16 -6
- package/dist/components/atoms/Icon/icons/PlusCircleIcon.js +1 -1
- package/dist/components/atoms/Inputs/Input/Input.d.ts +1 -1
- package/dist/components/molecules/AddItemButton/AddItemButton.css +2088 -0
- package/dist/components/molecules/AddItemButton/AddItemButton.d.ts +7 -0
- package/dist/components/molecules/AddItemButton/AddItemButton.js +19 -0
- package/dist/components/molecules/BookingPax/BookingPax.d.ts +43 -0
- package/dist/components/molecules/BookingPax/BookingPax.js +43 -0
- package/dist/components/molecules/BookingPax/BookingPaxAccom.d.ts +34 -0
- package/dist/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.css +10 -0
- package/dist/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.d.ts +89 -1
- package/dist/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.js +34 -11
- package/dist/components/molecules/BookingPax/BookingPaxExcursion.d.ts +43 -0
- package/dist/components/molecules/BookingPax/BookingPaxExcursion.js +19 -0
- package/dist/components/molecules/BookingPax/BookingPaxHeader.d.ts +15 -0
- package/dist/components/molecules/BookingPax/BookingPaxHeader.js +13 -0
- package/dist/components/molecules/BookingPax/BookingPaxLayout/BookingPaxLayout.d.ts +30 -0
- package/dist/components/molecules/BookingPax/BookingPaxLayout/BookingPaxLayout.js +15 -0
- package/dist/components/molecules/BookingPax/BookingPaxRemarks.d.ts +14 -0
- package/dist/components/molecules/BookingPax/BookingPaxRemarks.js +11 -0
- package/dist/components/molecules/BookingPax/BookingPaxTransfer.d.ts +51 -0
- package/dist/components/molecules/BookingPax/BookingPaxTransfer.js +19 -2
- package/dist/components/molecules/BookingPax/index.d.ts +1 -0
- package/dist/components/molecules/BookingPax/index.js +1 -0
- package/dist/components/molecules/Calendar/DateTime.d.ts +5 -5
- package/dist/components/molecules/Calendar/DateTime.js +48 -37
- package/dist/components/molecules/DialogContentPolicy/DialogCancellationList.d.ts +20 -0
- package/dist/components/molecules/DialogContentPolicy/DialogCancellationList.js +17 -6
- package/dist/components/molecules/DialogContentPolicy/DialogContentPolicy.d.ts +18 -0
- package/dist/components/molecules/DialogContentPolicy/DialogContentPolicy.js +14 -3
- package/dist/components/molecules/ServiceSelector/ServiceSelector.d.ts +3 -0
- package/dist/components/molecules/ServiceSelector/ServiceSelector.js +23 -12
- package/dist/components/organisms/Booking/BookingPaxList.d.ts +64 -0
- package/dist/components/organisms/Booking/BookingPaxList.js +19 -0
- package/dist/components/organisms/BookingAddItem/AddItemNewService.d.ts +12 -0
- package/dist/components/organisms/BookingAddItem/AddItemNewService.js +48 -0
- package/dist/components/organisms/BookingAddItem/AddItemSelector.d.ts +9 -0
- package/dist/components/organisms/BookingAddItem/AddItemSelector.js +23 -0
- package/dist/components/organisms/BookingAddItem/BookingAddItem.d.ts +16 -0
- package/dist/components/organisms/BookingAddItem/BookingAddItem.js +66 -0
- package/dist/components/organisms/BookingAddItem/index.d.ts +3 -0
- package/dist/components/organisms/BookingAddItem/index.js +3 -0
- package/dist/components/organisms/DateTimePicker/DateTimePicker.js +11 -7
- package/dist/components/organisms/Dialog/Dialog.d.ts +1 -1
- package/dist/components/organisms/Dialog/Dialog.js +4 -4
- package/dist/components/organisms/DialogBookingConfirm/BookingCancellationPolicy.d.ts +29 -0
- package/dist/components/organisms/DialogBookingConfirm/BookingCancellationPolicy.js +31 -0
- package/dist/components/organisms/DialogBookingConfirm/BookingMailSent.d.ts +29 -0
- package/dist/components/organisms/DialogBookingConfirm/BookingMailSent.js +31 -0
- package/dist/components/organisms/DialogBookingConfirm/BookingReference.d.ts +35 -0
- package/dist/components/organisms/DialogBookingConfirm/BookingReference.js +37 -0
- package/dist/components/organisms/DialogBookingConfirm/BookingSuccess.d.ts +35 -0
- package/dist/components/organisms/DialogBookingConfirm/BookingSuccess.js +33 -0
- package/dist/components/organisms/DialogBookingConfirm/DialogBookingConfirm.d.ts +39 -2
- package/dist/components/organisms/DialogBookingConfirm/DialogBookingConfirm.js +25 -1
- package/dist/components/organisms/DialogBookingConfirm/index.d.ts +5 -0
- package/dist/components/organisms/DialogBookingConfirm/index.js +1 -0
- package/dist/components/organisms/PaxSelector/PaxSelector.d.ts +1 -0
- package/dist/components/organisms/PaxSelector/PaxSelector.js +50 -28
- package/dist/components/organisms/TabCancellationPolicy/CancellationAccom.d.ts +25 -0
- package/dist/components/organisms/TabCancellationPolicy/CancellationAccom.js +16 -0
- package/dist/components/organisms/TabCancellationPolicy/CancellationBody.d.ts +24 -0
- package/dist/components/organisms/TabCancellationPolicy/CancellationBody.js +24 -0
- package/dist/components/organisms/TabCancellationPolicy/CancellationExcursion.d.ts +30 -0
- package/dist/components/organisms/TabCancellationPolicy/CancellationExcursion.js +15 -0
- package/dist/components/organisms/TabCancellationPolicy/CancellationHeader.d.ts +23 -0
- package/dist/components/organisms/TabCancellationPolicy/CancellationHeader.js +23 -0
- package/dist/components/organisms/TabCancellationPolicy/CancellationTransfer.d.ts +22 -0
- package/dist/components/organisms/TabCancellationPolicy/CancellationTransfer.js +13 -0
- package/dist/components/organisms/TabCancellationPolicy/HeaderAccom.d.ts +22 -0
- package/dist/components/organisms/TabCancellationPolicy/HeaderAccom.js +13 -0
- package/dist/components/organisms/TabCancellationPolicy/HeaderExcursion.d.ts +18 -0
- package/dist/components/organisms/TabCancellationPolicy/HeaderExcursion.js +12 -0
- package/dist/components/organisms/TabCancellationPolicy/PolicyAccom/PolicyAccom.css +7 -0
- package/dist/components/organisms/TabCancellationPolicy/PolicyAccom/PolicyAccom.js +2 -1
- package/dist/components/organisms/TabCancellationPolicy/PolicyExcursion.d.ts +18 -0
- package/dist/components/organisms/TabCancellationPolicy/PolicyExcursion.js +12 -0
- package/dist/components/organisms/TabCancellationPolicy/PolicyTransfer.d.ts +11 -0
- package/dist/components/organisms/TabCancellationPolicy/PolicyTransfer.js +11 -0
- package/dist/components/organisms/TabCancellationPolicy/TabCancellationPolicy.d.ts +29 -0
- package/dist/components/organisms/TabCancellationPolicy/TabCancellationPolicy.js +29 -0
- package/dist/components/ui/popover.js +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -2
- package/dist/styles/components/checkbox.css +16 -9
- package/dist/styles/components/molecule/calendarInput.css +3 -4
- package/dist/styles/components/molecule/service-selector.css +70 -21
- package/package.json +1 -2
- package/src/components/atoms/Checkbox/Checkbox.tsx +38 -23
- package/src/components/atoms/Icon/icons/PlusCircleIcon.tsx +2 -2
- package/src/components/atoms/Inputs/Input/Input.tsx +1 -1
- package/src/components/molecules/AddItemButton/AddItemButton.css +5 -0
- package/src/components/molecules/AddItemButton/AddItemButton.tsx +18 -0
- package/src/components/molecules/BookingPax/BookingPax.tsx +43 -0
- package/src/components/molecules/BookingPax/BookingPaxAccom.tsx +34 -0
- package/src/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.css +6 -0
- package/src/components/molecules/BookingPax/BookingPaxClient/BookingPaxClient.tsx +92 -18
- package/src/components/molecules/BookingPax/BookingPaxExcursion.tsx +43 -0
- package/src/components/molecules/BookingPax/BookingPaxHeader.tsx +28 -1
- package/src/components/molecules/BookingPax/BookingPaxLayout/BookingPaxLayout.tsx +30 -0
- package/src/components/molecules/BookingPax/BookingPaxRemarks.tsx +14 -0
- package/src/components/molecules/BookingPax/BookingPaxTransfer.tsx +52 -2
- package/src/components/molecules/BookingPax/index.ts +2 -0
- package/src/components/molecules/Calendar/DateTime.tsx +69 -53
- package/src/components/molecules/DialogContentPolicy/DialogCancellationList.tsx +32 -12
- package/src/components/molecules/DialogContentPolicy/DialogContentPolicy.tsx +27 -11
- package/src/components/molecules/ServiceSelector/ServiceSelector.tsx +91 -83
- package/src/components/organisms/Booking/BookingPaxList.tsx +64 -0
- package/src/components/organisms/BookingAddItem/AddItemNewService.tsx +95 -0
- package/src/components/organisms/BookingAddItem/AddItemSelector.tsx +43 -0
- package/src/components/organisms/BookingAddItem/BookingAddItem.tsx +120 -0
- package/src/components/organisms/BookingAddItem/index.ts +3 -0
- package/src/components/organisms/DateTimePicker/DateTimePicker.tsx +13 -7
- package/src/components/organisms/Dialog/Dialog.tsx +13 -20
- package/src/components/organisms/DialogBookingConfirm/BookingCancellationPolicy.tsx +44 -0
- package/src/components/organisms/DialogBookingConfirm/BookingMailSent.tsx +56 -0
- package/src/components/organisms/DialogBookingConfirm/BookingReference.tsx +74 -0
- package/src/components/organisms/DialogBookingConfirm/BookingSuccess.tsx +67 -0
- package/src/components/organisms/DialogBookingConfirm/DialogBookingConfirm.tsx +43 -2
- package/src/components/organisms/DialogBookingConfirm/index.ts +6 -0
- package/src/components/organisms/PaxSelector/PaxSelector.tsx +305 -193
- package/src/components/organisms/TabCancellationPolicy/CancellationAccom.tsx +25 -0
- package/src/components/organisms/TabCancellationPolicy/CancellationBody.tsx +24 -0
- package/src/components/organisms/TabCancellationPolicy/CancellationExcursion.tsx +30 -0
- package/src/components/organisms/TabCancellationPolicy/CancellationHeader.tsx +23 -0
- package/src/components/organisms/TabCancellationPolicy/CancellationTransfer.tsx +22 -0
- package/src/components/organisms/TabCancellationPolicy/HeaderAccom.tsx +22 -0
- package/src/components/organisms/TabCancellationPolicy/HeaderExcursion.tsx +18 -0
- package/src/components/organisms/TabCancellationPolicy/PolicyAccom/PolicyAccom.css +3 -0
- package/src/components/organisms/TabCancellationPolicy/PolicyAccom/PolicyAccom.tsx +3 -2
- package/src/components/organisms/TabCancellationPolicy/PolicyExcursion.tsx +18 -0
- package/src/components/organisms/TabCancellationPolicy/PolicyTransfer.tsx +11 -0
- package/src/components/organisms/TabCancellationPolicy/TabCancellationPolicy.tsx +29 -0
- package/src/components/ui/popover.tsx +2 -4
- package/src/styles/components/checkbox.css +16 -9
- package/src/styles/components/molecule/calendarInput.css +12 -13
- package/src/styles/components/molecule/service-selector.css +71 -23
- package/dist/components/ui/checkbox.d.ts +0 -4
- package/dist/components/ui/checkbox.js +0 -31
- package/src/components/ui/checkbox.tsx +0 -32
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DateRange } from
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
1
|
+
import { Locale } from 'date-fns/locale';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { DateRange } from 'react-day-picker';
|
|
4
|
+
import Icon from '../../atoms/Icon/Icon';
|
|
5
|
+
import { Button } from '../../ui/button';
|
|
6
|
+
import { Calendar } from '../../ui/calendar';
|
|
7
|
+
import TimePicker from './TimePicker';
|
|
8
8
|
|
|
9
9
|
export interface DateTimeProps {
|
|
10
|
-
mode?:
|
|
11
|
-
selectionMode?:
|
|
10
|
+
mode?: 'calendar' | 'time' | 'both';
|
|
11
|
+
selectionMode?: 'single' | 'range';
|
|
12
12
|
numberOfMonths?: 1 | 2;
|
|
13
13
|
disableBeforeToday?: boolean;
|
|
14
14
|
disableToday?: boolean;
|
|
15
15
|
defaultDateRange?: DateRange;
|
|
16
|
-
defaultTime?: { hour: string; minute: string; meridiem:
|
|
17
|
-
onChange?: (payload: {
|
|
16
|
+
defaultTime?: { hour: string; minute: string; meridiem: 'AM' | 'PM' };
|
|
17
|
+
onChange?: (payload: {
|
|
18
|
+
dateRange?: DateRange;
|
|
19
|
+
time?: { hour: string; minute: string; meridiem: 'AM' | 'PM' };
|
|
20
|
+
}) => void;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
const DateTime: React.FC<DateTimeProps> = ({
|
|
21
|
-
mode =
|
|
22
|
-
selectionMode =
|
|
24
|
+
mode = 'both',
|
|
25
|
+
selectionMode = 'range',
|
|
23
26
|
numberOfMonths = 2,
|
|
24
27
|
disableBeforeToday = true,
|
|
25
28
|
disableToday = false,
|
|
@@ -28,15 +31,19 @@ const DateTime: React.FC<DateTimeProps> = ({
|
|
|
28
31
|
onChange,
|
|
29
32
|
}) => {
|
|
30
33
|
const [dateRange, setDateRange] = useState<DateRange | undefined>(defaultDateRange);
|
|
31
|
-
const [
|
|
32
|
-
const [
|
|
33
|
-
const [
|
|
34
|
+
const [month, setMonth] = useState<Date | undefined>(defaultDateRange?.from);
|
|
35
|
+
const [hours, setHours] = useState<string>(defaultTime?.hour ?? '12');
|
|
36
|
+
const [minutes, setMinutes] = useState<string>(defaultTime?.minute ?? '00');
|
|
37
|
+
const [amPm, setAmPm] = useState<'AM' | 'PM'>(defaultTime?.meridiem ?? 'AM');
|
|
34
38
|
|
|
35
39
|
// notify parent when date or time changes
|
|
36
40
|
useEffect(() => {
|
|
37
41
|
onChange?.({
|
|
38
42
|
dateRange: dateRange ?? undefined,
|
|
39
|
-
time:
|
|
43
|
+
time:
|
|
44
|
+
mode === 'calendar'
|
|
45
|
+
? undefined
|
|
46
|
+
: { hour: hours, minute: minutes, meridiem: amPm },
|
|
40
47
|
});
|
|
41
48
|
}, [dateRange, hours, minutes, amPm, onChange, mode]);
|
|
42
49
|
|
|
@@ -60,9 +67,9 @@ const DateTime: React.FC<DateTimeProps> = ({
|
|
|
60
67
|
};
|
|
61
68
|
|
|
62
69
|
const resetTime = () => {
|
|
63
|
-
setHours(
|
|
64
|
-
setMinutes(
|
|
65
|
-
setAmPm(
|
|
70
|
+
setHours('12');
|
|
71
|
+
setMinutes('00');
|
|
72
|
+
setAmPm('AM');
|
|
66
73
|
};
|
|
67
74
|
|
|
68
75
|
const clearSelection = () => {
|
|
@@ -76,7 +83,7 @@ const DateTime: React.FC<DateTimeProps> = ({
|
|
|
76
83
|
setDateRange({ from: today, to: today });
|
|
77
84
|
};
|
|
78
85
|
|
|
79
|
-
const calendarMode = selectionMode ===
|
|
86
|
+
const calendarMode = selectionMode === 'single' ? 'single' : 'range';
|
|
80
87
|
|
|
81
88
|
const buildDisabled = () => {
|
|
82
89
|
const disabled: any[] = [];
|
|
@@ -95,44 +102,55 @@ const DateTime: React.FC<DateTimeProps> = ({
|
|
|
95
102
|
|
|
96
103
|
const disabledDays = buildDisabled();
|
|
97
104
|
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (defaultDateRange) {
|
|
107
|
+
setMonth(defaultDateRange?.from);
|
|
108
|
+
}
|
|
109
|
+
}, [defaultDateRange]);
|
|
110
|
+
|
|
98
111
|
return (
|
|
99
112
|
<div className="calendar--dropdown">
|
|
100
|
-
{mode !==
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
{mode !== 'time' &&
|
|
114
|
+
(() => {
|
|
115
|
+
const calendarProps: any = {
|
|
116
|
+
mode: calendarMode,
|
|
117
|
+
selected: dateRange,
|
|
118
|
+
onSelect: handleSelect,
|
|
119
|
+
weekStartsOn: 1,
|
|
120
|
+
month,
|
|
121
|
+
onMonthChange: setMonth,
|
|
122
|
+
showOutsideDays: false,
|
|
123
|
+
numberOfMonths: numberOfMonths,
|
|
124
|
+
disabled: disabledDays,
|
|
125
|
+
className: 'p-0',
|
|
126
|
+
formatters: {
|
|
127
|
+
formatWeekdayName: (weekday: Date, options?: { locale?: Locale }) => {
|
|
128
|
+
return weekday
|
|
129
|
+
.toLocaleDateString(options?.locale?.code, { weekday: 'short' })
|
|
130
|
+
.toUpperCase();
|
|
131
|
+
},
|
|
115
132
|
},
|
|
116
|
-
}
|
|
117
|
-
};
|
|
133
|
+
};
|
|
118
134
|
|
|
119
|
-
|
|
120
|
-
|
|
135
|
+
return <Calendar {...calendarProps} />;
|
|
136
|
+
})()}
|
|
121
137
|
|
|
122
|
-
{mode !==
|
|
123
|
-
<div className={`${mode ===
|
|
138
|
+
{mode !== 'calendar' && (
|
|
139
|
+
<div className={`${mode === 'both' ? 'calendar--time_container_separated' : ''}`}>
|
|
124
140
|
<TimePicker
|
|
125
141
|
label="Time"
|
|
126
142
|
hour={hours}
|
|
127
143
|
minute={minutes}
|
|
128
144
|
meridiem={amPm}
|
|
129
145
|
onChange={(h, m, mm) => {
|
|
130
|
-
const hh = String(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
const hh = String(Math.max(0, Math.min(12, Number(h || 0)))).padStart(
|
|
147
|
+
2,
|
|
148
|
+
'0'
|
|
149
|
+
);
|
|
150
|
+
const mmn = String(Math.max(0, Math.min(59, Number(m || 0)))).padStart(
|
|
151
|
+
2,
|
|
152
|
+
'0'
|
|
153
|
+
);
|
|
136
154
|
setHours(hh);
|
|
137
155
|
setMinutes(mmn);
|
|
138
156
|
setAmPm(mm);
|
|
@@ -141,7 +159,7 @@ const DateTime: React.FC<DateTimeProps> = ({
|
|
|
141
159
|
</div>
|
|
142
160
|
)}
|
|
143
161
|
|
|
144
|
-
{mode !==
|
|
162
|
+
{mode !== 'time' && (
|
|
145
163
|
<div className="calendar--footer">
|
|
146
164
|
<Button
|
|
147
165
|
variant="ghost"
|
|
@@ -149,8 +167,7 @@ const DateTime: React.FC<DateTimeProps> = ({
|
|
|
149
167
|
onClick={selectToday}
|
|
150
168
|
type="button"
|
|
151
169
|
className="calendar--footer--button"
|
|
152
|
-
disabled={disableToday}
|
|
153
|
-
>
|
|
170
|
+
disabled={disableToday}>
|
|
154
171
|
<Icon name="calendar-outline" size="sm" />
|
|
155
172
|
Today
|
|
156
173
|
</Button>
|
|
@@ -159,8 +176,7 @@ const DateTime: React.FC<DateTimeProps> = ({
|
|
|
159
176
|
size="sm"
|
|
160
177
|
onClick={clearSelection}
|
|
161
178
|
type="button"
|
|
162
|
-
className="calendar--footer--button"
|
|
163
|
-
>
|
|
179
|
+
className="calendar--footer--button">
|
|
164
180
|
Clear
|
|
165
181
|
</Button>
|
|
166
182
|
</div>
|
|
@@ -10,28 +10,48 @@ import {
|
|
|
10
10
|
import { DialogContentPolicy } from './DialogContentPolicy';
|
|
11
11
|
|
|
12
12
|
export interface CancellationItem {
|
|
13
|
+
/**
|
|
14
|
+
* The type of the cancellation.
|
|
15
|
+
*/
|
|
13
16
|
type: 'accommodation' | 'excursion';
|
|
17
|
+
/**
|
|
18
|
+
* The data of the cancellation.
|
|
19
|
+
*/
|
|
14
20
|
data: DialogCancellationAccomProps | DialogCancellationExcursionProps;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
export interface DialogCancellationListProps {
|
|
24
|
+
/**
|
|
25
|
+
* The cancellations to display.
|
|
26
|
+
*/
|
|
18
27
|
cancellations: CancellationItem[];
|
|
19
28
|
}
|
|
20
29
|
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
const isAccommodation = (
|
|
31
|
+
data: CancellationItem['data']
|
|
32
|
+
): data is DialogCancellationAccomProps => {
|
|
33
|
+
return 'hotelName' in data;
|
|
34
|
+
};
|
|
23
35
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
const isExcursion = (
|
|
37
|
+
data: CancellationItem['data']
|
|
38
|
+
): data is DialogCancellationExcursionProps => {
|
|
39
|
+
return 'excursionName' in data;
|
|
40
|
+
};
|
|
29
41
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
/**
|
|
43
|
+
* DialogCancellationList is a component that allows the user to display the cancellations.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* <DialogCancellationList
|
|
47
|
+
* cancellations={cancellations}
|
|
48
|
+
* />
|
|
49
|
+
*
|
|
50
|
+
* @param props - The props for the DialogCancellationList component.
|
|
51
|
+
* @returns The DialogCancellationList component.
|
|
52
|
+
*/
|
|
53
|
+
export const DialogCancellationList: React.FC<DialogCancellationListProps> = (props) => {
|
|
54
|
+
const { cancellations } = props;
|
|
35
55
|
|
|
36
56
|
return (
|
|
37
57
|
<DialogContentPolicy>
|
|
@@ -1,32 +1,48 @@
|
|
|
1
|
-
import { CheckedState } from '@radix-ui/react-checkbox';
|
|
2
1
|
import React, { useState } from 'react';
|
|
3
2
|
import Button from '../../atoms/Button/Button';
|
|
4
|
-
import
|
|
5
|
-
import { Checkbox } from '../../ui/checkbox';
|
|
3
|
+
import Checkbox from '../../atoms/Checkbox/Checkbox';
|
|
6
4
|
import { DialogCancellationAccom } from './DialogCancellationAccom';
|
|
7
5
|
import { DialogCancellationExcursion } from './DialogCancellationExcursion';
|
|
8
6
|
import { DialogCancellationList } from './DialogCancellationList';
|
|
9
7
|
|
|
10
8
|
export interface DialogContentPolicyProps {
|
|
9
|
+
/**
|
|
10
|
+
* The children to display.
|
|
11
|
+
*/
|
|
11
12
|
children: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* The callback function to call when the submit button is clicked.
|
|
15
|
+
*/
|
|
12
16
|
onSubmit?: () => void;
|
|
13
17
|
}
|
|
14
18
|
|
|
19
|
+
/**
|
|
20
|
+
* DialogContentPolicy is a component that allows the user to display the cancellation policy.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <DialogContentPolicy
|
|
24
|
+
* children={children}
|
|
25
|
+
* onSubmit={onSubmit}
|
|
26
|
+
* />
|
|
27
|
+
*
|
|
28
|
+
* @param props - The props for the DialogContentPolicy component.
|
|
29
|
+
* @returns The DialogContentPolicy component.
|
|
30
|
+
*/
|
|
15
31
|
export const DialogContentPolicy = (props: DialogContentPolicyProps) => {
|
|
16
32
|
const { children, onSubmit } = props;
|
|
17
|
-
const [accepted, setAccepted] = useState<
|
|
33
|
+
const [accepted, setAccepted] = useState<boolean>(false);
|
|
18
34
|
|
|
19
35
|
return (
|
|
20
36
|
<div className="cancellation-policy">
|
|
21
37
|
{children}
|
|
22
|
-
<div className="flex justify-end gap-x-
|
|
38
|
+
<div className="flex justify-end gap-x-5 py-9">
|
|
23
39
|
<div className="flex gap-x-2.5 items-center">
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
<Checkbox
|
|
41
|
+
checked={accepted}
|
|
42
|
+
onChange={setAccepted}
|
|
43
|
+
label="I've read and accept the cancellation policy."
|
|
44
|
+
labelPosition="leading"
|
|
45
|
+
/>
|
|
30
46
|
</div>
|
|
31
47
|
<Button
|
|
32
48
|
className="w-[250px]"
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { cn } from '@/src/lib/utils';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import '../../../styles/components/molecule/service-selector.css';
|
|
2
4
|
import Icon from '../../atoms/Icon/Icon';
|
|
3
5
|
import { Text } from '../../atoms/Typography/Typography';
|
|
4
|
-
import '
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover';
|
|
5
7
|
|
|
6
8
|
export type ServiceType = 'transfer' | 'accommodation' | 'excursion';
|
|
7
9
|
|
|
@@ -22,6 +24,8 @@ export interface ServiceSelectorProps {
|
|
|
22
24
|
disabled?: boolean;
|
|
23
25
|
/** Additional CSS classes */
|
|
24
26
|
className?: string;
|
|
27
|
+
/** Options to display */
|
|
28
|
+
options?: ServiceOption[];
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
const DEFAULT_OPTIONS: ServiceOption[] = [
|
|
@@ -44,12 +48,16 @@ const DEFAULT_OPTIONS: ServiceOption[] = [
|
|
|
44
48
|
},
|
|
45
49
|
];
|
|
46
50
|
|
|
51
|
+
export const DEFAULT_SERVICE_SELECTOR_OPTIONS: ServiceOption[] = DEFAULT_OPTIONS;
|
|
52
|
+
|
|
47
53
|
const ServiceSelector: React.FC<ServiceSelectorProps> = ({
|
|
48
54
|
value,
|
|
49
55
|
onChange,
|
|
50
56
|
disabled = false,
|
|
57
|
+
options = DEFAULT_OPTIONS,
|
|
51
58
|
className = '',
|
|
52
59
|
}) => {
|
|
60
|
+
const [selectedValue, setSelectedValue] = useState(value);
|
|
53
61
|
const [isOpen, setIsOpen] = useState(false);
|
|
54
62
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
55
63
|
|
|
@@ -77,103 +85,103 @@ const ServiceSelector: React.FC<ServiceSelectorProps> = ({
|
|
|
77
85
|
if (disabled || option.disabled) return;
|
|
78
86
|
onChange(option.value);
|
|
79
87
|
setIsOpen(false);
|
|
88
|
+
setSelectedValue(option.value);
|
|
80
89
|
};
|
|
81
90
|
|
|
82
91
|
const getDropdownState = () => {
|
|
83
92
|
if (disabled) return 'disabled';
|
|
84
93
|
// If a service is selected, always show selected state (even if open)
|
|
85
|
-
if (
|
|
94
|
+
if (selectedValue) return 'selected';
|
|
86
95
|
if (isOpen) return 'open';
|
|
87
96
|
return 'default';
|
|
88
97
|
};
|
|
98
|
+
const defaultOptions = options.length > 0 ? options : DEFAULT_OPTIONS;
|
|
89
99
|
|
|
90
|
-
const selectedOption =
|
|
100
|
+
const selectedOption = selectedValue
|
|
101
|
+
? defaultOptions.find((opt) => opt.value === selectedValue)
|
|
102
|
+
: null;
|
|
91
103
|
const displayText = selectedOption ? selectedOption.label : 'Select a service';
|
|
92
104
|
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
setSelectedValue(value);
|
|
107
|
+
}, [value]);
|
|
108
|
+
|
|
93
109
|
return (
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
aria-haspopup="listbox"
|
|
102
|
-
>
|
|
103
|
-
<div className="service-selector__trigger-content">
|
|
104
|
-
{selectedOption && (
|
|
105
|
-
<Icon
|
|
106
|
-
name={selectedOption.icon as any}
|
|
107
|
-
size="md"
|
|
108
|
-
className="service-selector__trigger-icon"
|
|
109
|
-
/>
|
|
110
|
+
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
|
111
|
+
<PopoverTrigger asChild>
|
|
112
|
+
<button
|
|
113
|
+
type="button"
|
|
114
|
+
className={cn(
|
|
115
|
+
`service-selector__trigger service-selector__trigger--${getDropdownState()}`,
|
|
116
|
+
className
|
|
110
117
|
)}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
>
|
|
116
|
-
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
118
|
+
onClick={handleToggleDropdown}
|
|
119
|
+
disabled={disabled}
|
|
120
|
+
aria-expanded={isOpen}
|
|
121
|
+
aria-haspopup="listbox">
|
|
122
|
+
<div className="service-selector__trigger-content">
|
|
123
|
+
{selectedOption && (
|
|
124
|
+
<Icon
|
|
125
|
+
name={selectedOption.icon as any}
|
|
126
|
+
size="md"
|
|
127
|
+
className="service-selector__trigger-icon"
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
130
|
+
<Text size="base" variant="bold" className="service-selector__trigger-text">
|
|
131
|
+
{displayText}
|
|
132
|
+
</Text>
|
|
133
|
+
</div>
|
|
134
|
+
<Icon
|
|
135
|
+
name="chevron-down-new"
|
|
136
|
+
size="sm"
|
|
137
|
+
className="service-selector__trigger-chevron"
|
|
138
|
+
style={{
|
|
139
|
+
transform: isOpen ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
140
|
+
transition: 'transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
141
|
+
transformOrigin: 'center',
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
</button>
|
|
145
|
+
</PopoverTrigger>
|
|
146
|
+
<PopoverContent className="service-selector__panel" align="start">
|
|
147
|
+
<div className="service-selector__content">
|
|
148
|
+
<div className="service-selector__options-wrapper">
|
|
149
|
+
{defaultOptions.map((option) => {
|
|
150
|
+
const isSelected = value === option.value;
|
|
151
|
+
const isDisabled = option.disabled || disabled;
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<button
|
|
155
|
+
key={option.value}
|
|
156
|
+
type="button"
|
|
157
|
+
className={`service-selector__option ${isSelected ? 'service-selector__option--selected' : ''} ${isDisabled ? 'service-selector__option--disabled' : ''}`}
|
|
158
|
+
onClick={() => handleOptionSelect(option)}
|
|
159
|
+
disabled={isDisabled}
|
|
160
|
+
role="option"
|
|
161
|
+
aria-selected={isSelected}>
|
|
162
|
+
<Icon
|
|
163
|
+
name={option.icon as any}
|
|
164
|
+
size="md"
|
|
165
|
+
className={`service-selector__option-icon ${isSelected ? 'service-selector__option-icon--selected' : ''}`}
|
|
166
|
+
/>
|
|
167
|
+
<Text
|
|
168
|
+
size="base"
|
|
169
|
+
variant="bold"
|
|
170
|
+
color={isSelected ? 'inverted' : 'default'}
|
|
171
|
+
className="service-selector__option-text">
|
|
172
|
+
{option.label}
|
|
173
|
+
</Text>
|
|
174
|
+
{option.badge && (
|
|
175
|
+
<span className="service-selector__option-badge">{option.badge}</span>
|
|
176
|
+
)}
|
|
177
|
+
</button>
|
|
178
|
+
);
|
|
179
|
+
})}
|
|
171
180
|
</div>
|
|
172
181
|
</div>
|
|
173
|
-
|
|
174
|
-
</
|
|
182
|
+
</PopoverContent>
|
|
183
|
+
</Popover>
|
|
175
184
|
);
|
|
176
185
|
};
|
|
177
186
|
|
|
178
187
|
export default ServiceSelector;
|
|
179
|
-
|
|
@@ -11,7 +11,13 @@ import {
|
|
|
11
11
|
} from '../../molecules/BookingPax/BookingPaxClient/BookingPaxClient';
|
|
12
12
|
|
|
13
13
|
export interface BookingPaxData {
|
|
14
|
+
/**
|
|
15
|
+
* The type of the booking pax.
|
|
16
|
+
*/
|
|
14
17
|
type: 'accommodation' | 'excursion' | 'transfer';
|
|
18
|
+
/**
|
|
19
|
+
* The data of the booking pax.
|
|
20
|
+
*/
|
|
15
21
|
data:
|
|
16
22
|
| Omit<BookingPaxAccomProps, 'clientsInfo'>
|
|
17
23
|
| Omit<BookingPaxExcursionProps, 'clientsInfo'>
|
|
@@ -19,25 +25,64 @@ export interface BookingPaxData {
|
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export interface BookingPaxAutoFilledData {
|
|
28
|
+
/**
|
|
29
|
+
* The type of the booking pax.
|
|
30
|
+
*/
|
|
22
31
|
type: BookingPaxData['type'];
|
|
32
|
+
/**
|
|
33
|
+
* The parent index of the booking pax.
|
|
34
|
+
*/
|
|
23
35
|
parentIndex: number;
|
|
36
|
+
/**
|
|
37
|
+
* The room index of the booking pax.
|
|
38
|
+
*/
|
|
24
39
|
roomIndex?: number;
|
|
40
|
+
/**
|
|
41
|
+
* The selected clients of the booking pax.
|
|
42
|
+
*/
|
|
25
43
|
selectedClients: BookingPaxClientInfo[];
|
|
26
44
|
}
|
|
27
45
|
|
|
28
46
|
export interface BookingPaxProps {
|
|
47
|
+
/**
|
|
48
|
+
* The data of the booking pax.
|
|
49
|
+
*/
|
|
29
50
|
data: BookingPaxData[];
|
|
51
|
+
/**
|
|
52
|
+
* The clients info of the booking pax.
|
|
53
|
+
*/
|
|
30
54
|
clientsInfo: BookingPaxClientInfo[];
|
|
55
|
+
/**
|
|
56
|
+
* Whether the booking pax is submitted.
|
|
57
|
+
*/
|
|
31
58
|
isSubmitted?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The callback function to call when the pax changes.
|
|
61
|
+
*/
|
|
32
62
|
onPaxChange?: (
|
|
33
63
|
index: number,
|
|
34
64
|
type: BookingPaxData['type'],
|
|
35
65
|
options: BookingPaxClientOptions
|
|
36
66
|
) => void;
|
|
67
|
+
/**
|
|
68
|
+
* The callback function to call when the remark changes.
|
|
69
|
+
*/
|
|
37
70
|
onRemarkChange?: (index: number, type: BookingPaxData['type'], value: string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* The callback function to call when the error changes.
|
|
73
|
+
*/
|
|
38
74
|
onError?: (index: number, type: BookingPaxData['type'], hasError: boolean) => void;
|
|
75
|
+
/**
|
|
76
|
+
* The callback function to call when the time changes.
|
|
77
|
+
*/
|
|
39
78
|
onTimeChange?: (index: number, value: string | string[]) => void;
|
|
79
|
+
/**
|
|
80
|
+
* The callback function to call when the flight number changes.
|
|
81
|
+
*/
|
|
40
82
|
onFlightNumberChange?: (index: number, value: string) => void;
|
|
83
|
+
/**
|
|
84
|
+
* The callback function to call when the auto filled data changes.
|
|
85
|
+
*/
|
|
41
86
|
onAutoFilled?: (data: BookingPaxAutoFilledData[]) => void;
|
|
42
87
|
}
|
|
43
88
|
|
|
@@ -60,6 +105,25 @@ const isTransferData = (
|
|
|
60
105
|
return 'from' in data && 'to' in data && 'type' in data;
|
|
61
106
|
};
|
|
62
107
|
|
|
108
|
+
/**
|
|
109
|
+
* BookingPaxList is a component that allows the user to select the pax for a booking.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* <BookingPaxList
|
|
113
|
+
* data={data}
|
|
114
|
+
* clientsInfo={clientsInfo}
|
|
115
|
+
* isSubmitted={isSubmitted}
|
|
116
|
+
* onPaxChange={onPaxChange}
|
|
117
|
+
* onRemarkChange={onRemarkChange}
|
|
118
|
+
* onError={onError}
|
|
119
|
+
* onTimeChange={onTimeChange}
|
|
120
|
+
* onFlightNumberChange={onFlightNumberChange}
|
|
121
|
+
* onAutoFilled={onAutoFilled}
|
|
122
|
+
* />
|
|
123
|
+
*
|
|
124
|
+
* @param props - The props for the BookingPaxList component.
|
|
125
|
+
* @returns The BookingPaxList component.
|
|
126
|
+
*/
|
|
63
127
|
export const BookingPaxList: React.FC<BookingPaxProps> = (props) => {
|
|
64
128
|
const {
|
|
65
129
|
data,
|