feat(products): name is also editable
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7b498a91f8
commit
2c364f95e5
2 changed files with 5 additions and 4 deletions
|
|
@ -46,9 +46,11 @@ export async function updateProduct(formData: FormData): Promise<ActionResult> {
|
||||||
|
|
||||||
const parsed = z.object({
|
const parsed = z.object({
|
||||||
code: z.string().min(1).max(50),
|
code: z.string().min(1).max(50),
|
||||||
|
name: z.string().min(1).max(200),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
}).safeParse({
|
}).safeParse({
|
||||||
code: formData.get("code"),
|
code: formData.get("code"),
|
||||||
|
name: formData.get("name"),
|
||||||
description: formData.get("description") || undefined,
|
description: formData.get("description") || undefined,
|
||||||
});
|
});
|
||||||
if (!parsed.success) return { error: parsed.error.errors[0].message };
|
if (!parsed.success) return { error: parsed.error.errors[0].message };
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,9 @@ function ProductFormFields({ product }: { product?: ProductRow }) {
|
||||||
placeholder="e.g. FUEL-OIL-001" />
|
placeholder="e.g. FUEL-OIL-001" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-neutral-700 mb-1">Name</label>
|
<label className="block text-xs font-medium text-neutral-700 mb-1">Name *</label>
|
||||||
<input name="name" defaultValue={product?.name} required disabled={!!product}
|
<input name="name" defaultValue={product?.name} required
|
||||||
className="w-full rounded-lg border border-neutral-300 px-3 py-2 text-sm focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 disabled:bg-neutral-50 disabled:text-neutral-400" />
|
className="w-full rounded-lg border border-neutral-300 px-3 py-2 text-sm focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20" />
|
||||||
{product && <p className="mt-1 text-xs text-neutral-400">Name is locked after creation.</p>}
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-xs font-medium text-neutral-700 mb-1">Description</label>
|
<label className="block text-xs font-medium text-neutral-700 mb-1">Description</label>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue