[dyad] Fixed issue with adding new items to purchase orders - wrote 1 file(s)

This commit is contained in:
[dyad] 2025-09-12 14:44:02 +02:00
parent 0dc7ffb925
commit c11b83f44e

View file

@ -126,14 +126,14 @@ export function PurchaseOrderForm({ setOpen, refreshData }: PurchaseOrderFormPro
// Function to add a new item row
const addItem = () => {
form.control.register("items", { shouldUnregister: true }) // Ensure registration
form.setValue("items", [...form.getValues("items"), {
const currentItems = form.getValues("items");
form.setValue("items", [...currentItems, {
stockItemId: "",
itemName: "",
quantity: 1,
sku: "",
costPrice: 0,
}])
}]);
}
// Function to remove an item row