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,7 +1,6 @@
'use client';
import { useState, useTransition } from 'react';
import { useRouter } from 'next/navigation';
type PendingProduct = {
id: number;
@@ -17,7 +16,6 @@ export default function PendingProductsClient({ products: initial }: { products:
const [isPending, startTransition] = useTransition();
const [error, setError] = useState<string | null>(null);
const [processing, setProcessing] = useState<number | null>(null);
const router = useRouter();
function handleAction(id: number, status: 'active' | 'rejected') {
setError(null);
@@ -34,7 +32,6 @@ export default function PendingProductsClient({ products: initial }: { products:
throw new Error(data?.error || 'Fel vid uppdatering');
}
setProducts((prev) => prev.filter((p) => p.id !== id));
router.refresh();
} catch (err) {
setError(err instanceof Error ? err.message : 'Fel vid uppdatering');
} finally {