import { __ } from '@wordpress/i18n' import { minutesToText } from '../../../../admin/components/WebbaDataTable/utils' import { Webba5ActionButton } from './Webba5ActionButton' import { Webba5BackButton } from './Webba5BackButton' import { StaffSelector } from '../../../components/StaffSelector/StaffSelector' import { useWording } from '../../../hooks/useWording' import { WaterfallAvailabilityCalendar } from '../WaterfallForm/WaterfallAvailabilityCalendar' import { WaterfallUnitAvailabilityCalendar } from '../WaterfallForm/WaterfallUnitAvailabilityCalendar' import { IServiceProps, IUnitProps } from '../../../components/Services/types' import { useWebba5Booking } from './useWebba5Booking' type BookingState = ReturnType export const Webba5ScheduleStep = ({ booking }: { booking: BookingState }) => { const wording = useWording() const durationLabel = booking.selectedService?.duration ? minutesToText(Number(booking.selectedService.duration), { h: wording.hour, min: wording.minute, d: wording.day || 'd', }) : '' const summary = [booking.selectedItem?.label, durationLabel] .filter(Boolean) .join(' ยท ') const minQuantity = Math.max(1, Number(booking.selectedService?.min_quantity) || 1) const maxQuantity = Math.max( minQuantity, Number(booking.selectedService?.max_quantity) || 1 ) const quantity = Math.min( maxQuantity, Math.max(minQuantity, Number(booking.selectedService?.quantity) || minQuantity) ) return (

{__('Make it fit your day', 'webba-booking-lite')}

{booking.bookingMode === 'units' ? __('Pick your dates.', 'webba-booking-lite') : __('Pick a date & time.', 'webba-booking-lite')}

{summary &&

{summary}

} {booking.skipServiceStep && booking.showStaffDropdown && booking.selectedService && (
{__('Preferred team member', 'webba-booking-lite')} { if (staffId != null) { booking.handleStaffChange(String(staffId)) } }} />
)} {booking.skipServiceStep && booking.selectedService && maxQuantity > minQuantity && ( )} {booking.bookingMode === 'services' && booking.selectedService && ( )} {booking.bookingMode === 'units' && booking.selectedUnit && ( )}
{!booking.skipServiceStep && ( booking.openStep('service')} /> )} booking.openStep('details')} />
) }