38 lines
906 B
TypeScript
38 lines
906 B
TypeScript
'use client';
|
|
import {
|
|
BackButton,
|
|
ClientsGrid,
|
|
DateTimeSelect,
|
|
MastersGrid,
|
|
ServiceSelect,
|
|
SubmitButton,
|
|
} from './components';
|
|
import { OrderContext, OrderContextProvider } from '@/context/order';
|
|
import { withContext } from '@/utils/context';
|
|
import { type JSX, use } from 'react';
|
|
|
|
const STEP_COMPONENTS: Record<string, JSX.Element> = {
|
|
'client-select': <ClientsGrid />,
|
|
'datetime-select': <DateTimeSelect />,
|
|
'master-select': <MastersGrid />,
|
|
'service-select': <ServiceSelect />,
|
|
};
|
|
|
|
function getStepComponent(step: string) {
|
|
return STEP_COMPONENTS[step] ?? null;
|
|
}
|
|
|
|
export const OrderForm = withContext(OrderContextProvider)(function () {
|
|
const { step } = use(OrderContext);
|
|
|
|
return (
|
|
<div className="space-y-4 [&>*]:px-4">
|
|
{getStepComponent(step)}
|
|
<div className="space-y-2">
|
|
<SubmitButton />
|
|
<BackButton />
|
|
</div>
|
|
</div>
|
|
);
|
|
});
|