feat(products): update event handling for product list refresh on creation and reset actions
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user