feat(products): add reset functionality to delete all products and related data
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user