This commit is contained in:
seb
2026-08-07 03:52:11 +02:00
parent 628980dc49
commit 83ac0efd00
3 changed files with 149 additions and 64 deletions

View File

@@ -682,17 +682,20 @@ export const order = {
/**
* Company-scoped customer groups.
* Shape: CustomerGroup = { id, name }
* Shape: CustomerGroup = { id, name, sort }
* List item: CustomerGroup & { editable } — editable false for POS / Lieferanten
* (name locked). Reorder via PUT /api/customergroup/order.
*/
export const customergroup = {
/** GET /api/customergroup → { customergroups: CustomerGroup[] } */
/** GET /api/customergroup → { customergroups: (CustomerGroup & { editable })[] } ordered by sort */
list() {
return http('/api/customergroup');
},
/**
* POST /api/customergroup
* Body: { name } — empty name ⇒ 400 Name required.
* Body: { name } — empty name ⇒ 400 Name required;
* reserved POS / Lieferanten ⇒ 400 Name not allowed; sort appends next index.
* → 201 { customergroup: CustomerGroup }
*/
create(body) {
@@ -701,13 +704,23 @@ export const customergroup = {
/**
* PATCH /api/customergroup/:id
* Body: { name }
* Body: { name } — locked groups cannot be renamed (Name cannot be changed).
* → 200 { customergroup: CustomerGroup }
*/
update(id, body) {
return http(`/api/customergroup/${id}`, { method: 'PATCH', body });
},
/**
* PUT /api/customergroup/order
* Body: { customergroupIds: number[] } — must be exactly the company set (same ids, no dups)
* else 400 Invalid customer group order. Sets sort to each id’s index 0…n-1.
* → 200 { customergroupIds: number[] }
*/
order(body) {
return http('/api/customergroup/order', { method: 'PUT', body });
},
/** DELETE /api/customergroup/:id → 204 · 409 Customer group in use */
delete(id) {
return http(`/api/customergroup/${id}`, { method: 'DELETE' });