feat(products): update event handling for product list refresh on creation and reset actions

This commit is contained in:
Nils-Johan Gynther
2026-04-19 19:25:02 +02:00
parent a7680b40af
commit 6e297403d6
4 changed files with 7 additions and 10 deletions
@@ -1,12 +1,10 @@
'use client';
import { useState } from 'react';
import { useRouter } from 'next/navigation';
export default function ResetProductsButton() {
const [isPending, setIsPending] = useState(false);
const [error, setError] = useState<string | null>(null);
const router = useRouter();
async function handleClick() {
if (
@@ -24,7 +22,7 @@ export default function ResetProductsButton() {
const data = await res.json().catch(() => ({}));
throw new Error(data?.error || 'Återställning misslyckades');
}
router.refresh();
window.dispatchEvent(new CustomEvent('product-list-changed'));
} catch (err) {
setError(err instanceof Error ? err.message : 'Okänt fel');
} finally {