dashboard

This commit is contained in:
Lucas Tettamanti
2026-01-27 02:41:39 -03:00
parent 493f26af17
commit df9420b954
19 changed files with 2105 additions and 111 deletions

View File

@@ -1,19 +1,32 @@
import {
handleListRecentOrders,
handleListOrders,
handleGetProductsWithStock,
handleCreateTestOrder,
handleCreatePaymentLink,
handleSimulateMpWebhook,
} from "../handlers/testing.js";
import { handleGetOrderStats } from "../handlers/stats.js";
export const makeListRecentOrders = (tenantIdOrFn) => async (req, res) => {
export const makeListOrders = (tenantIdOrFn) => async (req, res) => {
try {
const tenantId = typeof tenantIdOrFn === "function" ? tenantIdOrFn() : tenantIdOrFn;
const limit = parseInt(req.query.limit) || 20;
const result = await handleListRecentOrders({ tenantId, limit });
const page = parseInt(req.query.page) || 1;
const limit = parseInt(req.query.limit) || 50;
const result = await handleListOrders({ tenantId, page, limit });
res.json(result);
} catch (err) {
console.error("[testing] listRecentOrders error:", err);
console.error("[testing] listOrders error:", err);
res.status(500).json({ ok: false, error: err.message || "internal_error" });
}
};
export const makeGetOrderStats = (tenantIdOrFn) => async (req, res) => {
try {
const tenantId = typeof tenantIdOrFn === "function" ? tenantIdOrFn() : tenantIdOrFn;
const result = await handleGetOrderStats({ tenantId });
res.json(result);
} catch (err) {
console.error("[stats] getOrderStats error:", err);
res.status(500).json({ ok: false, error: err.message || "internal_error" });
}
};