feat(product): trigger product list refresh on product creation event

This commit is contained in:
Nils-Johan Gynther
2026-04-19 19:22:46 +02:00
parent 829b7a80fc
commit a7680b40af
2 changed files with 7 additions and 3 deletions
+1 -3
View File
@@ -1,12 +1,10 @@
'use client';
import { useState } from 'react';
import { useRouter } from 'next/navigation';
export default function ProductForm() {
const [isPending, setIsPending] = useState(false);
const [error, setError] = useState<string | null>(null);
const router = useRouter();
return (
<form
@@ -29,7 +27,7 @@ export default function ProductForm() {
throw new Error(data?.error || 'Kunde inte skapa produkt');
}
form.reset();
router.refresh();
window.dispatchEvent(new CustomEvent('product-created'));
} catch (err) {
setError(err instanceof Error ? err.message : 'Okänt fel');
} finally {