feat: paginate customer orders and polish the dashboard hero
Add paged orders API and infinite scroll, short order numbers, and align the guest invite card with the logged-in hero shell. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
-- App (B2B) orders were stored as RETAIL because createOrder defaulted
|
||||
-- channel to RETAIL and the apps never sent one. Legacy's mobile setOrder
|
||||
-- wrote to the wholesale `orders` table.
|
||||
--
|
||||
-- Flip mis-filed rows: any RETAIL order whose customer is NOT a تک
|
||||
-- (CustomerKind.RETAIL) belongs on the omde list. Genuine retail-list
|
||||
-- orders for CustomerKind.RETAIL stay RETAIL.
|
||||
|
||||
UPDATE "Order" AS o
|
||||
SET channel = 'WHOLESALE'
|
||||
FROM "Customer" AS c
|
||||
WHERE o."customerId" = c.id
|
||||
AND o.channel = 'RETAIL'
|
||||
AND c.kind <> 'RETAIL';
|
||||
@@ -0,0 +1,31 @@
|
||||
-- Short global customer-facing order numbers (SMS / app), replacing
|
||||
-- ORD-{timestamp}-{random}. Pure digits, starting at 100.
|
||||
-- Existing ORD-* / MOCK-ORD-* rows stay as-is; the sequence only advances
|
||||
-- past any already-numeric orderNumber so new allocations never collide.
|
||||
|
||||
DROP SEQUENCE IF EXISTS order_number_seq;
|
||||
|
||||
CREATE SEQUENCE order_number_seq
|
||||
AS BIGINT
|
||||
INCREMENT BY 1
|
||||
MINVALUE 1
|
||||
START WITH 100
|
||||
NO CYCLE;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
max_numeric bigint;
|
||||
BEGIN
|
||||
SELECT MAX("orderNumber"::bigint)
|
||||
INTO max_numeric
|
||||
FROM "Order"
|
||||
WHERE "orderNumber" ~ '^[0-9]+$';
|
||||
|
||||
IF max_numeric IS NULL THEN
|
||||
-- next nextval() returns 100
|
||||
PERFORM setval('order_number_seq', 100, false);
|
||||
ELSE
|
||||
-- next nextval() returns max_numeric + 1
|
||||
PERFORM setval('order_number_seq', max_numeric, true);
|
||||
END IF;
|
||||
END $$;
|
||||
@@ -389,8 +389,8 @@ async function main() {
|
||||
await prisma.brand.updateMany({ where: { id: 'brand-henza' }, data: { id: 'brand-montzar' } });
|
||||
const brandMain = await prisma.brand.upsert({
|
||||
where: { id: 'brand-montzar' },
|
||||
update: { title: 'زرتاج طلا' },
|
||||
create: { id: 'brand-montzar', title: 'زرتاج طلا' },
|
||||
update: { title: 'تهران تاج طلا' },
|
||||
create: { id: 'brand-montzar', title: 'تهران تاج طلا' },
|
||||
});
|
||||
const brandArtisan = await prisma.brand.upsert({
|
||||
where: { id: 'brand-artisan' },
|
||||
|
||||
Reference in New Issue
Block a user