feat(api): implement bulk categorization and suggestion endpoints with authentication
refactor(actions): remove unused imports and console logs from product actions refactor(EditProductForm): update category suggestion logic to use new API endpoint
This commit is contained in:
@@ -33,8 +33,6 @@ export async function PATCH(
|
||||
return Response.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
console.log('[api/admin/product] PATCH product', productId);
|
||||
|
||||
// 1. Update product fields
|
||||
const patchRes = await fetch(`${API_BASE}/api/products/${productId}`, {
|
||||
method: 'PATCH',
|
||||
@@ -55,8 +53,6 @@ export async function PATCH(
|
||||
return Response.json({ error: `Kunde inte uppdatera produkt: ${text}` }, { status: patchRes.status });
|
||||
}
|
||||
|
||||
console.log('[api/admin/product] PATCH OK');
|
||||
|
||||
// 2. Update tags
|
||||
const tagsRes = await fetch(`${API_BASE}/api/products/${productId}/tags`, {
|
||||
method: 'PUT',
|
||||
@@ -70,8 +66,6 @@ export async function PATCH(
|
||||
return Response.json({ error: `Kunde inte uppdatera taggar: ${text}` }, { status: tagsRes.status });
|
||||
}
|
||||
|
||||
console.log('[api/admin/product] tags PUT OK');
|
||||
|
||||
// 3. Return the complete updated product
|
||||
const fullRes = await fetch(`${API_BASE}/api/products/${productId}`, {
|
||||
headers: authHeaders,
|
||||
@@ -82,7 +76,6 @@ export async function PATCH(
|
||||
}
|
||||
|
||||
const product = await fullRes.json();
|
||||
console.log('[api/admin/product] returning full product id:', product?.id);
|
||||
return Response.json(product);
|
||||
} catch (err) {
|
||||
console.error('[api/admin/product] PATCH error:', err);
|
||||
@@ -108,8 +101,6 @@ export async function DELETE(
|
||||
return Response.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
console.log('[api/admin/product] DELETE product', productId);
|
||||
|
||||
const res = await fetch(`${API_BASE}/api/products/${productId}`, {
|
||||
method: 'DELETE',
|
||||
headers: authHeaders,
|
||||
@@ -121,7 +112,6 @@ export async function DELETE(
|
||||
return Response.json({ error: `Kunde inte ta bort produkt: ${text}` }, { status: res.status });
|
||||
}
|
||||
|
||||
console.log('[api/admin/product] DELETE OK');
|
||||
return new Response(null, { status: 204 });
|
||||
} catch (err) {
|
||||
console.error('[api/admin/product] DELETE error:', err);
|
||||
|
||||
Reference in New Issue
Block a user