disable submit button if no customer selected

This commit is contained in:
vchikalkin 2025-03-12 17:18:06 +03:00
parent cf5ceae115
commit 3a649e5825
2 changed files with 10 additions and 8 deletions

View File

@ -17,22 +17,22 @@ export function ContactsGrid() {
if (isLoading) return <LoadingSpinner />;
function handleOnSelect(contactId: string) {
setSelected(contactId);
}
return (
<div className="grid grid-cols-4 gap-4">
{contacts.map((contact) => {
if (!contact) return null;
return (
<Label
className="flex cursor-pointer flex-col items-center"
key={contact?.documentId}
onClick={() => setSelected(contact?.documentId)}
>
<Label className="flex cursor-pointer flex-col items-center" key={contact?.documentId}>
<input
checked={selected === contact?.documentId}
className="hidden"
name="user"
onChange={() => setSelected(contact?.documentId)}
onChange={() => handleOnSelect(contact?.documentId)}
type="radio"
value={contact?.documentId}
/>

View File

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