Improve config form UI and add mapping row save endpoint.

Refactor status counts and config pages for the updated PrestaShop integration workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
fatequod
2026-07-15 09:19:53 +02:00
co-authored by Cursor
parent 1a6a978a21
commit 139ac5cb52
4 changed files with 257 additions and 139 deletions
+3 -35
View File
@@ -1,38 +1,6 @@
const { getOrderStatuses, searchOrders } = require('../../src/orders-api');
const cache = new Map();
const CACHE_TTL = 5000;
const CACHE_KEY = 'default';
const { Core } = require('@orbito/api-lib');
// Proxy do core/orders — statusy są współdzielone i zarządzane w core/orders.
module.exports = async function(params, ctx) {
const now = Date.now();
const cached = cache.get(CACHE_KEY);
if (cached && now - cached.ts < CACHE_TTL) {
return { data: cached.data };
}
const statuses = await getOrderStatuses();
const data = [];
for (const status of statuses) {
const statusId = status._id?.toString?.() ?? status._id;
const result = await searchOrders({
statusId,
page: 1,
perPage: 1
});
data.push({
_id: statusId,
name: status.name ?? '',
color: status.color ?? 'secondary',
positionInGroup: status.positionInGroup ?? 0,
count: result.pagination?.total ?? 0
});
}
data.sort((a, b) => (a.positionInGroup ?? 0) - (b.positionInGroup ?? 0));
cache.set(CACHE_KEY, { ts: now, data });
return { data };
return Core.callModule('core/orders', 'status.get_with_counts', params || {});
};