File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ export default function AddProductDialog({
9898 setSelectedCategory ( selectedProduct . categoryId || "" ) ;
9999 setSelectedSupplier ( selectedProduct . supplierId || "" ) ;
100100 } else {
101+ // Reset form to default values for adding a new product
101102 reset ( {
102103 productName : "" ,
103104 sku : "" ,
@@ -192,8 +193,19 @@ export default function AddProductDialog({
192193 }
193194 } ;
194195
196+ const handleOpenChange = ( open : boolean ) => {
197+ if ( open ) {
198+ // When opening the dialog for adding a new product, clear any selected product
199+ setSelectedProduct ( null ) ;
200+ } else {
201+ // When closing the dialog, also clear the selected product to ensure clean state
202+ setSelectedProduct ( null ) ;
203+ }
204+ setOpenProductDialog ( open ) ;
205+ } ;
206+
195207 return (
196- < Dialog open = { openProductDialog } onOpenChange = { setOpenProductDialog } >
208+ < Dialog open = { openProductDialog } onOpenChange = { handleOpenChange } >
197209 < DialogTrigger asChild >
198210 < Button className = "h-10 font-semibold" > +Add Product</ Button >
199211 </ DialogTrigger >
@@ -271,8 +283,8 @@ export default function AddProductDialog({
271283 { isSubmitting
272284 ? "Loading..."
273285 : selectedProduct
274- ? "Update Product"
275- : "Add Product" }
286+ ? "Update Product"
287+ : "Add Product" }
276288 </ Button >
277289 </ DialogFooter >
278290 </ form >
Original file line number Diff line number Diff line change @@ -240,9 +240,6 @@ export default function BusinessInsightsPage() {
240240 quantity : Number ( product . quantity ) ,
241241 } ) ) ;
242242
243- // Debug logging for topProducts
244- console . log ( "Top Products by Value:" , topProducts ) ;
245-
246243 // Low stock products (matching product table logic: quantity > 0 AND quantity <= 20)
247244 const lowStockProducts = allProducts
248245 . filter (
You can’t perform that action at this time.
0 commit comments