Disabled-Create-Customer-Button-Until-Name-Id-Or-Email-isfilled-to-Prevent-API-CALL

This commit is contained in:
shreyash1231
2025-09-16 16:41:45 +05:30
parent e7f6dffe34
commit d13505621c

View File

@@ -75,14 +75,18 @@ function CreateCustomer() {
</DialogHeader>
<div className="flex gap-2">
<div>
<FieldLabel>Name</FieldLabel>
<FieldLabel>
Name
</FieldLabel>
<Input
value={fields.name}
onChange={(e) => setFields({ ...fields, name: e.target.value })}
/>
</div>
<div>
<FieldLabel>ID</FieldLabel>
<FieldLabel>
ID
</FieldLabel>
<Input
value={fields.id}
onChange={(e) => setFields({ ...fields, id: e.target.value })}
@@ -107,12 +111,11 @@ function CreateCustomer() {
/>
</div> */}
<DialogFooter>
<Button
onClick={handleCreate}
<Button onClick={handleCreate}
isLoading={isLoading}
variant="gradientPrimary"
>
Create
disabled={ !fields.name.trim() || (!fields.id.trim() && !fields.email.trim()) }
> Create
</Button>
</DialogFooter>
</DialogContent>