import * as React from 'react'; import { __ } from '@wordpress/i18n'; import type { BookingApi } from './api'; import type { Booking } from './types'; import { BookingDetails } from './Bookings'; import { CalendarPanel } from './Calendar'; export function CalendarBookingPanel({ id, api, onClose, onChanged, onEdit }: { id: number; api: BookingApi; onClose: () => void; onChanged: () => void; onEdit?: (b: Booking) => void; }) { const [booking, setBooking] = React.useState(null), [error, setError] = React.useState(''); React.useEffect(() => { let alive = true; setBooking(null); setError(''); api.request(`bookings/${id}`).then(b => { if (alive) setBooking(b); }).catch(e => { if (alive) setError(e.message); }); return () => { alive = false; }; }, [api, id]); return {error &&

{error}

}{!booking && !error &&

{__('Loading…', 'abece-booking')}

}{booking && { setBooking(b); onChanged(); }}/>}
; }