disable submit button if no customer selected
This commit is contained in:
parent
cf5ceae115
commit
3a649e5825
@ -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}
|
||||
/>
|
||||
|
||||
@ -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>
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user