This commit is contained in:
seb
2026-08-02 18:54:25 +02:00
parent 780f946eff
commit b787549a85
5 changed files with 346 additions and 16 deletions

View File

@@ -235,6 +235,32 @@ export const article = {
body: { prices },
});
},
/**
* PUT /api/article/:sku/brand
* Body: { brandId: number | null } — null clears the brand.
* brandId must belong to the article's company → 404 Article or brand not found.
* → 200 { article } (same shape as GET by SKU)
*/
setBrandIdBySku(sku, brandId) {
return http(`/api/article/${encodeURIComponent(sku)}/brand`, {
method: 'PUT',
body: { brandId },
});
},
/**
* PUT /api/article/:sku/eans
* Body: { eans: string[] } — replace-all. Empty array clears all.
* EANs must be non-empty unique strings → 400 Invalid eans.
* → 200 { article } (same shape as GET by SKU)
*/
setEansBySku(sku, eans) {
return http(`/api/article/${encodeURIComponent(sku)}/eans`, {
method: 'PUT',
body: { eans },
});
},
};
/**
@@ -308,6 +334,27 @@ export const category = {
},
};
/**
* Company-scoped brands (selectedCompanyId from session).
* Shape: Brand = { id, name, gsprpinfo | null }
*/
export const brand = {
/** GET /api/brand → { brands: Brand[] } · 400 No company selected */
list() {
return http('/api/brand');
},
/**
* PUT /api/brand
* Body: { name, gsprpinfo? } — upsert by name for the selected company.
* Same name ⇒ update, otherwise create. Empty name ⇒ 400 Invalid brand.
* → 200 { brand: Brand }
*/
upsert(body) {
return http('/api/brand', { method: 'PUT', body });
},
};
export const company = {
async list() {
try {
@@ -402,4 +449,4 @@ export const auth = {
},
};
export default { auth, article, category, company, thumb, unit };
export default { auth, article, brand, category, company, thumb, unit };