feat(products): add reset functionality to delete all products and related data

This commit is contained in:
Nils-Johan Gynther
2026-04-17 21:22:54 +02:00
parent befa15609a
commit e41ee760b9
5 changed files with 93 additions and 0 deletions
+15
View File
@@ -73,3 +73,18 @@ export async function deleteProduct(id: number) {
revalidatePath('/admin/products');
}
export async function resetAllProducts() {
const res = await fetch(`${API_BASE}/api/products/reset-all`, {
method: 'DELETE',
headers: { ...(await getAuthHeaders()) },
cache: 'no-store',
});
if (!res.ok) {
const text = await res.text();
throw new Error(`Kunde inte återställa produkter: ${text}`);
}
revalidatePath('/admin/products');
}