'use client';
import { StrictMode } from 'react';
import { Fade, Stack, Avatar, Typography } from '@mui/material';
import Dialog, { DialogInline } from './components/dialog/Dialog';
import FormScreen from './components/FormScreen';
import ErrorScreen from './components/ErrorScreen';
import ErrorBoundary from './components/ErrorBoundary';
import LoadingScreen from './components/LoadingScreen';
import ConfirmationScreen from './components/ConfirmationScreen';
import { TimezoneStateProvider } from './components/timezone-select/TimezoneProvider';
import { usePublicRouting } from './api/routing';
import { ConfigurationProvider } from './config';
import { useWidgetState, WidgetStateContext } from './state';
interface BookingProps {
routingId: string;
productId?: string;
}
export interface BookingWidgetProps extends BookingProps {
open: boolean;
onClose: () => void;
}
function BookingWidget({ open, onClose, routingId, productId }: BookingWidgetProps) {
const widgetState = useWidgetState();
const [state] = widgetState;
const { data, isLoading, error } = usePublicRouting(routingId);
if (isLoading) {
return (
);
}
if (!data || error || state.state === 'error') {
const message =
state.state === 'error' ? state.error : error?.response?.message || error?.message;
return (
);
}
if (state.state === 'confirm') {
return (
);
}
return (
);
}
function BookingInline({ routingId, productId }: BookingProps) {
const widgetState = useWidgetState();
const [state] = widgetState;
const { data, isLoading, error } = usePublicRouting(routingId);
if (isLoading) {
return (
);
}
if (!data || error || state.state === 'error') {
const message =
state.state === 'error' ? state.error : error?.response?.message || error?.message;
return (
);
}
if (state.state === 'confirm') {
return (
);
}
return (
{data.account.name}
),
}}
>
);
}
function Main(props: BookingWidgetProps) {
return (
);
}
export function MainInline(props: BookingProps) {
return (
);
}
export default Main;