Add Kunde CRUD with addresses/contacts, delivery edit, and Auftrag sub-nav.

Wire customergroup/entity APIs, Lieferungen detail editing, and Angebot/Bestellung/Ausliefern/Retoure placeholders.
This commit is contained in:
seb
2026-08-06 07:38:23 +02:00
parent 1ee29399ff
commit 27fd5d3e94
20 changed files with 2265 additions and 56 deletions

View File

@@ -599,6 +599,132 @@ export const delivery = {
},
};
/**
* Company-scoped customer groups.
* Shape: CustomerGroup = { id, name }
*/
export const customergroup = {
/** GET /api/customergroup → { customergroups: CustomerGroup[] } */
list() {
return http('/api/customergroup');
},
/**
* POST /api/customergroup
* Body: { name } — empty name ⇒ 400 Name required.
* → 201 { customergroup: CustomerGroup }
*/
create(body) {
return http('/api/customergroup', { method: 'POST', body });
},
/**
* PATCH /api/customergroup/:id
* Body: { name }
* → 200 { customergroup: CustomerGroup }
*/
update(id, body) {
return http(`/api/customergroup/${id}`, { method: 'PATCH', body });
},
/** DELETE /api/customergroup/:id → 204 · 409 Customer group in use */
delete(id) {
return http(`/api/customergroup/${id}`, { method: 'DELETE' });
},
};
/**
* Company-scoped entities (customers / contacts in a customergroup).
* Shape: Entity = { id, customergroupId, firstName, name, createdAt, updatedAt }
*/
export const entity = {
/**
* GET /api/entity → { entities: Entity[] }
* Optional query: customergroupId
*/
list({ customergroupId } = {}) {
const qs =
customergroupId != null
? `?customergroupId=${encodeURIComponent(customergroupId)}`
: '';
return http(`/api/entity${qs}`);
},
/** GET /api/entity/:id → { entity: Entity } */
get(id) {
return http(`/api/entity/${id}`);
},
/**
* POST /api/entity
* Body: { customergroupId, name, firstName? }
* → 201 { entity: Entity }
*/
create(body) {
return http('/api/entity', { method: 'POST', body });
},
/**
* PATCH /api/entity/:id
* Body: { name?, firstName? }
* → 200 { entity: Entity }
*/
update(id, body) {
return http(`/api/entity/${id}`, { method: 'PATCH', body });
},
/** DELETE /api/entity/:id → 204 */
delete(id) {
return http(`/api/entity/${id}`, { method: 'DELETE' });
},
/** GET /api/entity/:entityId/address → { addresses: EntityAddress[] } */
listAddresses(entityId) {
return http(`/api/entity/${entityId}/address`);
},
/** POST /api/entity/:entityId/address → 201 { address } */
createAddress(entityId, body) {
return http(`/api/entity/${entityId}/address`, { method: 'POST', body });
},
/** PATCH /api/entity/:entityId/address/:id → { address } */
updateAddress(entityId, id, body) {
return http(`/api/entity/${entityId}/address/${id}`, {
method: 'PATCH',
body,
});
},
/** DELETE /api/entity/:entityId/address/:id → 204 */
deleteAddress(entityId, id) {
return http(`/api/entity/${entityId}/address/${id}`, { method: 'DELETE' });
},
/** GET /api/entity/:entityId/contact → { contacts: EntityContact[] } */
listContacts(entityId) {
return http(`/api/entity/${entityId}/contact`);
},
/** POST /api/entity/:entityId/contact → 201 { contact } */
createContact(entityId, body) {
return http(`/api/entity/${entityId}/contact`, { method: 'POST', body });
},
/** PATCH /api/entity/:entityId/contact/:id → { contact } */
updateContact(entityId, id, body) {
return http(`/api/entity/${entityId}/contact/${id}`, {
method: 'PATCH',
body,
});
},
/** DELETE /api/entity/:entityId/contact/:id → 204 */
deleteContact(entityId, id) {
return http(`/api/entity/${entityId}/contact/${id}`, { method: 'DELETE' });
},
};
export const company = {
/** GET /api/company → { companies: [...] } */
list() {
@@ -774,9 +900,11 @@ export default {
brand,
category,
company,
customergroup,
delivery,
entity,
posterminal,
supplier,
delivery,
thumb,
unit,
};