@arquimedes.co/eureka-forms 3.0.47-test → 3.0.49-new-steps
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/@Types/AvailabilityFormStep.d.ts +48 -0
- package/dist/@Types/AvailabilityFormStep.js +24 -0
- package/dist/@Types/BankAccountFormStep.d.ts +67 -0
- package/dist/@Types/BankAccountFormStep.js +14 -0
- package/dist/@Types/BookingFormStep.d.ts +156 -0
- package/dist/@Types/BookingFormStep.js +44 -0
- package/dist/@Types/CalendarFormStep.d.ts +192 -0
- package/dist/@Types/CalendarFormStep.js +48 -0
- package/dist/@Types/CommunicationChannelFormStep.d.ts +51 -0
- package/dist/@Types/CommunicationChannelFormStep.js +15 -0
- package/dist/@Types/ConsentFormStep.d.ts +36 -0
- package/dist/@Types/ConsentFormStep.js +8 -0
- package/dist/@Types/EntityFormFormStep.d.ts +66 -0
- package/dist/@Types/EntityFormFormStep.js +20 -0
- package/dist/@Types/EventFormStep.d.ts +52 -0
- package/dist/@Types/EventFormStep.js +13 -0
- package/dist/@Types/ExternalReferenceFormStep.d.ts +74 -0
- package/dist/@Types/ExternalReferenceFormStep.js +20 -0
- package/dist/@Types/FormStep.d.ts +7 -2
- package/dist/@Types/FormStep.js +2 -1
- package/dist/@Types/LocationFormStep.d.ts +159 -0
- package/dist/@Types/LocationFormStep.js +46 -0
- package/dist/@Types/NumericFormSteps.d.ts +108 -0
- package/dist/@Types/NumericFormSteps.js +20 -0
- package/dist/@Types/PredefinedSelectorFormStep.d.ts +51 -0
- package/dist/@Types/PredefinedSelectorFormStep.js +39 -0
- package/dist/@Types/StepRef.d.ts +135 -0
- package/dist/@Types/StepRef.js +49 -0
- package/dist/FormSteps/BookingStep/BookingStep.d.ts +17 -0
- package/dist/FormSteps/BookingStep/BookingStep.js +14 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +3 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +362 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.module.css +174 -0
- package/dist/FormSteps/CalendarStep/CalendarStep.d.ts +7 -0
- package/dist/FormSteps/CalendarStep/CalendarStep.js +14 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.d.ts +3 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.js +269 -0
- package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.module.css +531 -0
- package/dist/FormSteps/LocationStep/LocationStep.d.ts +10 -0
- package/dist/FormSteps/LocationStep/LocationStep.js +14 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +3 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +47 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +18 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +3 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +168 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +94 -0
- package/dist/FormSteps/NumberStep/NumberStep.d.ts +10 -0
- package/dist/FormSteps/NumberStep/NumberStep.js +14 -0
- package/dist/FormSteps/Step.js +16 -0
- package/dist/FormSteps/StepFunctions.js +14 -0
- package/dist/FormSteps/StepFunctions.test.js +57 -3
- package/dist/Icons/@ErkIcon.d.ts +2 -2
- package/dist/Icons/@ErkIcon.js +2 -2
- package/dist/Icons/AddIcon.d.ts +3 -0
- package/dist/Icons/AddIcon.js +7 -0
- package/dist/Icons/EditIcon.d.ts +3 -0
- package/dist/Icons/EditIcon.js +7 -0
- package/dist/Icons/RemoveIcon.d.ts +3 -0
- package/dist/Icons/RemoveIcon.js +7 -0
- package/dist/Icons/ViewDayIcon.d.ts +3 -0
- package/dist/Icons/ViewDayIcon.js +7 -0
- package/dist/Icons/ViewWeekIcon.d.ts +3 -0
- package/dist/Icons/ViewWeekIcon.js +7 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +19 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +80 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +82 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +29 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +139 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +1 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +2 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +1 -2
- package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +23 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.js +73 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.module.css +29 -0
- package/dist/Shared/ErkLocationField/addressFields.d.ts +12 -0
- package/dist/Shared/ErkLocationField/addressFields.js +34 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +6 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.js +51 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +15 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.js +499 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +115 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +42 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.js +170 -0
- package/dist/constants/FormStepTypes.d.ts +5 -1
- package/dist/constants/FormStepTypes.js +4 -0
- package/package.json +2 -1
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useState, useCallback, useEffect, useId } from 'react';
|
|
3
|
+
import { Dialog, DialogTitle, DialogContent, Avatar, CircularProgress, InputAdornment, styled, } from '@mui/material';
|
|
4
|
+
import { alpha, useTheme } from '@mui/material/styles';
|
|
5
|
+
import { format, addDays, startOfDay, isSameDay, isToday } from 'date-fns';
|
|
6
|
+
import { es } from 'date-fns/locale';
|
|
7
|
+
import { PersonSelectionMode } from '../../../@Types/BookingFormStep';
|
|
8
|
+
import { useFormStep } from '../../StepHooks';
|
|
9
|
+
import FormContext from '../../../Contexts/FormContext';
|
|
10
|
+
import { selectBreakPoint, useAppSelector } from '../../../hooks';
|
|
11
|
+
import { calcStepWidth } from '../../StepFunctions';
|
|
12
|
+
import { StyledTextField } from '../../../Shared/ErkTextField/ErkTextField';
|
|
13
|
+
import ErkButton from '../../../Shared/ErkButton/ErkButton';
|
|
14
|
+
import CalendarIcon from '../../../Icons/CalendarIcon';
|
|
15
|
+
import CloseIcon from '../../../Icons/CloseIcon';
|
|
16
|
+
import ArrowLeftIcon from '../../../Icons/ArrowLeftIcon';
|
|
17
|
+
import ArrowRightIcon from '../../../Icons/ArrowRightIcon';
|
|
18
|
+
import PersonIcon from '../../../Icons/PersonIcon';
|
|
19
|
+
import styles from './MaterialBookingStep.module.css';
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Theme-aware styled components
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
const SummaryCard = styled('div')(({ theme }) => ({
|
|
24
|
+
display: 'flex',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
gap: 12,
|
|
27
|
+
padding: '12px 16px',
|
|
28
|
+
border: `1px solid ${theme.palette.outline.main}`,
|
|
29
|
+
borderRadius: 10,
|
|
30
|
+
backgroundColor: theme.palette.stepBackgroundColor.default,
|
|
31
|
+
}));
|
|
32
|
+
const EmptyReadOnly = styled('div')(({ theme }) => ({
|
|
33
|
+
display: 'flex',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
gap: 10,
|
|
36
|
+
padding: '14px 16px',
|
|
37
|
+
border: `1px solid ${theme.palette.outline.main}`,
|
|
38
|
+
borderRadius: 10,
|
|
39
|
+
backgroundColor: theme.palette.stepBackgroundColor.default,
|
|
40
|
+
color: alpha(theme.palette.text.primary, 0.45),
|
|
41
|
+
fontSize: 14,
|
|
42
|
+
}));
|
|
43
|
+
const PersonCard = styled('div')(({ theme, active }) => ({
|
|
44
|
+
display: 'flex',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
gap: 14,
|
|
47
|
+
padding: '14px 20px',
|
|
48
|
+
cursor: 'pointer',
|
|
49
|
+
borderBottom: `1px solid ${alpha(theme.palette.text.primary, 0.06)}`,
|
|
50
|
+
backgroundColor: active ? alpha(theme.palette.primary.main, 0.05) : 'transparent',
|
|
51
|
+
transition: 'background 0.15s',
|
|
52
|
+
'&:last-child': { borderBottom: 'none' },
|
|
53
|
+
'&:hover': { backgroundColor: alpha(theme.palette.text.primary, 0.03) },
|
|
54
|
+
}));
|
|
55
|
+
const PersonChip = styled('button')(({ theme }) => ({
|
|
56
|
+
display: 'inline-flex',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
gap: 8,
|
|
59
|
+
marginTop: 10,
|
|
60
|
+
padding: '6px 12px 6px 8px',
|
|
61
|
+
border: `1px solid ${theme.palette.outline.main}`,
|
|
62
|
+
borderRadius: 10,
|
|
63
|
+
background: 'none',
|
|
64
|
+
cursor: 'pointer',
|
|
65
|
+
fontSize: 13,
|
|
66
|
+
fontWeight: 500,
|
|
67
|
+
color: 'inherit',
|
|
68
|
+
fontFamily: 'inherit',
|
|
69
|
+
transition: 'border-color 0.2s, background 0.2s',
|
|
70
|
+
'&:hover': {
|
|
71
|
+
borderColor: theme.palette.primary.main,
|
|
72
|
+
background: alpha(theme.palette.primary.main, 0.04),
|
|
73
|
+
},
|
|
74
|
+
}));
|
|
75
|
+
const DateChipButton = styled('button', {
|
|
76
|
+
shouldForwardProp: (p) => p !== 'selected' && p !== 'todayHighlight',
|
|
77
|
+
})(({ theme, selected, todayHighlight }) => ({
|
|
78
|
+
display: 'flex',
|
|
79
|
+
flexDirection: 'column',
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
justifyContent: 'center',
|
|
82
|
+
flex: 1,
|
|
83
|
+
minWidth: 0,
|
|
84
|
+
padding: '8px 4px',
|
|
85
|
+
border: `1px solid ${selected || todayHighlight ? theme.palette.primary.main : theme.palette.outline.main}`,
|
|
86
|
+
borderRadius: 10,
|
|
87
|
+
cursor: 'pointer',
|
|
88
|
+
background: selected ? theme.palette.primary.main : 'transparent',
|
|
89
|
+
color: selected ? theme.palette.primary.contrastText ?? '#fff' : 'inherit',
|
|
90
|
+
fontFamily: 'inherit',
|
|
91
|
+
transition: 'border-color 0.15s, background 0.15s, color 0.15s',
|
|
92
|
+
gap: 1,
|
|
93
|
+
'&:hover:not(:disabled)': {
|
|
94
|
+
borderColor: theme.palette.primary.main,
|
|
95
|
+
background: selected ? theme.palette.primary.main : alpha(theme.palette.primary.main, 0.05),
|
|
96
|
+
},
|
|
97
|
+
'&:disabled': {
|
|
98
|
+
opacity: 0.35,
|
|
99
|
+
cursor: 'default',
|
|
100
|
+
},
|
|
101
|
+
}));
|
|
102
|
+
const SlotRowButton = styled('button')(({ theme }) => ({
|
|
103
|
+
padding: '12px 16px',
|
|
104
|
+
border: `1.5px solid ${theme.palette.outline.main}`,
|
|
105
|
+
borderRadius: 10,
|
|
106
|
+
cursor: 'pointer',
|
|
107
|
+
background: 'transparent',
|
|
108
|
+
fontSize: 15,
|
|
109
|
+
fontWeight: 500,
|
|
110
|
+
textAlign: 'left',
|
|
111
|
+
color: theme.palette.text.primary,
|
|
112
|
+
fontFamily: 'inherit',
|
|
113
|
+
transition: 'border-color 0.15s, background 0.15s, color 0.15s',
|
|
114
|
+
'&:hover': {
|
|
115
|
+
borderColor: theme.palette.primary.main,
|
|
116
|
+
background: alpha(theme.palette.primary.main, 0.04),
|
|
117
|
+
color: theme.palette.primary.main,
|
|
118
|
+
},
|
|
119
|
+
}));
|
|
120
|
+
const IconBtn = styled('button')(({ theme }) => ({
|
|
121
|
+
display: 'flex',
|
|
122
|
+
alignItems: 'center',
|
|
123
|
+
justifyContent: 'center',
|
|
124
|
+
padding: 6,
|
|
125
|
+
border: 'none',
|
|
126
|
+
borderRadius: '50%',
|
|
127
|
+
background: 'none',
|
|
128
|
+
cursor: 'pointer',
|
|
129
|
+
color: 'inherit',
|
|
130
|
+
opacity: 0.6,
|
|
131
|
+
flexShrink: 0,
|
|
132
|
+
transition: 'opacity 0.15s, background 0.15s',
|
|
133
|
+
'&:hover': {
|
|
134
|
+
opacity: 1,
|
|
135
|
+
background: alpha(theme.palette.text.primary, 0.06),
|
|
136
|
+
},
|
|
137
|
+
}));
|
|
138
|
+
const StripArrowBtn = styled('button')(({ theme }) => ({
|
|
139
|
+
flexShrink: 0,
|
|
140
|
+
display: 'flex',
|
|
141
|
+
alignItems: 'center',
|
|
142
|
+
justifyContent: 'center',
|
|
143
|
+
padding: 4,
|
|
144
|
+
border: 'none',
|
|
145
|
+
borderRadius: '50%',
|
|
146
|
+
background: 'none',
|
|
147
|
+
cursor: 'pointer',
|
|
148
|
+
color: 'inherit',
|
|
149
|
+
opacity: 0.6,
|
|
150
|
+
transition: 'opacity 0.15s, background 0.15s',
|
|
151
|
+
'&:hover:not(:disabled)': {
|
|
152
|
+
opacity: 1,
|
|
153
|
+
background: alpha(theme.palette.text.primary, 0.06),
|
|
154
|
+
},
|
|
155
|
+
'&:disabled': { opacity: 0.2, cursor: 'default' },
|
|
156
|
+
}));
|
|
157
|
+
const ClearBtn = styled('button')(({ theme }) => ({
|
|
158
|
+
flexShrink: 0,
|
|
159
|
+
display: 'flex',
|
|
160
|
+
alignItems: 'center',
|
|
161
|
+
justifyContent: 'center',
|
|
162
|
+
padding: 4,
|
|
163
|
+
border: 'none',
|
|
164
|
+
borderRadius: '50%',
|
|
165
|
+
background: 'none',
|
|
166
|
+
cursor: 'pointer',
|
|
167
|
+
color: 'inherit',
|
|
168
|
+
opacity: 0.45,
|
|
169
|
+
transition: 'opacity 0.15s, background 0.15s',
|
|
170
|
+
'&:hover': {
|
|
171
|
+
opacity: 1,
|
|
172
|
+
background: alpha(theme.palette.text.primary, 0.06),
|
|
173
|
+
},
|
|
174
|
+
}));
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
// Helpers
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
function formatDate(date) {
|
|
179
|
+
return format(date, 'yyyy-MM-dd');
|
|
180
|
+
}
|
|
181
|
+
function formatDisplayDate(date) {
|
|
182
|
+
return format(date, 'd \'de\' MMMM', { locale: es });
|
|
183
|
+
}
|
|
184
|
+
function initials(name) {
|
|
185
|
+
return name
|
|
186
|
+
.split(' ')
|
|
187
|
+
.slice(0, 2)
|
|
188
|
+
.map((w) => w[0])
|
|
189
|
+
.join('')
|
|
190
|
+
.toUpperCase();
|
|
191
|
+
}
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
// Component
|
|
194
|
+
// ---------------------------------------------------------------------------
|
|
195
|
+
function MaterialBookingStep({ step, editable, fetchSlots }) {
|
|
196
|
+
const currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
197
|
+
const { postview } = useAppSelector((state) => state.global);
|
|
198
|
+
const form = useContext(FormContext);
|
|
199
|
+
const theme = useTheme();
|
|
200
|
+
const triggerId = useId();
|
|
201
|
+
const isReadOnly = !editable || postview;
|
|
202
|
+
const widthStyle = currentBreakPoint <= step.size ? '100%' : calcStepWidth(step.size, form.size);
|
|
203
|
+
const needsPerson = step.personSelectionMode && step.personSelectionMode !== PersonSelectionMode.NONE;
|
|
204
|
+
const personsOptional = step.personSelectionMode === PersonSelectionMode.OPTIONAL;
|
|
205
|
+
// ------------------------------------------------------------------
|
|
206
|
+
// Form state
|
|
207
|
+
// ------------------------------------------------------------------
|
|
208
|
+
const { ref, value, onChange, error } = useFormStep(step, {
|
|
209
|
+
defaultValue: null,
|
|
210
|
+
rules: {
|
|
211
|
+
required: step.required ? 'Selecciona una cita' : undefined,
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
// ------------------------------------------------------------------
|
|
215
|
+
// Dialog state
|
|
216
|
+
// ------------------------------------------------------------------
|
|
217
|
+
const [open, setOpen] = useState(false);
|
|
218
|
+
const [phase, setPhase] = useState(needsPerson ? 'person' : 'datetime');
|
|
219
|
+
const [selectedPersonId, setSelectedPersonId] = useState(undefined);
|
|
220
|
+
const [selectedPerson, setSelectedPerson] = useState(undefined);
|
|
221
|
+
const [weekStart, setWeekStart] = useState(() => startOfDay(new Date()));
|
|
222
|
+
const [selectedDate, setSelectedDate] = useState(() => startOfDay(new Date()));
|
|
223
|
+
const [slots, setSlots] = useState([]);
|
|
224
|
+
const [loadingSlots, setLoadingSlots] = useState(false);
|
|
225
|
+
const STRIP_DAYS = 7;
|
|
226
|
+
const days = Array.from({ length: STRIP_DAYS }, (_, i) => addDays(weekStart, i));
|
|
227
|
+
// ------------------------------------------------------------------
|
|
228
|
+
// Fetch slots when date or person changes
|
|
229
|
+
// ------------------------------------------------------------------
|
|
230
|
+
const loadSlots = useCallback(async (date, personId) => {
|
|
231
|
+
if (!fetchSlots)
|
|
232
|
+
return;
|
|
233
|
+
setLoadingSlots(true);
|
|
234
|
+
setSlots([]);
|
|
235
|
+
try {
|
|
236
|
+
const result = await fetchSlots({ personId, date: formatDate(date) });
|
|
237
|
+
setSlots(result);
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
setSlots([]);
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
setLoadingSlots(false);
|
|
244
|
+
}
|
|
245
|
+
}, [fetchSlots]);
|
|
246
|
+
useEffect(() => {
|
|
247
|
+
if (open && phase === 'datetime') {
|
|
248
|
+
void loadSlots(selectedDate, selectedPersonId);
|
|
249
|
+
}
|
|
250
|
+
}, [open, phase, selectedDate, selectedPersonId, loadSlots]);
|
|
251
|
+
// ------------------------------------------------------------------
|
|
252
|
+
// Handlers
|
|
253
|
+
// ------------------------------------------------------------------
|
|
254
|
+
const handleOpen = () => {
|
|
255
|
+
if (isReadOnly)
|
|
256
|
+
return;
|
|
257
|
+
setPhase(needsPerson ? 'person' : 'datetime');
|
|
258
|
+
setSelectedDate(startOfDay(new Date()));
|
|
259
|
+
setWeekStart(startOfDay(new Date()));
|
|
260
|
+
setSlots([]);
|
|
261
|
+
setOpen(true);
|
|
262
|
+
};
|
|
263
|
+
const handleClose = () => setOpen(false);
|
|
264
|
+
const handleSelectPerson = (person) => {
|
|
265
|
+
setSelectedPersonId(person?.id);
|
|
266
|
+
setSelectedPerson(person);
|
|
267
|
+
setPhase('datetime');
|
|
268
|
+
};
|
|
269
|
+
const handleSkipPerson = () => {
|
|
270
|
+
setSelectedPersonId(undefined);
|
|
271
|
+
setSelectedPerson(undefined);
|
|
272
|
+
setPhase('datetime');
|
|
273
|
+
};
|
|
274
|
+
const handleSelectDate = (date) => {
|
|
275
|
+
setSelectedDate(date);
|
|
276
|
+
};
|
|
277
|
+
const handleSelectSlot = (slot) => {
|
|
278
|
+
const bookingValue = {
|
|
279
|
+
type: 'BOOKING_VALUE',
|
|
280
|
+
slotId: slot.id,
|
|
281
|
+
date: formatDate(selectedDate),
|
|
282
|
+
startTime: slot.startTime,
|
|
283
|
+
endTime: slot.endTime,
|
|
284
|
+
personId: selectedPersonId,
|
|
285
|
+
personName: selectedPerson?.name,
|
|
286
|
+
status: 'PENDING',
|
|
287
|
+
};
|
|
288
|
+
onChange(bookingValue);
|
|
289
|
+
handleClose();
|
|
290
|
+
};
|
|
291
|
+
const handleClear = (e) => {
|
|
292
|
+
e.stopPropagation();
|
|
293
|
+
onChange(null);
|
|
294
|
+
};
|
|
295
|
+
// ------------------------------------------------------------------
|
|
296
|
+
// Display value for the trigger field
|
|
297
|
+
// ------------------------------------------------------------------
|
|
298
|
+
const displayValue = value
|
|
299
|
+
? [
|
|
300
|
+
value.personName,
|
|
301
|
+
formatDisplayDate(new Date(value.date + 'T00:00:00')),
|
|
302
|
+
`${value.startTime}–${value.endTime}`,
|
|
303
|
+
]
|
|
304
|
+
.filter(Boolean)
|
|
305
|
+
.join(' · ')
|
|
306
|
+
: '';
|
|
307
|
+
// ------------------------------------------------------------------
|
|
308
|
+
// Render: Read-only summary
|
|
309
|
+
// ------------------------------------------------------------------
|
|
310
|
+
if (isReadOnly) {
|
|
311
|
+
return (_jsx("div", { className: styles.container, style: { width: widthStyle }, children: value ? (_jsxs(SummaryCard, { children: [_jsx(CalendarIcon, { size: 26, style: { color: theme.palette.primary.main, flexShrink: 0 } }), _jsxs("div", { className: styles.summaryDetails, children: [_jsx("span", { className: styles.summaryLabel, children: step.label }), _jsxs("span", { className: styles.summaryMain, children: [value.personName && (_jsxs("span", { style: { color: theme.palette.primary.main, fontWeight: 600 }, children: [value.personName, " \u00B7", ' '] })), formatDisplayDate(new Date(value.date + 'T00:00:00')), " \u00B7 ", value.startTime, "\u2013", value.endTime] })] })] })) : (_jsxs(EmptyReadOnly, { children: [_jsx(CalendarIcon, { size: 20, style: { flexShrink: 0 } }), _jsx("span", { children: step.label })] })) }));
|
|
312
|
+
}
|
|
313
|
+
// ------------------------------------------------------------------
|
|
314
|
+
// Render: Trigger + Dialog
|
|
315
|
+
// ------------------------------------------------------------------
|
|
316
|
+
return (_jsxs("div", { ref: ref, className: styles.container, style: { width: widthStyle }, children: [_jsx(StyledTextField, { id: triggerId, label: step.label, value: displayValue, variant: "outlined", fullWidth: true, required: step.required, error: !!error, errorBorder: !!error, helperText: error?.message ?? step.description ?? ' ', onClick: handleOpen, sx: { '& input': { cursor: 'pointer', caretColor: 'transparent', userSelect: 'none' } }, slotProps: {
|
|
317
|
+
inputLabel: { shrink: !!value },
|
|
318
|
+
input: {
|
|
319
|
+
readOnly: true,
|
|
320
|
+
notched: !!value,
|
|
321
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", children: value ? (_jsx(ClearBtn, { type: "button", onClick: handleClear, tabIndex: -1, "aria-label": "Limpiar", children: _jsx(CloseIcon, { size: 16 }) })) : (_jsx(CalendarIcon, { size: 20, style: {
|
|
322
|
+
fill: alpha(theme.palette.text.primary, 0.45),
|
|
323
|
+
flexShrink: 0,
|
|
324
|
+
} })) })),
|
|
325
|
+
},
|
|
326
|
+
} }), _jsxs(Dialog, { open: open, onClose: handleClose, maxWidth: "sm", fullWidth: true, slotProps: {
|
|
327
|
+
paper: {
|
|
328
|
+
sx: {
|
|
329
|
+
borderRadius: '20px',
|
|
330
|
+
height: '580px',
|
|
331
|
+
maxHeight: '90vh',
|
|
332
|
+
display: 'flex',
|
|
333
|
+
flexDirection: 'column',
|
|
334
|
+
backgroundColor: theme.palette.background.paper,
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
}, children: [_jsxs(DialogTitle, { sx: {
|
|
338
|
+
padding: '16px 20px 8px',
|
|
339
|
+
borderBottom: `1px solid ${alpha(theme.palette.text.primary, 0.08)}`,
|
|
340
|
+
}, children: [_jsxs("div", { className: styles.dialogTitleInner, children: [phase === 'datetime' && needsPerson && (_jsx(IconBtn, { type: "button", onClick: () => setPhase('person'), "aria-label": "Volver", children: _jsx(ArrowLeftIcon, { size: 20 }) })), _jsx("span", { className: styles.dialogTitleText, children: phase === 'person' ? 'Seleccionar profesional' : 'Seleccionar fecha y hora' }), _jsx(IconBtn, { type: "button", onClick: handleClose, "aria-label": "Cerrar", children: _jsx(CloseIcon, { size: 18 }) })] }), phase === 'datetime' && needsPerson && (_jsxs(PersonChip, { type: "button", onClick: () => setPhase('person'), children: [selectedPerson ? (_jsxs(_Fragment, { children: [_jsx(Avatar, { src: selectedPerson.avatarUrl, sx: { width: 22, height: 22, fontSize: 10 }, children: initials(selectedPerson.name) }), _jsx("span", { children: selectedPerson.name })] })) : (_jsxs(_Fragment, { children: [_jsx(PersonIcon, { size: 16 }), _jsx("span", { children: "Sin preferencia" })] })), _jsx(ArrowRightIcon, { size: 14, style: { opacity: 0.4 } })] }))] }), _jsxs(DialogContent, { sx: { padding: '0 !important', display: 'flex', flexDirection: 'column', flex: 1, overflow: 'hidden', minHeight: 0 }, children: [phase === 'person' && (_jsxs("div", { className: styles.personList, children: [personsOptional && (_jsxs(PersonCard, { active: !selectedPersonId, onClick: handleSkipPerson, role: "button", tabIndex: 0, onKeyDown: (e) => e.key === 'Enter' && handleSkipPerson(), children: [_jsx(Avatar, { sx: {
|
|
341
|
+
width: 48,
|
|
342
|
+
height: 48,
|
|
343
|
+
bgcolor: alpha(theme.palette.text.primary, 0.08),
|
|
344
|
+
color: alpha(theme.palette.text.primary, 0.45),
|
|
345
|
+
}, children: _jsx(PersonIcon, { size: 24 }) }), _jsxs("div", { className: styles.personInfo, children: [_jsx("span", { className: styles.personName, children: "Sin preferencia" }), _jsx("span", { className: styles.personRole, children: "M\u00E1xima disponibilidad" })] }), _jsx(ErkButton, { variant: "outlined", size: "small", children: "Seleccionar" })] })), (step.persons ?? []).map((person) => (_jsxs(PersonCard, { active: selectedPersonId === person.id, onClick: () => handleSelectPerson(person), role: "button", tabIndex: 0, onKeyDown: (e) => e.key === 'Enter' && handleSelectPerson(person), children: [_jsx(Avatar, { src: person.avatarUrl, sx: {
|
|
346
|
+
width: 48,
|
|
347
|
+
height: 48,
|
|
348
|
+
bgcolor: theme.palette.primary.main,
|
|
349
|
+
fontSize: 16,
|
|
350
|
+
}, children: initials(person.name) }), _jsxs("div", { className: styles.personInfo, children: [_jsx("span", { className: styles.personName, children: person.name }), person.role && _jsx("span", { className: styles.personRole, children: person.role }), person.description && (_jsx("span", { className: styles.personDesc, children: person.description }))] }), _jsx(ErkButton, { variant: "outlined", size: "small", children: "Seleccionar" })] }, person.id)))] })), phase === 'datetime' && (_jsxs("div", { className: styles.datetimePhase, children: [_jsx("div", { className: styles.dateSectionTitle, children: "Selecciona una fecha" }), _jsxs("div", { className: styles.dateStrip, children: [_jsx(StripArrowBtn, { type: "button", onClick: () => setWeekStart((d) => {
|
|
351
|
+
const next = addDays(d, -STRIP_DAYS);
|
|
352
|
+
return next < startOfDay(new Date()) ? startOfDay(new Date()) : next;
|
|
353
|
+
}), disabled: weekStart <= startOfDay(new Date()), children: _jsx(ArrowLeftIcon, { size: 20 }) }), _jsx("div", { className: styles.dateChips, children: days.map((day) => {
|
|
354
|
+
const isPast = day < startOfDay(new Date());
|
|
355
|
+
const isSelected = isSameDay(day, selectedDate);
|
|
356
|
+
return (_jsxs(DateChipButton, { type: "button", disabled: isPast, onClick: () => handleSelectDate(day), selected: isSelected, todayHighlight: isToday(day) && !isSelected, children: [_jsx("span", { className: styles.chipDow, children: format(day, 'EEE', { locale: es }) }), _jsx("span", { className: styles.chipNum, children: format(day, 'd') }), _jsx("span", { className: styles.chipMonth, children: format(day, 'MMM', { locale: es }) })] }, day.toISOString()));
|
|
357
|
+
}) }), _jsx(StripArrowBtn, { type: "button", onClick: () => setWeekStart((d) => addDays(d, STRIP_DAYS)), children: _jsx(ArrowRightIcon, { size: 20 }) })] }), _jsx("div", { className: styles.dateSectionTitle, children: "Escoge una hora" }), _jsxs("div", { className: styles.slotList, children: [loadingSlots && (_jsx("div", { className: styles.slotsLoading, children: _jsx(CircularProgress, { size: 24 }) })), !loadingSlots && slots.length === 0 && (_jsx("div", { className: styles.slotsEmpty, children: "No hay horarios disponibles para este d\u00EDa." })), !loadingSlots &&
|
|
358
|
+
slots
|
|
359
|
+
.filter((s) => s.available)
|
|
360
|
+
.map((slot) => (_jsx(SlotRowButton, { type: "button", onClick: () => handleSelectSlot(slot), children: slot.startTime }, slot.id)))] })] }))] })] })] }));
|
|
361
|
+
}
|
|
362
|
+
export default MaterialBookingStep;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
MaterialBookingStep — layout & typography only.
|
|
3
|
+
All colors use MUI theme via styled() in the .tsx file.
|
|
4
|
+
========================================================================= */
|
|
5
|
+
|
|
6
|
+
.container {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
padding: 10px;
|
|
10
|
+
padding-bottom: 0;
|
|
11
|
+
padding-top: 5px;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* =========================================================================
|
|
17
|
+
Read-only summary
|
|
18
|
+
========================================================================= */
|
|
19
|
+
|
|
20
|
+
.summaryDetails {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: 2px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.summaryLabel {
|
|
27
|
+
font-size: 11px;
|
|
28
|
+
text-transform: uppercase;
|
|
29
|
+
letter-spacing: 0.5px;
|
|
30
|
+
opacity: 0.5;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.summaryMain {
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
font-weight: 500;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* =========================================================================
|
|
40
|
+
Dialog header
|
|
41
|
+
========================================================================= */
|
|
42
|
+
|
|
43
|
+
.dialogTitleInner {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: 8px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.dialogTitleText {
|
|
50
|
+
flex: 1;
|
|
51
|
+
font-weight: 600;
|
|
52
|
+
font-size: 17px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* =========================================================================
|
|
56
|
+
Person phase
|
|
57
|
+
========================================================================= */
|
|
58
|
+
|
|
59
|
+
.personList {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
padding: 8px 0;
|
|
63
|
+
flex: 1;
|
|
64
|
+
overflow-y: auto;
|
|
65
|
+
min-height: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.personInfo {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
gap: 2px;
|
|
72
|
+
flex: 1;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.personName {
|
|
77
|
+
font-weight: 600;
|
|
78
|
+
font-size: 14px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.personRole {
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
opacity: 0.55;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.personDesc {
|
|
87
|
+
font-size: 12px;
|
|
88
|
+
opacity: 0.45;
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
text-overflow: ellipsis;
|
|
91
|
+
white-space: nowrap;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* =========================================================================
|
|
95
|
+
Datetime phase
|
|
96
|
+
========================================================================= */
|
|
97
|
+
|
|
98
|
+
.datetimePhase {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
flex: 1;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
min-height: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.dateSectionTitle {
|
|
107
|
+
padding: 14px 20px 8px;
|
|
108
|
+
font-weight: 600;
|
|
109
|
+
font-size: 14px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.dateStrip {
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
padding: 0 8px 8px;
|
|
116
|
+
gap: 4px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.dateChips {
|
|
120
|
+
display: flex;
|
|
121
|
+
flex: 1;
|
|
122
|
+
gap: 4px;
|
|
123
|
+
overflow-x: auto;
|
|
124
|
+
scrollbar-width: none;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.dateChips::-webkit-scrollbar {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.chipDow {
|
|
132
|
+
font-size: 11px;
|
|
133
|
+
text-transform: lowercase;
|
|
134
|
+
opacity: 0.75;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.chipNum {
|
|
138
|
+
font-size: 16px;
|
|
139
|
+
font-weight: 700;
|
|
140
|
+
line-height: 1.1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.chipMonth {
|
|
144
|
+
font-size: 10px;
|
|
145
|
+
opacity: 0.65;
|
|
146
|
+
text-transform: lowercase;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* =========================================================================
|
|
150
|
+
Slot list
|
|
151
|
+
========================================================================= */
|
|
152
|
+
|
|
153
|
+
.slotList {
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
gap: 6px;
|
|
157
|
+
padding: 0 16px 20px;
|
|
158
|
+
flex: 1;
|
|
159
|
+
overflow-y: auto;
|
|
160
|
+
min-height: 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.slotsLoading {
|
|
164
|
+
display: flex;
|
|
165
|
+
justify-content: center;
|
|
166
|
+
padding: 24px 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.slotsEmpty {
|
|
170
|
+
padding: 20px 4px;
|
|
171
|
+
font-size: 13px;
|
|
172
|
+
opacity: 0.5;
|
|
173
|
+
text-align: center;
|
|
174
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CalendarStep } from '../../@Types/CalendarFormStep';
|
|
2
|
+
import { StepProps } from '../Step';
|
|
3
|
+
export interface CalendarStepProps extends StepProps {
|
|
4
|
+
step: CalendarStep;
|
|
5
|
+
}
|
|
6
|
+
declare function CalendarStepComponent(props: CalendarStepProps): JSX.Element;
|
|
7
|
+
export default CalendarStepComponent;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FormStyleTypes } from '../../constants/FormStepTypes';
|
|
3
|
+
import MaterialCalendarStep from './MaterialCalendarStep/MaterialCalendarStep';
|
|
4
|
+
import { useAppSelector } from '../../hooks';
|
|
5
|
+
function CalendarStepComponent(props) {
|
|
6
|
+
const { formStyle } = useAppSelector((state) => state.global);
|
|
7
|
+
switch (formStyle.type) {
|
|
8
|
+
case FormStyleTypes.MATERIAL:
|
|
9
|
+
default: {
|
|
10
|
+
return _jsx(MaterialCalendarStep, { ...props });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default CalendarStepComponent;
|