Show article history in a table via GET /article/{sku}/history.

This commit is contained in:
seb
2026-08-05 09:35:47 +02:00
parent debd246012
commit 60e6858fd5
10 changed files with 297 additions and 96 deletions

View File

@@ -106,8 +106,21 @@ export class ApiClient {
exportZip: (query = {}) => this.#blob('GET', '/api/article/export.zip', { query }),
/** GET /api/article/{sku} */
get: (sku) => this.#json('GET', `/api/article/${enc(sku)}`),
/** PATCH /api/article/{sku} */
update: (sku, body) => this.#json('PATCH', `/api/article/${enc(sku)}`, { body }),
/** GET /api/article/{sku}/history → { history: [{ id, date, text }, ...] } */
history: (sku) => this.#json('GET', `/api/article/${enc(sku)}/history`),
/** PATCH /api/article/{sku} — body: at least one of { name, unitamount, unitSi } */
update: async (sku, body) => {
const nameChange = body != null && Object.hasOwn(body, 'name');
if (nameChange) {
this.setArticleIndexName(sku, body.name);
}
try {
return await this.#json('PATCH', `/api/article/${enc(sku)}`, { body });
} catch (err) {
if (nameChange) this.clearArticleIndex();
throw err;
}
},
/** DELETE /api/article/{sku} */
delete: (sku) => this.#empty('DELETE', `/api/article/${enc(sku)}`),
/** PUT /api/article/{sku}/prices */