feat(api): add create and update product routes with authentication
refactor(admin): integrate router refresh after product updates in forms fix(imports): update fetch paths for product creation and update in ReceiptImportClient
This commit is contained in:
@@ -196,7 +196,7 @@ export default function ReceiptImportClient({ isAdmin }: { isAdmin: boolean }) {
|
||||
console.log('handleCreateProduct: isAdmin =', isAdmin, 'endpoint = /api/products-create');
|
||||
try {
|
||||
// Admin skapar aktiv produkt via API route
|
||||
const res = await fetch('/api/products-create', {
|
||||
const res = await fetch('/api/admin/create-product', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name: row.rawName }),
|
||||
@@ -212,7 +212,7 @@ export default function ReceiptImportClient({ isAdmin }: { isAdmin: boolean }) {
|
||||
// Sätt kategori: AI-förslag har prioritet, annars manuellt val
|
||||
const categoryId = row.categorySuggestion?.categoryId ?? (row.selectedCategoryId !== '' ? row.selectedCategoryId : null);
|
||||
if (categoryId) {
|
||||
const patchRes = await fetch(`/api/products-update/${product.id}`, {
|
||||
const patchRes = await fetch(`/api/admin/update-product/${product.id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ categoryId }),
|
||||
|
||||
Reference in New Issue
Block a user