This commit is contained in:
seb
2026-10-08 04:45:35 +02:00
parent b01ebccf90
commit ec238c7b50
5 changed files with 200 additions and 43 deletions

View File

@@ -161,6 +161,22 @@ const server = http.createServer(async (req, res) => {
article: { ...catalog.articleDetail, sku, name: catalog.articleDetail.name },
});
}
const catArticle = Object.values(catalog.articlesByCategory ?? {}).flat().find((a) => a.sku === sku);
if (catArticle) {
return json(res, 200, {
article: {
id: catArticle.id,
sku: catArticle.sku,
name: catArticle.name,
unitamount: 1,
unit: { si: 'stk', name: 'Stück' },
prices: [{ minmultiplier: 1, net: 10, taxRate: 19, customergroupId: 1 }],
categoryIds: [],
photos: catArticle.fullHash ? [{ fullHash: catArticle.fullHash, thumbHash: catArticle.thumbHash }] : [],
children: [],
},
});
}
return json(res, 404, { error: 'Article not found' });
}
if (p === '/api/article/history') return json(res, 200, { history: misc.articleHistoryGrid ?? [] });
@@ -419,12 +435,27 @@ const server = http.createServer(async (req, res) => {
if (p.match(/^\/api\/company\/setting\/.+$/) && method === 'PUT') {
return json(res, 200, { setting: { key: decodeURIComponent(p.split('/').pop()), ...(body ?? {}) } });
}
if (p === '/api/company/import' && method === 'POST') {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
});
res.write('event: status\ndata: {"message": "Import gestartet. Daten werden verarbeitet..."}\n\n');
res.write('event: progress\ndata: {"phase": "categories", "current": 1, "total": 1, "item": "Katalog"}\n\n');
res.write('event: done\ndata: {"ok": true, "message": "Import erfolgreich abgeschlossen.", "stats": {"categories": 1, "categoriesCreated": 1, "categoryPictures": 0, "articlesTotal": 1, "articlesImported": 1, "articlesUpdated": 0, "variantsLinked": 0, "articlePictures": 1}}\n\n');
res.end();
return;
}
if (p.match(/^\/api\/number\/\d+$/) && method === 'PATCH') {
return json(res, 200, { number: { id: Number(p.split('/').pop()), ...(body ?? {}) } });
}
if (p === '/api/posterminal' && method === 'PUT') {
return json(res, 200, { posterminal: { id: 999001, ...(body ?? {}) } });
}
if (p.match(/^\/api\/posterminal\/\d+$/) && method === 'PATCH') {
return json(res, 200, { posterminal: { id: Number(p.split('/').pop()), ...(body ?? {}) } });
}
if (p.match(/^\/api\/posterminal\/\d+\/(all|category\/\d+)$/) && ['PUT', 'DELETE'].includes(method)) {
return json(res, 200, { id: Number(p.split('/')[3]), categoryIds: [] });
}