mautourco-components 0.2.22 → 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/Icon/icons/PlusCircleIcon.js +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/Calendar/DateTime.d.ts +5 -5
- package/dist/components/molecules/Calendar/DateTime.js +48 -37
- package/dist/components/molecules/ServiceSelector/ServiceSelector.d.ts +3 -0
- package/dist/components/molecules/ServiceSelector/ServiceSelector.js +23 -12
- 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/PaxSelector/PaxSelector.d.ts +1 -0
- package/dist/components/organisms/PaxSelector/PaxSelector.js +50 -28
- package/dist/components/ui/popover.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/styles/components/checkbox.css +5 -4
- package/dist/styles/components/molecule/calendarInput.css +3 -4
- package/dist/styles/components/molecule/service-selector.css +70 -21
- package/package.json +1 -1
- package/src/components/atoms/Icon/icons/PlusCircleIcon.tsx +2 -2
- package/src/components/molecules/AddItemButton/AddItemButton.css +5 -0
- package/src/components/molecules/AddItemButton/AddItemButton.tsx +18 -0
- package/src/components/molecules/Calendar/DateTime.tsx +69 -53
- package/src/components/molecules/ServiceSelector/ServiceSelector.tsx +91 -83
- 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/PaxSelector/PaxSelector.tsx +305 -193
- package/src/components/ui/popover.tsx +2 -4
- package/src/styles/components/checkbox.css +5 -4
- package/src/styles/components/molecule/calendarInput.css +12 -13
- package/src/styles/components/molecule/service-selector.css +71 -23
|
@@ -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>
|
|
@@ -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
|
-
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import Button from '../../atoms/Button/Button';
|
|
3
|
+
import Checkbox from '../../atoms/Checkbox/Checkbox';
|
|
4
|
+
import { Text } from '../../atoms/Typography/Typography';
|
|
5
|
+
import { BookingPaxClientInfo } from '../../molecules/BookingPax';
|
|
6
|
+
import ServiceSelector, {
|
|
7
|
+
ServiceOption,
|
|
8
|
+
ServiceType,
|
|
9
|
+
} from '../../molecules/ServiceSelector';
|
|
10
|
+
import DateTimePicker from '../DateTimePicker/DateTimePicker';
|
|
11
|
+
|
|
12
|
+
export interface AddItemNewServiceProps {
|
|
13
|
+
options?: ServiceOption[];
|
|
14
|
+
date: string | string[];
|
|
15
|
+
clients: BookingPaxClientInfo[];
|
|
16
|
+
onServiceChange: (service: ServiceType) => void;
|
|
17
|
+
onNext: (selectedClients: BookingPaxClientInfo[]) => void;
|
|
18
|
+
onBack: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const AddItemNewService: React.FC<AddItemNewServiceProps> = (props) => {
|
|
22
|
+
const { date, options, clients, onServiceChange, onNext, onBack } = props;
|
|
23
|
+
const [service, setService] = useState<ServiceType>('accommodation');
|
|
24
|
+
const [selectedClients, setSelectedClients] = useState<BookingPaxClientInfo[]>([]);
|
|
25
|
+
const handleServiceChange = (service: ServiceType) => {
|
|
26
|
+
onServiceChange(service);
|
|
27
|
+
setService(service);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const isAccommodation = service === 'accommodation';
|
|
31
|
+
const selectionMode = isAccommodation ? 'range' : 'single';
|
|
32
|
+
const numberOfMonths = isAccommodation ? 2 : 1;
|
|
33
|
+
|
|
34
|
+
const handleClientChange = useCallback(
|
|
35
|
+
(client: BookingPaxClientInfo) => {
|
|
36
|
+
if (selectedClients.includes(client)) {
|
|
37
|
+
setSelectedClients(selectedClients.filter((c) => c.clientId !== client.clientId));
|
|
38
|
+
} else {
|
|
39
|
+
setSelectedClients([...selectedClients, client]);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
[selectedClients]
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className="space-y-9">
|
|
47
|
+
<div className="flex sm:items-center gap-4 flex-col sm:flex-row">
|
|
48
|
+
<ServiceSelector
|
|
49
|
+
className="sm:basis-[245px] xl:basis-[260px] shrink-0 grow-0"
|
|
50
|
+
value={service}
|
|
51
|
+
onChange={handleServiceChange}
|
|
52
|
+
options={options}
|
|
53
|
+
/>
|
|
54
|
+
<div className="sm:basis-[245px] xl:basis-[260px] shrink-0 grow-0">
|
|
55
|
+
<DateTimePicker
|
|
56
|
+
mode="calendar"
|
|
57
|
+
selectionMode={selectionMode}
|
|
58
|
+
defaultValue={date}
|
|
59
|
+
placeholder="Select date"
|
|
60
|
+
numberOfMonths={numberOfMonths}
|
|
61
|
+
iconPosition="left"
|
|
62
|
+
iconBGFull={false}
|
|
63
|
+
showChevron={true}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
<div className="space-y-4">
|
|
68
|
+
<Text variant="bold">Please select the pax affected by the new service</Text>
|
|
69
|
+
<ul>
|
|
70
|
+
{clients.map((client, index) => (
|
|
71
|
+
<li key={`cl-${index}`}>
|
|
72
|
+
<Checkbox
|
|
73
|
+
id={`cl-${index}`}
|
|
74
|
+
label={`${client.firstName} ${client.lastName} (${client.clientType}${client.clientType !== 'Adult' ? ` - ${client.age} years old` : ''})`}
|
|
75
|
+
checked={selectedClients.some((c) => c.clientId === client.clientId)}
|
|
76
|
+
onChange={() => handleClientChange(client)}
|
|
77
|
+
/>
|
|
78
|
+
</li>
|
|
79
|
+
))}
|
|
80
|
+
</ul>
|
|
81
|
+
</div>
|
|
82
|
+
<div className="flex justify-end gap-x-4 [&>*]:w-[250px] pb-2">
|
|
83
|
+
<Button variant="outline-secondary" onClick={onBack}>
|
|
84
|
+
Back
|
|
85
|
+
</Button>
|
|
86
|
+
<Button
|
|
87
|
+
variant="secondary"
|
|
88
|
+
onClick={() => onNext(selectedClients)}
|
|
89
|
+
disabled={selectedClients.length === 0}>
|
|
90
|
+
Next
|
|
91
|
+
</Button>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Text } from '../../atoms/Typography/Typography';
|
|
2
|
+
import { AddItemButton } from '../../molecules/AddItemButton/AddItemButton';
|
|
3
|
+
|
|
4
|
+
export enum AddItemType {
|
|
5
|
+
NEW = 'NEW',
|
|
6
|
+
EXISTING = 'EXISTING',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface AddItemSelectorProps {
|
|
10
|
+
onAddItem?: (type: AddItemType) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const AddItemSelector: React.FC<AddItemSelectorProps> = ({ onAddItem }) => {
|
|
14
|
+
return (
|
|
15
|
+
<div className="space-y-9">
|
|
16
|
+
<Text size="sm" variant="medium">
|
|
17
|
+
If you are sure you want to add this service, please confirm below. New prices and
|
|
18
|
+
cancellation policies will apply to the added service.
|
|
19
|
+
</Text>
|
|
20
|
+
<div className="grid grid-cols-2 gap-4">
|
|
21
|
+
<AddItemButton
|
|
22
|
+
label={
|
|
23
|
+
<>
|
|
24
|
+
Add new service <br /> and new pax
|
|
25
|
+
</>
|
|
26
|
+
}
|
|
27
|
+
onClick={() => onAddItem?.(AddItemType.NEW)}
|
|
28
|
+
/>
|
|
29
|
+
<AddItemButton
|
|
30
|
+
label={
|
|
31
|
+
<>
|
|
32
|
+
Add new service <br /> for your existing pax
|
|
33
|
+
</>
|
|
34
|
+
}
|
|
35
|
+
onClick={() => onAddItem?.(AddItemType.EXISTING)}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
<Text size="sm" variant="medium">
|
|
39
|
+
Note: This action is irreversible and cannot be undone.
|
|
40
|
+
</Text>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|