Improve look and performance of orders table

This commit is contained in:
Dominic Ferrando
2026-07-17 15:33:17 -04:00
parent 1673bc5498
commit fdbfbb125d
3 changed files with 147 additions and 67 deletions
+26
View File
@@ -237,6 +237,32 @@ export const app = new Elysia()
})
)
.group("/orders", (app) => app
.get("/", async ({ query }) => {
const wOrders = await s.Commerce.Webflow.Orders.list({
status: query.status,
limit: query.limit,
offset: query.offset,
});
const isSyncedFlags = await Promise.all(
wOrders.map(async (wOrder) =>
(await s.Commerce.Printful.Orders.get(`@${wOrder.orderId}`)) !== undefined
)
);
return wOrders.map((wOrder, i) => ({ wOrder, isSynced: isSyncedFlags[i] }));
}, {
query: t.Object({
status: t.Optional(t.Union([
t.Literal("pending"),
t.Literal("unfulfilled"),
t.Literal("fulfilled"),
t.Literal("disputed"),
t.Literal("dispute-lost"),
t.Literal("refunded"),
])),
limit: t.Optional(t.Numeric()),
offset: t.Optional(t.Numeric()),
})
})
.get("/:wOrderId", async ({ params: { wOrderId } }) => {
const wOrder = await s.Commerce.Webflow.Orders.get(wOrderId);
if (!wOrder) throw new NotFoundError("Missing webflow order");