2025-03-13 13:47:44 +03:00

29 lines
755 B
TypeScript

'use client';
import { OrderContext } from '@/context/order';
import { Button } from '@repo/ui/components/ui/button';
import { use } from 'react';
export function SubmitButton() {
const { nextStep, step } = use(OrderContext);
function handleOnClick() {
if (step !== 'success') {
nextStep();
}
}
const disabled = useButtonDisabled();
return (
<Button className="w-full" disabled={disabled} onClick={() => handleOnClick()} type="button">
{step === 'success' ? 'Создать' : 'Продолжить'}
</Button>
);
}
function useButtonDisabled() {
const { customerId, serviceId, step } = use(OrderContext);
return (step === 'customer-select' && !customerId) || (step === 'service-select' && !serviceId);
}