Improve look and performance of orders table
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user