diff --git a/apps/admin-ui/app/(drawer)/dashboard/products/add.tsx b/apps/admin-ui/app/(drawer)/dashboard/products/add.tsx index e728976..bedb212 100644 --- a/apps/admin-ui/app/(drawer)/dashboard/products/add.tsx +++ b/apps/admin-ui/app/(drawer)/dashboard/products/add.tsx @@ -118,7 +118,9 @@ export default function AddProduct() { name: '', shortDescription: '', longDescription: '', - storeId: 1, + // 0 = "no store chosen yet"; ProductForm fills in the first available store + // (regional preferred) once the store list loads. + storeId: 0, productType: 'item' as const, variants: [ { diff --git a/apps/admin-ui/app/(drawer)/dashboard/products/edit.tsx b/apps/admin-ui/app/(drawer)/dashboard/products/edit.tsx index e632aad..e2bb50e 100644 --- a/apps/admin-ui/app/(drawer)/dashboard/products/edit.tsx +++ b/apps/admin-ui/app/(drawer)/dashboard/products/edit.tsx @@ -51,7 +51,7 @@ export default function EditProduct() { name: productData.name, shortDescription: productData.shortDescription || '', longDescription: productData.longDescription || '', - storeId: productData.storeId || 1, + storeId: productData.storeId || 0, productType: (productData.productType as 'item' | 'combo') || 'item', variants: (productData.skus || []).map((sku) => ({ id: sku.id, diff --git a/apps/admin-ui/src/components/ProductForm.tsx b/apps/admin-ui/src/components/ProductForm.tsx index 30d3818..2d4f6bd 100644 --- a/apps/admin-ui/src/components/ProductForm.tsx +++ b/apps/admin-ui/src/components/ProductForm.tsx @@ -177,11 +177,21 @@ const ProductForm = forwardRef(({ }), [initialValues.variants]) const { data: storesData } = trpc.common.getStoresSummary.useQuery() + // Global stores are usable from every region, so they are selectable too; + // label them so the choice is explicit (the product still stays in this + // admin's region). const storeOptions = storesData?.stores.map((store) => ({ - label: store.name, + label: store.isGlobal ? `${store.name} (global)` : store.name, value: store.id, })) || [] + // Fallback for a create form that seeds no store: prefer a regional store, + // else the first option (e.g. a global store) once the list loads. + const defaultStoreId = useMemo(() => { + const stores = storesData?.stores ?? [] + return stores.find((store) => !store.isGlobal)?.id ?? stores[0]?.id ?? 0 + }, [storesData]) + const { data: skusData } = trpc.common.product.getAllSkusSummary.useQuery() const skuOptions = (skusData?.skus || []).map((sku) => ({ label: sku.label, @@ -193,6 +203,9 @@ const ProductForm = forwardRef(({ const formInitialValues = useMemo(() => { return { ...initialValues, + // An empty seed (create form) adopts the first available store once the + // list has loaded; an existing product keeps its own store. + storeId: initialValues.storeId || defaultStoreId, variants: (initialValues.variants || []).map((v) => { const hasQuantity = (v.features || []).some( (a) => (a.featureName ?? '').trim().toLowerCase() === 'quantity' @@ -201,7 +214,7 @@ const ProductForm = forwardRef(({ return { ...v, features: [quantityAttribute(), ...(v.features || [])] } }), } - }, [initialValues]) + }, [initialValues, defaultStoreId]) return ( { ) expect(onSubmit).not.toHaveBeenCalled() }) + + it('lists global stores in the picker and marks them (global)', async () => { + setupApiMocks({ + procedures: { + 'common.getStoresSummary': { + stores: [ + { id: 1, name: 'Main Store' }, + { id: 3, name: 'Meat Store', isGlobal: true }, + ], + }, + }, + }) + renderWithProviders( + + ) + + // The selected global store is offered (otherwise the trigger would fall + // back to the placeholder) and its label carries the global marker. + await waitFor(() => + expect(screen.getAllByText('Meat Store (global)').length).toBeGreaterThan(0) + ) + + fireEvent.press(screen.getByTestId('product-store-dropdown')) + expect(await screen.findByTestId('product-store-dropdown-option-3')).toBeVisible() + }) + + it('adopts the first regional store when the form seeds no store', async () => { + setupApiMocks({ + procedures: { + 'common.getStoresSummary': { + stores: [ + { id: 3, name: 'Meat Store', isGlobal: true }, + { id: 2, name: 'Second Store' }, + ], + }, + }, + }) + renderWithProviders( + + ) + + // Prefers the regional store even though the global one is listed first. + await waitFor(() => + expect(screen.getAllByText('Second Store').length).toBeGreaterThan(0) + ) + }) }) diff --git a/apps/admin-web/src/components/ProductForm.tsx b/apps/admin-web/src/components/ProductForm.tsx index 86af553..4c17bb5 100644 --- a/apps/admin-web/src/components/ProductForm.tsx +++ b/apps/admin-web/src/components/ProductForm.tsx @@ -195,11 +195,21 @@ const ProductForm = forwardRef(({ }), [initialValues.variants]) const { data: storesData } = trpc.common.getStoresSummary.useQuery() + // Global stores are usable from every region, so they are selectable too; + // label them so the choice is explicit (the product still stays in this + // admin's region). const storeOptions = storesData?.stores.map((store) => ({ - label: store.name, + label: store.isGlobal ? `${store.name} (global)` : store.name, value: store.id, })) || [] + // Fallback for a create form that seeds no store: prefer a regional store, + // else the first option (e.g. a global store) once the list loads. + const defaultStoreId = useMemo(() => { + const stores = storesData?.stores ?? [] + return stores.find((store) => !store.isGlobal)?.id ?? stores[0]?.id ?? 0 + }, [storesData]) + const { data: skusData } = trpc.common.product.getAllSkusSummary.useQuery() const skuOptions = (skusData?.skus || []).map((sku) => ({ label: sku.label, @@ -211,6 +221,9 @@ const ProductForm = forwardRef(({ const formInitialValues = useMemo(() => { return { ...initialValues, + // An empty seed (create form) adopts the first available store once the + // list has loaded; an existing product keeps its own store. + storeId: initialValues.storeId || defaultStoreId, variants: (initialValues.variants || []).map((v) => { const hasQuantity = (v.features || []).some( (a) => (a.featureName ?? '').trim().toLowerCase() === 'quantity' @@ -219,7 +232,7 @@ const ProductForm = forwardRef(({ return { ...v, features: [quantityAttribute(), ...(v.features || [])] } }), } - }, [initialValues]) + }, [initialValues, defaultStoreId]) return ( ({ id: sku.id, diff --git a/apps/admin-web/src/routes/dashboard.products.new.tsx b/apps/admin-web/src/routes/dashboard.products.new.tsx index ebff7be..96e74f3 100644 --- a/apps/admin-web/src/routes/dashboard.products.new.tsx +++ b/apps/admin-web/src/routes/dashboard.products.new.tsx @@ -112,7 +112,9 @@ function AddProduct() { name: '', shortDescription: '', longDescription: '', - storeId: 1, + // 0 = "no store chosen yet"; ProductForm fills in the first available store + // (regional preferred) once the store list loads. + storeId: 0, productType: 'item' as const, variants: [ { diff --git a/apps/backend/dumps/latest.sql b/apps/backend/dumps/latest.sql index 61107fb..35a0c0c 100644 --- a/apps/backend/dumps/latest.sql +++ b/apps/backend/dumps/latest.sql @@ -859,6 +859,8 @@ INSERT INTO "addresses" ("id","user_id","is_default","name","phone","address_lin INSERT INTO "addresses" ("id","user_id","is_default","name","phone","address_line1","address_line2","city","state","pincode","latitude","longitude","created_at","zone_id","admin_latitude","admin_longitude","google_maps_url") VALUES(881,679,0,'Priyanka ','8919926863','Sarika township ','','Mahabubnagar','Telangana','509001',16.7112532,78.0250534,'2026-10-12 04:15:13',NULL,NULL,NULL,NULL); INSERT INTO "addresses" ("id","user_id","is_default","name","phone","address_line1","address_line2","city","state","pincode","latitude","longitude","created_at","zone_id","admin_latitude","admin_longitude","google_maps_url") VALUES(882,1207,1,'Vijay','7989347494','1-6-9/3 palsab gutta','Opp lane to sri ramulu hospital','Mahabubnagar','Telangana','509001',NULL,NULL,'2026-10-12 05:03:14',NULL,NULL,NULL,NULL); INSERT INTO "addresses" ("id","user_id","is_default","name","phone","address_line1","address_line2","city","state","pincode","latitude","longitude","created_at","zone_id","admin_latitude","admin_longitude","google_maps_url") VALUES(883,1322,0,'Mohammed Hussain ','9966770420','Bhageratha colony pragati nagar ','','Mahabubnagar','Telangana','509001',NULL,NULL,'2026-10-13 11:39:34',NULL,NULL,NULL,NULL); +INSERT INTO "addresses" ("id","user_id","is_default","name","phone","address_line1","address_line2","city","state","pincode","latitude","longitude","created_at","zone_id","admin_latitude","admin_longitude","google_maps_url") VALUES(884,1136,0,'hamdan','9542458176','street no 4','padmavati colny','Mahabubnagar','Telangana','509001',16.7512976,78.0207931,'2026-10-13 13:13:36',NULL,NULL,NULL,NULL); +INSERT INTO "addresses" ("id","user_id","is_default","name","phone","address_line1","address_line2","city","state","pincode","latitude","longitude","created_at","zone_id","admin_latitude","admin_longitude","google_maps_url") VALUES(885,1187,1,'Shyam','9059431839','Ssgutra nalanda auto stand','','Mahabubnagar','Telangana','509001',16.7453134,78.0088342,'2026-10-13 15:49:36',NULL,NULL,NULL,'https://maps.app.goo.gl/sXFDPXkiWukmLLHMA?g_st=ac'); CREATE TABLE IF NOT EXISTS "complaints" ("id" INTEGER PRIMARY KEY, "user_id" INTEGER NOT NULL, "order_id" INTEGER, "complaint_body" TEXT NOT NULL, "is_resolved" INTEGER NOT NULL DEFAULT false, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "response" TEXT, "images" TEXT); INSERT INTO "complaints" ("id","user_id","order_id","complaint_body","is_resolved","created_at","response","images") VALUES(4,17,NULL,'Hello',1,'2025-12-19T08:34:32.924Z','Hi',NULL); INSERT INTO "complaints" ("id","user_id","order_id","complaint_body","is_resolved","created_at","response","images") VALUES(5,17,NULL,'Hello',1,'2025-12-19T09:32:59.187Z','','["complaint-images/1766136777180-0"]'); @@ -957,7 +959,7 @@ INSERT INTO "complaints" ("id","user_id","order_id","complaint_body","is_resolve INSERT INTO "complaints" ("id","user_id","order_id","complaint_body","is_resolved","created_at","response","images") VALUES(102,701,NULL,'Not delivered',1,'2026-10-04 06:04:32','Delivered Successfully',NULL); INSERT INTO "complaints" ("id","user_id","order_id","complaint_body","is_resolved","created_at","response","images") VALUES(103,538,NULL,'Not delivered',0,'2026-10-10 02:43:37',NULL,NULL); INSERT INTO "complaints" ("id","user_id","order_id","complaint_body","is_resolved","created_at","response","images") VALUES(104,538,NULL,'Not delivered',0,'2026-10-10 02:45:03',NULL,NULL); -INSERT INTO "complaints" ("id","user_id","order_id","complaint_body","is_resolved","created_at","response","images") VALUES(105,1262,NULL,replace('Booked slot 11 to 12 between \nCame after 12\nWe left for work\nNo option of rescheduling time','\n',char(10)),0,'2026-10-13 08:32:09',NULL,NULL); +INSERT INTO "complaints" ("id","user_id","order_id","complaint_body","is_resolved","created_at","response","images") VALUES(105,1262,NULL,replace('Booked slot 11 to 12 between \nCame after 12\nWe left for work\nNo option of rescheduling time','\n',char(10)),1,'2026-10-13 08:32:09',replace('Apologies for your trouble mam. Spoke to the delivery agent. This issue won''t happen again.\nWe don''t want to lose you as a customer. To encourage you to order again and experience our services we''ve created a coupon APOLOGY30 for you. Get 30% diacount on your next order','\n',char(10)),NULL); CREATE TABLE IF NOT EXISTS "coupon_applicable_users" ("id" INTEGER PRIMARY KEY, "coupon_id" INTEGER NOT NULL, "user_id" INTEGER NOT NULL); INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(2,11,4); INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(6,18,145); @@ -982,6 +984,7 @@ INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(25,39, INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(26,40,514); INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(27,41,701); INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(28,42,701); +INSERT INTO "coupon_applicable_users" ("id","coupon_id","user_id") VALUES(29,43,1262); CREATE TABLE IF NOT EXISTS "coupon_usage" ("id" INTEGER PRIMARY KEY, "user_id" INTEGER NOT NULL, "coupon_id" INTEGER NOT NULL, "used_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "order_id" INTEGER, "order_item_id" INTEGER); INSERT INTO "coupon_usage" ("id","user_id","coupon_id","used_at","order_id","order_item_id") VALUES(1,2,4,'2025-11-25T06:29:10.947Z',NULL,NULL); INSERT INTO "coupon_usage" ("id","user_id","coupon_id","used_at","order_id","order_item_id") VALUES(59,2,8,'2025-12-27T17:39:01.970Z',117,NULL); @@ -1150,6 +1153,7 @@ INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount"," INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","sku_ids","exclusive_apply","is_first_order_only") VALUES(40,1,15,NULL,299,4,100,0,'2026-09-24 16:56:49',0,'2026-09-30T03:19:00.000Z',2,'FRND31',NULL,0,0); INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","sku_ids","exclusive_apply","is_first_order_only") VALUES(41,1,15,NULL,299,4,50,0,'2026-09-26 03:05:17',0,'2026-10-30T07:02:00.000Z',3,'FRND43',NULL,0,0); INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","sku_ids","exclusive_apply","is_first_order_only") VALUES(42,1,15,NULL,299,4,50,0,'2026-09-26 03:05:43',0,'2026-10-30T07:02:00.000Z',3,'FRESH43',NULL,0,0); +INSERT INTO "coupons" ("id","is_user_based","discount_percent","flat_discount","min_order","created_by","max_value","is_invalidated","created_at","is_apply_for_all","valid_till","max_limit_for_user","coupon_code","sku_ids","exclusive_apply","is_first_order_only") VALUES(43,1,30,NULL,100,6,299,0,'2026-10-13 14:39:43',0,'2026-10-30T00:00:00.000Z',1,'APOLOGY30',NULL,0,0); CREATE TABLE IF NOT EXISTS "delivery_slot_info" ("id" INTEGER PRIMARY KEY, "delivery_time" TEXT NOT NULL, "freeze_time" TEXT NOT NULL, "is_active" INTEGER NOT NULL DEFAULT true, "delivery_sequence" TEXT, "is_flash" INTEGER NOT NULL DEFAULT false, "group_ids" TEXT, "is_capacity_full" INTEGER NOT NULL DEFAULT false, "sku_ids" text DEFAULT '[]'); INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(8,'2025-12-24T19:30:00.000Z','2025-12-25T05:30:00.000Z',1,'{"1":[72,71,67],"2":[70],"3":[69,73,74,76,75]}',0,NULL,0,'[]'); INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(9,'2025-12-25T04:30:00.000Z','2025-12-25T02:30:00.000Z',1,'{"1":[62,60]}',0,NULL,0,'[]'); @@ -2778,6 +2782,12 @@ INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active" INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(2064,'2026-10-14T13:30:00.000Z','2026-10-14T13:20:00.000Z',1,'{}',0,'[12,11,10,5]',0,'[129,130,131,132,133,134,135,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,148,6,7,8,11,13,25,26,38,39,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,73,96,100,125,126,2,3,10,21,23,24,36,40,41,42,80,137,141]'); INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(2065,'2026-10-15T01:30:00.000Z','2026-10-15T01:20:00.000Z',1,'{}',0,'[9,8,7,5]',0,'[9,22,81,82,102,5,6,13,16,17,18,19,27,28,29,30,31,32,33,37,45,64,65,66,67,68,69,70,71,72,74,76,77,78,79,88,89,90,91,92,94,95,97,101,103,127,144,145,146,4,14,35,86,98,99,2,3,10,21,23,24,36,40,41,42,80,137,149,147,140,139,138,136]'); INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(2066,'2026-10-15T02:30:00.000Z','2026-10-15T02:20:00.000Z',1,'{}',0,'[12,11,10,9,8,7,5]',0,'[129,130,131,132,133,134,135,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,148,6,7,8,11,13,25,26,38,39,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,73,96,100,125,126,9,22,81,82,102,5,16,17,18,19,27,28,29,30,31,32,33,37,45,64,65,66,67,68,69,70,71,72,74,76,77,78,79,88,89,90,91,92,94,95,97,101,103,127,144,145,146,4,14,35,86,98,99,2,3,10,21,23,24,36,40,41,42,80,137,149,147,141,140,139,138,136]'); +INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(2067,'2026-10-15T05:30:00.000Z','2026-10-15T05:20:00.000Z',1,'{}',0,'[12,11,10,9,8,7,5]',0,'[129,130,131,132,133,134,135,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,148,6,7,8,11,13,25,26,38,39,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,73,96,100,125,126,9,22,81,82,102,5,16,17,18,19,27,28,29,30,31,32,33,37,45,64,65,66,67,68,69,70,71,72,74,76,77,78,79,88,89,90,91,92,94,95,97,101,103,127,144,145,146,4,14,35,86,98,99,2,3,10,21,23,24,36,40,41,42,80,137,149,147,141,140,139,138,136]'); +INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(2068,'2026-10-15T06:30:00.000Z','2026-10-15T06:20:00.000Z',1,'{}',0,'[12,11,10,9,8,7,5]',0,'[129,130,131,132,133,134,135,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,148,6,7,8,11,13,25,26,38,39,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,73,96,100,125,126,9,22,81,82,102,5,16,17,18,19,27,28,29,30,31,32,33,37,45,64,65,66,67,68,69,70,71,72,74,76,77,78,79,88,89,90,91,92,94,95,97,101,103,127,144,145,146,4,14,35,86,98,99,2,3,10,21,23,24,36,40,41,42,80,137,149,147,141,140,139,138,136]'); +INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(2069,'2026-10-15T09:30:00.000Z','2026-10-15T09:20:00.000Z',1,'{}',0,'[12,11,10,9,8,5]',0,'[129,130,131,132,133,134,135,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,148,7,8,11,13,25,26,38,39,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,73,96,100,125,126,9,22,81,82,102,5,16,17,18,19,27,28,29,30,31,32,33,37,45,64,65,66,67,68,69,70,71,72,74,76,77,78,79,88,89,90,91,92,94,95,97,101,103,127,144,145,146,2,3,10,21,23,24,36,40,41,42,80,137,149,147,141,140,139,138,136]'); +INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(2070,'2026-10-15T10:30:00.000Z','2026-10-15T10:20:00.000Z',1,'{}',0,'[12,11,10,9,8,5]',0,'[129,130,131,132,133,134,135,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,148,6,7,8,11,13,25,26,38,39,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,73,96,100,125,126,9,22,81,82,102,5,16,17,18,19,27,28,29,30,31,32,33,37,45,64,65,66,67,68,69,70,71,72,74,76,77,78,79,88,89,90,91,92,94,95,97,101,103,127,144,145,146,2,3,10,21,23,24,36,40,41,42,80,137,149,147,141,140,139,138,136]'); +INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(2071,'2026-10-15T12:30:00.000Z','2026-10-15T12:20:00.000Z',1,'{}',0,'[12,11,10,9,5]',0,'[129,130,131,132,133,134,135,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,148,6,7,8,11,13,25,26,38,39,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,73,96,100,125,126,9,22,81,82,102,2,3,10,21,23,24,36,40,41,42,80,137,141]'); +INSERT INTO "delivery_slot_info" ("id","delivery_time","freeze_time","is_active","delivery_sequence","is_flash","group_ids","is_capacity_full","sku_ids") VALUES(2072,'2026-10-15T13:30:00.000Z','2026-10-15T13:20:00.000Z',1,'{}',0,'[12,11,10,9,5]',0,'[129,130,131,132,133,134,135,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,148,6,7,8,11,13,25,26,38,39,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,73,96,100,125,126,9,22,81,82,102,2,3,10,21,23,24,36,40,41,42,80,137,141]'); CREATE TABLE IF NOT EXISTS "home_banners" ("id" INTEGER PRIMARY KEY, "name" TEXT NOT NULL, "image_url" TEXT NOT NULL, "description" TEXT, "redirect_url" TEXT, "serial_num" INTEGER, "is_active" INTEGER NOT NULL DEFAULT false, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "last_updated" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "sku_ids" TEXT); INSERT INTO "home_banners" ("id","name","image_url","description","redirect_url","serial_num","is_active","created_at","last_updated","sku_ids") VALUES(9,'10%off ','1770281046297.jpg',NULL,NULL,NULL,0,'2026-02-05T08:44:06.996Z','2026-09-04T15:04:56.030Z','[1,2,3,4,5,6,8,7,9,11,13,12,10]'); INSERT INTO "home_banners" ("id","name","image_url","description","redirect_url","serial_num","is_active","created_at","last_updated","sku_ids") VALUES(11,'Daily veggies ','store-images/1770429593455.jpg','Under 19 ',NULL,3,0,'2026-02-07T01:59:57.566Z','2026-08-19T04:14:07.794Z','[45,72,76,97,70,32,74,77,33]'); @@ -2800,8 +2810,8 @@ INSERT INTO "key_val_store" ("key","value") VALUES('supportMobile','9000885620') INSERT INTO "key_val_store" ("key","value") VALUES('tester','value41'); INSERT INTO "key_val_store" ("key","value") VALUES('versionNum','1.2.0'); INSERT INTO "key_val_store" ("key","value") VALUES('cache_version','769'); -INSERT INTO "key_val_store" ("key","value") VALUES('slots_version_num','674'); -INSERT INTO "key_val_store" ("key","value") VALUES('availability_version_num','110'); +INSERT INTO "key_val_store" ("key","value") VALUES('slots_version_num','680'); +INSERT INTO "key_val_store" ("key","value") VALUES('availability_version_num','111'); INSERT INTO "key_val_store" ("key","value") VALUES('tagsOrder','9,1,2,4,5,8,3,7,6'); CREATE TABLE IF NOT EXISTS "notif_creds" ("id" INTEGER PRIMARY KEY, "token" TEXT NOT NULL, "added_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "user_id" INTEGER NOT NULL, "last_verified" TEXT); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(3,'ExponentPushToken[iv6POIJTUIiGpkElL84fG7]','2026-02-07T16:46:24.831Z',7,'2026-10-10T17:57:30.367Z'); @@ -2819,14 +2829,14 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(18,'ExponentPushToken[qjCI58EqTOeyVk5yLFHGRq]','2026-02-09T11:18:51.370Z',123,'2026-02-09T11:18:51.369Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(19,'ExponentPushToken[mZo3TECtB4tDVgxkDOwev6]','2026-02-09T12:02:26.730Z',124,'2026-02-15T10:51:29.871Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(20,'ExponentPushToken[l527a0C4KT5Ez8aJL7K76l]','2026-02-09T12:10:39.831Z',107,'2026-02-09T12:10:43.875Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(21,'ExponentPushToken[WxQDABD09Hd7JBURDocB67]','2026-02-09T13:24:12.209Z',125,'2026-10-03T07:26:24.568Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(21,'ExponentPushToken[WxQDABD09Hd7JBURDocB67]','2026-02-09T13:24:12.209Z',125,'2026-10-14T05:57:55.292Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(22,'ExponentPushToken[81Io9TG3Qg0s3N0V8L86T-]','2026-02-09T14:12:50.649Z',4,'2026-09-13T13:09:27.482Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(23,'ExponentPushToken[buJyUUCfCpMmsiXqb1--T4]','2026-02-09T15:57:32.198Z',38,'2026-03-25T06:37:06.114Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(24,'ExponentPushToken[B2zWnHNaumIgbeFFKO-15D]','2026-02-09T19:53:37.594Z',113,'2026-02-10T07:43:48.632Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(25,'ExponentPushToken[wIhrdlAmwj0Eytvz3W3TTZ]','2026-02-10T11:09:24.848Z',127,'2026-04-18T06:53:49.329Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(26,'ExponentPushToken[hFUlPFOKMdAUgtDP7EtSzM]','2026-02-10T11:33:43.821Z',3,'2026-02-24T11:16:46.799Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(27,'ExponentPushToken[NymZTEED3G7YCyDg7ihgBA]','2026-02-11T03:16:04.540Z',2,'2026-10-13T12:24:40.011Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(28,'ExponentPushToken[ARCT4KD7CJ_pFF_GkywepP]','2026-02-11T11:34:32.238Z',115,'2026-10-11T08:16:00.995Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(27,'ExponentPushToken[NymZTEED3G7YCyDg7ihgBA]','2026-02-11T03:16:04.540Z',2,'2026-10-14T05:09:51.520Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(28,'ExponentPushToken[ARCT4KD7CJ_pFF_GkywepP]','2026-02-11T11:34:32.238Z',115,'2026-10-14T06:53:32.365Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(29,'ExponentPushToken[NN4v16BFslBX8ryVXDwQIg]','2026-02-12T08:46:42.421Z',128,'2026-02-17T19:04:12.936Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(30,'ExponentPushToken[qbteKBC1wbLMCe1ltpul7u]','2026-02-12T13:28:00.376Z',129,'2026-02-12T13:28:00.375Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(31,'ExponentPushToken[PfjMc_CTRvSvOWtSNmaHhL]','2026-02-14T10:25:41.451Z',131,'2026-10-13T06:20:51.433Z'); @@ -2836,7 +2846,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(35,'ExponentPushToken[pIQ2waNDjjSHjQYJbXKD8m]','2026-02-15T07:14:10.912Z',9,'2026-02-15T07:14:10.910Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(37,'ExponentPushToken[kq0I8ADfcQ4VcsZ0yK0Mlc]','2026-02-16T04:01:56.375Z',102,'2026-07-05T14:39:51.366Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(38,'ExponentPushToken[8wH85rFtQRMk7ciFszmirX]','2026-02-16T09:30:32.930Z',134,'2026-09-08T07:22:34.339Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(39,'ExponentPushToken[YJRSQmMUEUbaI2VCZLaoN_]','2026-02-16T09:49:56.439Z',6,'2026-10-13T10:28:55.609Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(39,'ExponentPushToken[YJRSQmMUEUbaI2VCZLaoN_]','2026-02-16T09:49:56.439Z',6,'2026-10-14T11:35:46.240Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(40,'ExponentPushToken[QoWbURL2N8-3jRhQwfnRP_]','2026-02-17T08:59:14.561Z',135,'2026-02-17T08:59:14.561Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(41,'ExponentPushToken[sz_g75Il_CNAG6KpEAxYUH]','2026-02-17T12:56:33.589Z',136,'2026-02-21T08:42:45.220Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(42,'ExponentPushToken[JMEvkUHKT0n34hcs-MiJAJ]','2026-02-17T14:22:02.805Z',137,'2026-02-17T18:35:14.821Z'); @@ -2853,7 +2863,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(53,'ExponentPushToken[Gb4KieGJIaPnwHmzTYtcMv]','2026-02-18T09:59:40.489Z',146,'2026-03-19T13:14:04.282Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(54,'ExponentPushToken[B74UidJrvnrP8wBb_rHdAC]','2026-02-18T10:44:13.691Z',147,'2026-02-23T08:38:19.771Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(55,'ExponentPushToken[x2VSb-OGOkn6ivVxpzk6tX]','2026-02-18T12:22:43.429Z',24,'2026-10-07T05:25:32.395Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(56,'ExponentPushToken[qh6APjAuydb_LnlN4DqYsO]','2026-02-18T12:46:15.407Z',82,'2026-10-08T06:16:33.610Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(56,'ExponentPushToken[qh6APjAuydb_LnlN4DqYsO]','2026-02-18T12:46:15.407Z',82,'2026-10-14T04:11:02.519Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(57,'ExponentPushToken[2o572RMsmVSFjUamLuEcoU]','2026-02-18T12:59:53.266Z',148,'2026-02-28T11:44:18.100Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(58,'ExponentPushToken[3kQdCMDTdTPoDMGP05IITB]','2026-02-18T14:39:16.947Z',149,'2026-02-24T12:34:44.462Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(59,'ExponentPushToken[oHNDFzFcWPaMrr6UuCUaUd]','2026-02-18T14:41:42.373Z',150,'2026-02-19T10:15:17.727Z'); @@ -2947,14 +2957,14 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(165,'ExponentPushToken[K511csDWcit0dWEirbgbzi]','2026-02-27T07:04:00.681Z',240,'2026-02-28T15:41:55.679Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(166,'ExponentPushToken[MfRngZOhpCB7E3V9RdMZSv]','2026-02-27T08:53:11.807Z',241,'2026-03-03T12:23:45.086Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(167,'ExponentPushToken[7_2BsnHaPnqeRmS1UhKxVV]','2026-02-27T08:55:32.911Z',242,'2026-02-27T10:38:00.341Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(168,'ExponentPushToken[O97M2AI7zuVbU5f4uM4VQt]','2026-02-27T10:09:30.960Z',243,'2026-10-09T03:55:30.425Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(168,'ExponentPushToken[O97M2AI7zuVbU5f4uM4VQt]','2026-02-27T10:09:30.960Z',243,'2026-10-14T07:19:09.194Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(169,'ExponentPushToken[1OiPCiNz2M-HNY_r1Rqp6W]','2026-02-27T11:51:20.794Z',244,'2026-03-08T11:09:06.330Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(170,'ExponentPushToken[9AiqjsI6hJ6YjGJ_KcgO2I]','2026-02-28T05:31:18.743Z',246,'2026-08-14T03:21:51.274Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(171,'ExponentPushToken[OuDYj9C40QvJdE0mjvGnJJ]','2026-03-01T08:07:04.795Z',247,'2026-03-01T08:32:20.173Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(172,'ExponentPushToken[EhQ5xpIqjKR1dYQeye8QJ9]','2026-03-01T08:19:19.051Z',245,'2026-03-04T15:02:44.108Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(173,'ExponentPushToken[c6dahyP6YmPF9fCuqgt8CC]','2026-03-01T09:14:36.286Z',93,'2026-03-01T09:14:36.286Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(174,'ExponentPushToken[gNBguFFceE2kNkLWRCdUma]','2026-03-02T07:08:01.400Z',249,'2026-05-04T11:20:57.608Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(175,'ExponentPushToken[1wOEHBCH7bCIx3LzleZLnu]','2026-03-02T09:10:41.738Z',250,'2026-10-04T04:42:18.230Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(175,'ExponentPushToken[1wOEHBCH7bCIx3LzleZLnu]','2026-03-02T09:10:41.738Z',250,'2026-10-14T06:56:01.029Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(176,'ExponentPushToken[KNnVd_Ou8eRzSOPqN-GpUG]','2026-03-03T09:57:37.076Z',251,'2026-03-10T08:30:45.112Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(178,'ExponentPushToken[7GSJrGD9NaX281KgJzBLLH]','2026-03-03T14:06:35.808Z',253,'2026-03-03T14:06:35.807Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(179,'ExponentPushToken[UcUA5tEEV70FB2Ntz-oFJ2]','2026-03-03T16:06:53.662Z',254,'2026-03-20T07:56:23.132Z'); @@ -3031,7 +3041,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(261,'ExponentPushToken[a2jvk0Fnz9duzyq200RSaA]','2026-03-31T04:17:42.116Z',320,'2026-03-31T06:11:19.809Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(262,'ExponentPushToken[WLdlE5HouAnITMuP3e89pV]','2026-03-31T09:43:59.935Z',327,'2026-03-31T09:43:59.935Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(263,'ExponentPushToken[jr_qvoKS2Wzm2ypdOTtIg3]','2026-04-01T14:10:29.517Z',328,'2026-04-05T06:07:13.512Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(264,'ExponentPushToken[5Y0eOLHP-WHTdPIhswnzaw]','2026-04-02T08:29:21.649Z',329,'2026-09-25T04:35:16.056Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(264,'ExponentPushToken[5Y0eOLHP-WHTdPIhswnzaw]','2026-04-02T08:29:21.649Z',329,'2026-10-14T03:28:33.801Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(265,'ExponentPushToken[j1udiOOiTMrtb_49NPsyh-]','2026-04-02T18:49:29.930Z',330,'2026-04-03T14:24:44.024Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(266,'ExponentPushToken[rz39abBULbPasMRFHOT-AN]','2026-04-03T12:01:30.781Z',331,'2026-04-04T06:55:46.505Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(267,'ExponentPushToken[65W0pwIGMvhlJfkiFc6zx0]','2026-04-03T13:20:24.038Z',332,'2026-10-05T11:10:28.282Z'); @@ -3194,11 +3204,11 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(425,'ExponentPushToken[PowDUOG3Bormg6-1SBsuiu]','2026-05-22 03:17:23',491,'2026-05-30T07:59:12.100Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(426,'ExponentPushToken[tioFveItRlA7fTirESkDg6]','2026-05-22 05:06:05',492,'2026-10-05T15:34:46.197Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(427,'ExponentPushToken[FILgJIA4CF8h6Th5PrBj-m]','2026-05-22 06:32:38',493,'2026-07-31T14:01:28.590Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(428,'ExponentPushToken[ixGazvOfrCBIMFMjov2-qW]','2026-05-22 14:02:48',494,'2026-10-12T14:06:34.564Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(428,'ExponentPushToken[ixGazvOfrCBIMFMjov2-qW]','2026-05-22 14:02:48',494,'2026-10-14T03:07:02.366Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(429,'ExponentPushToken[F8ugp5MHbdW2gq6IU-mTj9]','2026-05-23 06:59:51',496,'2026-05-23T06:59:51.427Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(430,'ExponentPushToken[mYGulxOHjS3smtYG6104Gj]','2026-05-23 07:00:44',497,'2026-06-03T07:46:58.286Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(431,'ExponentPushToken[e25COGDjnLy9hJWwyZ3lwN]','2026-05-23 07:06:01',498,'2026-07-20T13:47:26.421Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(432,'ExponentPushToken[_aWL27BMxjQBY76z2FAun8]','2026-05-23 14:20:45',499,'2026-10-10T12:15:58.319Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(432,'ExponentPushToken[_aWL27BMxjQBY76z2FAun8]','2026-05-23 14:20:45',499,'2026-10-14T06:59:35.784Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(433,'ExponentPushToken[b6h8UBIO402fVqO95TOAIj]','2026-05-23 17:23:13',500,'2026-10-02T11:11:35.064Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(434,'ExponentPushToken[1SRWUsFouc9jcNsVoZVRtY]','2026-05-24 12:30:41',502,'2026-05-26T11:12:14.466Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(435,'ExponentPushToken[FhDC-3KdfVOiAk2vHRPoI0]','2026-05-24 12:31:09',503,'2026-08-14T09:42:50.214Z'); @@ -3246,7 +3256,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(477,'ExponentPushToken[xW60lBF5T8QZhcukLKWiLT]','2026-06-13 06:50:53',539,'2026-06-13T06:50:53.542Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(478,'ExponentPushToken[OcXxPHN4S6jSOcfUst66iz]','2026-06-13 13:05:48',541,'2026-06-13T13:05:47.880Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(479,'ExponentPushToken[MDMAekEhhWndpo2uBAD9Aa]','2026-06-14 08:02:34',542,'2026-06-14T08:02:34.279Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(480,'ExponentPushToken[-mWZEMNqDOXZj9ESRGhRuA]','2026-06-15 12:02:30',414,'2026-10-13T09:43:39.306Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(480,'ExponentPushToken[-mWZEMNqDOXZj9ESRGhRuA]','2026-06-15 12:02:30',414,'2026-10-14T04:55:47.072Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(481,'ExponentPushToken[C36i1zA_O5lmgPSe0H6GCS]','2026-06-17 06:17:53',544,'2026-09-06T15:30:50.969Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(482,'ExponentPushToken[Kl7RrWOFizANCgLbHBZDTO]','2026-06-17 11:56:17',545,'2026-06-21T08:01:57.256Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(483,'ExponentPushToken[3R26bUHCHaUtIoOnHLVbTX]','2026-06-17 13:50:26',121,'2026-06-17T13:53:22.079Z'); @@ -3412,7 +3422,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(643,'ExponentPushToken[7h7wnsIG9HYUoyBvb4X8wS]','2026-07-26 02:54:02',677,'2026-09-28T02:22:48.903Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(644,'ExponentPushToken[OKi6lkFWT3Qg5yj9DXJDO_]','2026-07-26 10:42:54',712,'2026-07-26T10:42:54.332Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(645,'ExponentPushToken[8fp2aLMdcCfmHVIDQpXeAA]','2026-07-27 03:27:39',713,'2026-07-27T03:45:30.720Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(646,'ExponentPushToken[BEVARONVXrlap4i5FLPKdf]','2026-07-28 06:28:09',714,'2026-09-29T05:06:55.257Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(646,'ExponentPushToken[BEVARONVXrlap4i5FLPKdf]','2026-07-28 06:28:09',714,'2026-10-14T05:50:03.258Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(647,'ExponentPushToken[tMg5fFP6YY0DQ8rueB_S7m]','2026-07-28 12:55:09',704,'2026-09-30T07:32:50.341Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(648,'ExponentPushToken[FILgJIA4CF8h6Th5PrBj-m]','2026-07-31 14:01:52',517,'2026-10-13T03:39:53.402Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(649,'ExponentPushToken[_fOMzgDKDz8CqLHUhEpLEk]','2026-08-01 01:08:10',715,'2026-08-01T01:08:10.898Z'); @@ -3474,7 +3484,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(705,'ExponentPushToken[SYnHRCJ01eyYUoTVTkdHtR]','2026-08-20 19:17:32',72,'2026-08-21T03:54:54.728Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(706,'ExponentPushToken[wC3NeIELlBXOaz9_ZE1nXW]','2026-08-21 13:42:12',770,'2026-08-21T13:42:12.496Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(707,'ExponentPushToken[HDlyCePSKidWMerJDuGs3i]','2026-08-22 05:37:47',771,'2026-08-22T05:37:47.680Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(708,'ExponentPushToken[QjYo7QIpmvlJFa5OziArDu]','2026-08-22 10:39:05',772,'2026-09-27T03:11:52.575Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(708,'ExponentPushToken[QjYo7QIpmvlJFa5OziArDu]','2026-08-22 10:39:05',772,'2026-10-13T16:46:02.326Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(709,'ExponentPushToken[BhMOVsOAh3QtXzMOKKN81M]','2026-08-22 12:53:54',32,'2026-09-24T06:00:38.871Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(710,'ExponentPushToken[DfXROmDG8YJTmvfcfVxMpe]','2026-08-23 04:49:05',773,'2026-09-27T04:20:25.487Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(711,'ExponentPushToken[tQsJhjJzn-50yVdmhNgCV6]','2026-08-23 12:41:26',774,'2026-10-01T13:02:10.973Z'); @@ -3489,7 +3499,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(720,'ExponentPushToken[xrdiTHAyODb8MC2Ods51zE]','2026-08-29 13:42:13',783,'2026-08-29T13:42:13.252Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(721,'ExponentPushToken[MngcWzOVupG2jCP92aFAHU]','2026-08-29 15:28:31',784,'2026-09-27T03:02:00.567Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(722,'ExponentPushToken[An3bpDJv4ViVBBpzCzM44a]','2026-08-30 01:19:31',29,'2026-08-30T01:19:31.979Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(723,'ExponentPushToken[t3FYXoICjlyY0mLg8oJk83]','2026-08-30 02:02:58',785,'2026-10-13T06:28:02.440Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(723,'ExponentPushToken[t3FYXoICjlyY0mLg8oJk83]','2026-08-30 02:02:58',785,'2026-10-14T07:30:03.291Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(724,'ExponentPushToken[cqGWnjOjW7qpXvF00rCIwY]','2026-08-30 04:10:48',787,'2026-10-05T12:06:12.922Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(725,'ExponentPushToken[loVe35LpngZFsQIIQLmHnS]','2026-08-30 14:44:23',788,'2026-10-10T15:23:27.423Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(726,'ExponentPushToken[jMAuL9Kx7xb-v6TQ3-YEQ-]','2026-09-04 08:44:41',789,'2026-09-07T17:53:58.352Z'); @@ -3579,7 +3589,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(811,'ExponentPushToken[Zpv0h8PmNMVjTBbE6VPDOW]','2026-09-11 15:40:07',881,'2026-09-11T15:40:07.099Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(812,'ExponentPushToken[Czll9XPe6JW6Y_pwmVt7Yl]','2026-09-11 15:44:20',882,'2026-09-29T02:52:27.943Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(813,'ExponentPushToken[PNKVoYFDkwMX4z1vlTBJZv]','2026-09-11 15:54:39',883,'2026-09-13T04:09:34.293Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(814,'ExponentPushToken[IN99jWFmKwUzfS8slyGooW]','2026-09-11 15:54:50',884,'2026-10-13T02:42:47.712Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(814,'ExponentPushToken[IN99jWFmKwUzfS8slyGooW]','2026-09-11 15:54:50',884,'2026-10-14T12:38:18.756Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(815,'ExponentPushToken[S6e577KGRa5M8CVOC06FCC]','2026-09-11 15:56:35',885,'2026-10-08T06:09:50.935Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(816,'ExponentPushToken[i2sfxDIRgo5tDmTrJc-Rht]','2026-09-11 15:59:25',886,'2026-09-27T10:03:30.506Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(817,'ExponentPushToken[2CcucpFt9MYNsF3PFlgxt4]','2026-09-11 16:02:26',887,'2026-09-27T12:27:43.091Z'); @@ -3688,7 +3698,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(920,'ExponentPushToken[yoginqEu07w8QGrlJkq-fq]','2026-09-12 07:12:06',1006,'2026-09-28T14:27:02.835Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(921,'ExponentPushToken[ceqKVyFD0U8CUtECPCErHD]','2026-09-12 07:12:33',1007,'2026-09-20T08:00:44.074Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(922,'ExponentPushToken[G04tsDHh8i7hJbjofA07m3]','2026-09-12 07:20:52',1008,'2026-10-12T12:23:57.111Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(923,'ExponentPushToken[ZSldxmD8RXsz-HXinaVO3M]','2026-09-12 07:20:54',1009,'2026-10-13T05:10:30.369Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(923,'ExponentPushToken[ZSldxmD8RXsz-HXinaVO3M]','2026-09-12 07:20:54',1009,'2026-10-13T18:11:13.096Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(924,'ExponentPushToken[Ec-YZlJi14sZmFnBJMsaD4]','2026-09-12 07:28:19',1012,'2026-09-30T15:13:49.327Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(925,'ExponentPushToken[qJx-_AF4AVCayQ9gliKogm]','2026-09-12 07:36:49',1014,'2026-09-12T07:36:49.806Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(926,'ExponentPushToken[1ys58PAxbdv1srboHb095_]','2026-09-12 08:04:01',1015,'2026-09-19T09:48:45.111Z'); @@ -3738,7 +3748,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(970,'ExponentPushToken[0wnswUCYyC2AGtnLoGObAw]','2026-09-12 17:51:00',388,'2026-09-30T16:35:36.684Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(971,'ExponentPushToken[GLZhE2PQcy5pJifQ1Fz4XI]','2026-09-12 18:49:56',770,'2026-09-13T07:51:12.864Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(972,'ExponentPushToken[B2nE0OE1P5d6FXSfP4UWo4]','2026-09-12 19:10:11',1068,'2026-10-06T14:37:32.288Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(973,'ExponentPushToken[utQUlNFmt8ApDX43jm4Vo1]','2026-09-12 19:20:14',1069,'2026-09-19T19:22:43.678Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(973,'ExponentPushToken[utQUlNFmt8ApDX43jm4Vo1]','2026-09-12 19:20:14',1069,'2026-10-13T13:20:54.322Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(974,'ExponentPushToken[H_TlXXGuzb9kx14qIfj5AI]','2026-09-12 19:26:44',1070,'2026-09-30T16:27:39.317Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(976,'ExponentPushToken[NPXzcaHyO-NjUbLL6YRqjQ]','2026-09-13 00:48:56',1072,'2026-10-03T09:39:46.808Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(977,'ExponentPushToken[MxKgZvF2eEy-v1EmCaLpmq]','2026-09-13 01:40:43',1073,'2026-09-17T13:32:43.512Z'); @@ -3776,7 +3786,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1009,'ExponentPushToken[8m6Kv8KIalWElZ49DTF9OF]','2026-09-13 10:39:45',1109,'2026-09-14T07:46:41.905Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1010,'ExponentPushToken[ZUIRJwCnvAmbke66Sf9Znx]','2026-09-13 10:58:37',1110,'2026-09-13T10:59:58.376Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1011,'ExponentPushToken[eL08_GAHcvVR21FuPDPy_U]','2026-09-13 11:17:47',1111,'2026-09-14T12:02:27.418Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1012,'ExponentPushToken[fTmN-PMifvn5P-4fQZA92R]','2026-09-13 11:31:30',816,'2026-10-13T09:55:34.355Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1012,'ExponentPushToken[fTmN-PMifvn5P-4fQZA92R]','2026-09-13 11:31:30',816,'2026-10-14T12:17:43.261Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1013,'ExponentPushToken[L3yKDYPdb6ywdzKh5zTxQ2]','2026-09-13 11:33:05',1112,'2026-09-13T11:42:09.330Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1014,'ExponentPushToken[N5P1BlNaIgCZuRyw0mttc-]','2026-09-13 11:42:04',1113,'2026-09-30T01:27:07.123Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1015,'ExponentPushToken[V6phOrD8N5laDCKsOKkJSw]','2026-09-13 12:01:26',1114,'2026-10-04T05:21:51.585Z'); @@ -3799,7 +3809,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1033,'ExponentPushToken[cr6_1DEr-vrZgj8U0LtEt7]','2026-09-14 07:34:10',1131,'2026-09-21T05:54:20.792Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1034,'ExponentPushToken[tEGX8aFR3w2cjBrEbk1Fk4]','2026-09-14 12:32:32',1133,'2026-10-04T13:49:07.669Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1035,'ExponentPushToken[30brXmOfR8xyF20BRLQ2eV]','2026-09-14 13:32:18',1135,'2026-09-14T13:32:18.417Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1036,'ExponentPushToken[QlF5ksFNOH8qup-CBDCj5k]','2026-09-14 13:37:50',1136,'2026-10-07T14:04:11.915Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1036,'ExponentPushToken[QlF5ksFNOH8qup-CBDCj5k]','2026-09-14 13:37:50',1136,'2026-10-13T14:23:14.437Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1037,'ExponentPushToken[tiZy9uGX2ERidETFAQUAEq]','2026-09-14 13:38:34',1137,'2026-09-27T12:27:58.319Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1038,'ExponentPushToken[iDeZjqHFrkhOc5JRXee6qz]','2026-09-14 13:56:03',1138,'2026-09-15T07:39:59.926Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1039,'ExponentPushToken[0A5i8bBTbwwv6QV_JIqgVJ]','2026-09-14 14:24:03',1139,'2026-10-04T05:01:24.650Z'); @@ -3807,7 +3817,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1041,'ExponentPushToken[Sf2Oj8FGMXAaviqsHi5nEV]','2026-09-14 19:22:45',1142,'2026-09-30T04:55:48.428Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1042,'ExponentPushToken[_eOuGGJJ9BgI2032XP0FI1]','2026-09-15 01:05:33',1143,'2026-10-11T02:36:18.323Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1043,'ExponentPushToken[16jaqrPx3FzyO_d1hHiGHg]','2026-09-15 01:40:21',1144,'2026-10-13T03:13:24.527Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1044,'ExponentPushToken[QHpVTGLrRHYPMOHIukqWm-]','2026-09-15 01:40:30',1145,'2026-10-13T02:53:11.673Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1044,'ExponentPushToken[QHpVTGLrRHYPMOHIukqWm-]','2026-09-15 01:40:30',1145,'2026-10-14T04:31:42.076Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1045,'ExponentPushToken[nCJ-e2JOLKdt1vAPNTnDl6]','2026-09-15 04:12:54',1146,'2026-09-16T05:55:47.489Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1046,'ExponentPushToken[WB3b2vGIAMbIP9GQZ5hO7Q]','2026-09-15 05:06:42',1147,'2026-10-09T05:07:01.797Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1047,'ExponentPushToken[YKeR0jCFe_PLXoT2aM4XbR]','2026-09-15 05:34:59',1148,'2026-09-19T07:19:48.963Z'); @@ -3822,7 +3832,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1056,'ExponentPushToken[QMegqTLBVUTTSTvUei6tJE]','2026-09-15 10:19:50',1156,'2026-09-30T11:18:14.255Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1057,'ExponentPushToken[jOCJZqGYiums4IfZfG-zeG]','2026-09-15 10:20:32',1157,'2026-09-15T10:25:12.908Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1058,'ExponentPushToken[KHBcS1Eo9zJKb8dMHv1l1M]','2026-09-15 11:25:28',1159,'2026-09-15T11:25:28.688Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1059,'ExponentPushToken[qtIUijCZo5HgXDzS0peSSu]','2026-09-15 11:55:01',1160,'2026-10-11T08:39:52.957Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1059,'ExponentPushToken[qtIUijCZo5HgXDzS0peSSu]','2026-09-15 11:55:01',1160,'2026-10-13T13:13:05.995Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1060,'ExponentPushToken[PCq8UGJY7A2SmriC35qttm]','2026-09-15 12:04:18',1162,'2026-10-11T06:04:20.404Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1061,'ExponentPushToken[y4IoxEAuJLgEFDZNIqRCMo]','2026-09-15 12:17:07',1163,'2026-09-18T04:08:39.588Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1062,'ExponentPushToken[cj_wFoL6KJ20jFXHHqR8d5]','2026-09-15 13:02:25',1164,'2026-09-15T13:02:25.710Z'); @@ -3851,7 +3861,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1085,'ExponentPushToken[WNFDt7O_XwLLi9o4Kzkxh1]','2026-09-16 17:05:05',1141,'2026-09-16T17:05:05.695Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1086,'ExponentPushToken[iy4keVDskW3UeguQ98IC18]','2026-09-16 18:28:01',1185,'2026-09-25T03:52:06.344Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1087,'ExponentPushToken[ztKEwrJShQuweUycnFsIEf]','2026-09-17 01:31:58',1186,'2026-09-17T01:57:18.495Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1088,'ExponentPushToken[sAd4YtJL7eNiyZYFLQ9RIS]','2026-09-17 03:54:31',1187,'2026-09-17T03:54:31.077Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1088,'ExponentPushToken[sAd4YtJL7eNiyZYFLQ9RIS]','2026-09-17 03:54:31',1187,'2026-10-13T15:45:11.244Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1089,'ExponentPushToken[LfAPs1IUnZSrW11L2P6Ljq]','2026-09-17 07:32:13',1188,'2026-09-22T16:24:02.326Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1090,'ExponentPushToken[FRvK5qOdOnOM3J_ewfgEVy]','2026-09-17 07:55:21',1078,'2026-10-08T20:35:15.568Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1091,'ExponentPushToken[QqPqRuL-HlsUOJkxoPiPCX]','2026-09-17 09:16:46',1011,'2026-09-17T11:40:10.585Z'); @@ -3865,7 +3875,7 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1099,'ExponentPushToken[yMnX48JtzXu3MfH5pnRGgG]','2026-09-18 06:14:21',1196,'2026-09-18T06:14:21.778Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1100,'ExponentPushToken[OSNa9rMsgXNTh02hjnbV_s]','2026-09-18 11:58:01',1198,'2026-09-19T03:51:26.462Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1101,'ExponentPushToken[_Fnig4JuATDGSX60UrE6z6]','2026-09-18 12:39:05',589,'2026-09-28T03:09:00.641Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1102,'ExponentPushToken[3uZhBQJSl7zx0qs_zjHy96]','2026-09-18 14:13:19',1199,'2026-09-28T13:07:41.246Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1102,'ExponentPushToken[3uZhBQJSl7zx0qs_zjHy96]','2026-09-18 14:13:19',1199,'2026-10-14T12:54:39.704Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1103,'ExponentPushToken[tMoHveEoDz0OonLg1Pk3Cy]','2026-09-18 14:16:07',1000,'2026-09-29T14:13:31.991Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1104,'ExponentPushToken[BJwjKOBp3xFUnSdLaZ0yiz]','2026-09-19 12:14:28',1201,'2026-09-19T12:14:28.952Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1105,'ExponentPushToken[sYn2CnJV_Focrm9PgNacHQ]','2026-09-19 15:53:55',1203,'2026-10-13T05:31:21.054Z'); @@ -3915,8 +3925,8 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1149,'ExponentPushToken[__M9CLEVj_j9IpU3AsUdDC]','2026-09-26 05:51:38',119,'2026-09-26T05:51:38.509Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1150,'ExponentPushToken[mMJ-_6Ev70Hz-OnSi1oRY5]','2026-09-26 15:43:02',1254,'2026-10-04T14:39:21.788Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1151,'ExponentPushToken[cPo8IVBjvLXvjV1AFZoi68]','2026-09-27 01:27:58',1255,'2026-10-02T13:35:56.856Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1152,'ExponentPushToken[TCFYIgFGUV7DFhrEMK3JqP]','2026-09-27 02:18:58',1257,'2026-10-12T13:33:31.459Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1153,'ExponentPushToken[kXfKFoI9a0ydsNoCA2Ox4F]','2026-09-27 02:59:14',1258,'2026-10-11T04:50:39.136Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1152,'ExponentPushToken[TCFYIgFGUV7DFhrEMK3JqP]','2026-09-27 02:18:58',1257,'2026-10-14T07:41:51.608Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1153,'ExponentPushToken[kXfKFoI9a0ydsNoCA2Ox4F]','2026-09-27 02:59:14',1258,'2026-10-14T02:47:06.191Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1154,'ExponentPushToken[a_TjBGIQuTFQFw9ZxIekcq]','2026-09-27 03:34:51',1259,'2026-10-05T13:33:57.163Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1155,'ExponentPushToken[H3VmShFfGbFHrDDmaQGcd9]','2026-09-27 04:28:20',1261,'2026-10-09T12:09:03.077Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1156,'ExponentPushToken[RNP4FZNLcX77qQR4HTZbD6]','2026-09-27 04:35:24',1262,'2026-10-12T05:17:08.996Z'); @@ -3949,11 +3959,11 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1183,'ExponentPushToken[YqTvn4OCS3sf5UNuYGHdfC]','2026-10-02 03:09:59',988,'2026-10-03T15:14:46.226Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1184,'ExponentPushToken[4dMyItFoZPR9MiLxNrIKqz]','2026-10-02 03:37:50',1288,'2026-10-10T12:53:20.136Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1185,'ExponentPushToken[4PvgQAObU_b4Z_I2lSyL8g]','2026-10-02 05:07:34',992,'2026-10-02T05:07:33.999Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1186,'ExponentPushToken[FSNk6WM1J7U1Jvja48EHsE]','2026-10-02 08:38:31',1289,'2026-10-13T01:13:15.920Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1186,'ExponentPushToken[FSNk6WM1J7U1Jvja48EHsE]','2026-10-02 08:38:31',1289,'2026-10-14T12:48:52.873Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1187,'ExponentPushToken[iXaOH8D5iAsn6lh66GuWRa]','2026-10-02 12:51:37',1290,'2026-10-05T01:03:11.369Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1188,'ExponentPushToken[ycucWsL8Ci-AWWKiL6Na6R]','2026-10-03 02:19:44',1292,'2026-10-03T02:19:44.722Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1189,'ExponentPushToken[m4tPqTJay2E2_l8TrIEpJT]','2026-10-03 04:04:45',1293,'2026-10-05T11:14:48.980Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1190,'ExponentPushToken[Y7kb0KFKDbU4YiK6DTORKV]','2026-10-03 07:35:55',1291,'2026-10-13T07:44:07.092Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1190,'ExponentPushToken[Y7kb0KFKDbU4YiK6DTORKV]','2026-10-03 07:35:55',1291,'2026-10-14T14:28:06.195Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1191,'ExponentPushToken[iex6cpCl0n8JzF4Zu-VTTY]','2026-10-03 08:05:45',1295,'2026-10-06T18:09:08.740Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1192,'ExponentPushToken[gv4jP3Gd6hSD0r2rU86quf]','2026-10-03 11:30:28',1296,'2026-10-10T15:36:33.612Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1193,'ExponentPushToken[sAknjMCm2jKoeWHqDX7z9C]','2026-10-03 11:32:22',1004,'2026-10-09T11:21:57.442Z'); @@ -3976,13 +3986,15 @@ INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VA INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1210,'ExponentPushToken[TCnjITJlPN71tJcOv2lGG1]','2026-10-10 10:54:38',1315,'2026-10-11T10:06:46.413Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1211,'ExponentPushToken[WQ11irFvYIR6nJbqV3isVL]','2026-10-10 16:55:13',1316,'2026-10-11T05:01:18.023Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1212,'ExponentPushToken[DtDZaYDoZ_TwpWVnbF733T]','2026-10-11 02:11:24',1205,'2026-10-11T02:11:24.376Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1213,'ExponentPushToken[nLYwtpFq3SAzUAEEV1HTPu]','2026-10-11 03:02:24',1317,'2026-10-11T03:02:24.222Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1213,'ExponentPushToken[nLYwtpFq3SAzUAEEV1HTPu]','2026-10-11 03:02:24',1317,'2026-10-14T12:54:40.531Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1214,'ExponentPushToken[_BXZshK2lSQuRCICuLTHiD]','2026-10-11 05:12:17',1318,'2026-10-11T05:12:17.723Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1215,'ExponentPushToken[m60i1MPwY_u8XMTFEHSQSm]','2026-10-11 17:14:19',1319,'2026-10-11T17:14:19.431Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1216,'ExponentPushToken[dQOhbqI5Xa2oazaM-X-FcN]','2026-10-13 00:54:25',1215,'2026-10-13T00:54:25.140Z'); -INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1217,'ExponentPushToken[_DdgjbH_6x9XoI59oucbpZ]','2026-10-13 04:12:36',1262,'2026-10-13T06:21:42.193Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1217,'ExponentPushToken[_DdgjbH_6x9XoI59oucbpZ]','2026-10-13 04:12:36',1262,'2026-10-13T15:41:14.199Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1218,'ExponentPushToken[yS7eULOnCceMkCw8zIMKNP]','2026-10-13 11:37:57',1322,'2026-10-13T11:43:19.742Z'); INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1219,'ExponentPushToken[cADwQ4JvLmXE02gVoxhvlS]','2026-10-13 12:39:59',1320,'2026-10-13T12:39:59.028Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1220,'ExponentPushToken[_gF_qFBYc7YinC6FdbIcSb]','2026-10-14 05:49:39',1324,'2026-10-14T05:52:03.363Z'); +INSERT INTO "notif_creds" ("id","token","added_at","user_id","last_verified") VALUES(1221,'ExponentPushToken[pBXUVdCgcZ7j4qYRCZppUY]','2026-10-14 07:02:00',1325,'2026-10-14T07:02:00.866Z'); CREATE TABLE IF NOT EXISTS "notifications" ("id" INTEGER PRIMARY KEY, "user_id" INTEGER NOT NULL, "title" TEXT NOT NULL, "body" TEXT NOT NULL, "type" TEXT, "is_read" INTEGER NOT NULL DEFAULT false, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP); CREATE TABLE IF NOT EXISTS "order_status" ("id" INTEGER PRIMARY KEY, "order_time" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "user_id" INTEGER NOT NULL, "order_id" INTEGER NOT NULL, "is_packaged" INTEGER NOT NULL DEFAULT false, "is_delivered" INTEGER NOT NULL DEFAULT false, "is_cancelled" INTEGER NOT NULL DEFAULT false, "cancel_reason" TEXT, "payment_state" TEXT NOT NULL DEFAULT 'pending', "cancellation_user_notes" TEXT, "cancellation_admin_notes" TEXT, "cancellation_reviewed" INTEGER NOT NULL DEFAULT false, "cancellation_reviewed_at" TEXT, "refund_coupon_id" INTEGER, "is_cancelled_by_admin" INTEGER); INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(105,'2025-12-24T02:50:33.284Z',22,105,0,0,1,'E','cod','E',NULL,0,NULL,NULL,NULL); @@ -6357,6 +6369,20 @@ INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged" INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2535,'2026-10-13 10:01:36',414,2541,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2536,'2026-10-13 11:39:57',1322,2542,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2537,'2026-10-13 12:49:04',1063,2543,0,0,1,'Order by mistake ','cod','Order by mistake ',NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2538,'2026-10-13 13:13:46',1136,2544,0,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2539,'2026-10-13 13:17:45',1145,2545,0,0,1,'We won''t ','cod','We won''t ',NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2540,'2026-10-13 14:36:53',1258,2546,0,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2541,'2026-10-13 18:44:02',1294,2547,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2542,'2026-10-14 01:56:54',178,2548,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2543,'2026-10-14 03:14:46',785,2549,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2544,'2026-10-14 03:18:00',494,2550,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2545,'2026-10-14 03:18:00',494,2551,0,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2546,'2026-10-14 04:12:52',82,2552,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2547,'2026-10-14 05:12:05',230,2553,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2548,'2026-10-14 06:59:37',115,2554,0,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2549,'2026-10-14 07:10:28',499,2555,0,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2550,'2026-10-14 07:30:54',785,2556,1,1,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); +INSERT INTO "order_status" ("id","order_time","user_id","order_id","is_packaged","is_delivered","is_cancelled","cancel_reason","payment_state","cancellation_user_notes","cancellation_admin_notes","cancellation_reviewed","cancellation_reviewed_at","refund_coupon_id","is_cancelled_by_admin") VALUES(2551,'2026-10-14 12:18:56',816,2557,0,0,0,NULL,'cod',NULL,NULL,0,NULL,NULL,NULL); CREATE TABLE IF NOT EXISTS "orders" ("id" INTEGER PRIMARY KEY, "user_id" INTEGER NOT NULL, "address_id" INTEGER NOT NULL, "slot_id" INTEGER, "total_amount" REAL NOT NULL, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "is_cod" INTEGER NOT NULL DEFAULT false, "is_online_payment" INTEGER NOT NULL DEFAULT false, "payment_info_id" INTEGER, "readable_id" INTEGER NOT NULL, "admin_notes" TEXT, "user_notes" TEXT, "delivery_charge" REAL NOT NULL DEFAULT '0', "order_group_id" TEXT, "order_group_proportion" REAL, "is_flash_delivery" INTEGER NOT NULL DEFAULT false, `delivered_at` text); INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(105,22,31,9,7700,'2025-12-24T02:50:33.284Z',1,0,NULL,147,NULL,NULL,0,NULL,NULL,0,NULL); INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(106,15,24,8,92,'2025-12-24T10:32:01.957Z',1,0,NULL,149,NULL,NULL,20,NULL,NULL,0,NULL); @@ -8736,6 +8762,20 @@ INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","crea INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2541,414,308,2054,235,'2026-10-13 10:01:36',1,0,NULL,-1,NULL,NULL,15,'1791885696733-414',1,0,NULL); INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2542,1322,883,NULL,191,'2026-10-13 11:39:57',1,0,NULL,-1,NULL,NULL,39,'1791891597063-1322',1,1,NULL); INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2543,1063,701,2056,167,'2026-10-13 12:49:04',1,0,NULL,-1,NULL,NULL,15,'1791895744153-1063',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2544,1136,884,NULL,281,'2026-10-13 13:13:46',1,0,NULL,-1,NULL,NULL,39,'1791897226774-1136',1,1,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2545,1145,749,2060,214,'2026-10-13 13:17:45',1,0,NULL,-1,NULL,NULL,15,'1791897465684-1145',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2546,1258,836,2057,600,'2026-10-13 14:36:53',1,0,NULL,-1,NULL,NULL,0,'1791902212849-1258',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2547,1294,866,2058,843,'2026-10-13 18:44:02',1,0,NULL,-1,NULL,NULL,0,'1791917042417-1294',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2548,178,812,2058,250,'2026-10-14 01:56:54',1,0,NULL,-1,NULL,NULL,15,'1791943014091-178',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2549,785,574,2059,399,'2026-10-14 03:14:46',1,0,NULL,-1,NULL,NULL,0,'1791947686056-785',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2550,494,369,2060,235,'2026-10-14 03:18:00',1,0,NULL,-1,NULL,NULL,0,'1791947879281-494',0.8392857142857143,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2551,494,369,2059,45,'2026-10-14 03:18:00',1,0,NULL,-1,NULL,NULL,0,'1791947879281-494',0.16071428571428573,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2552,82,72,2059,1350,'2026-10-14 04:12:52',1,0,NULL,-1,NULL,NULL,0,'1791951172031-82',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2553,230,174,2059,236,'2026-10-14 05:12:05',1,0,NULL,-1,NULL,NULL,15,'1791954725418-230',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2554,115,189,2061,595,'2026-10-14 06:59:37',1,0,NULL,-1,NULL,NULL,0,'1791961177232-115',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2555,499,861,NULL,423,'2026-10-14 07:10:28',1,0,NULL,-1,NULL,NULL,0,'1791961825979-499',1,1,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2556,785,574,2061,305,'2026-10-14 07:30:54',1,0,NULL,-1,NULL,'Leg piece only ',0,'1791963054189-785',1,0,NULL); +INSERT INTO "orders" ("id","user_id","address_id","slot_id","total_amount","created_at","is_cod","is_online_payment","payment_info_id","readable_id","admin_notes","user_notes","delivery_charge","order_group_id","order_group_proportion","is_flash_delivery","delivered_at") VALUES(2557,816,595,2065,152,'2026-10-14 12:18:55',1,0,NULL,-1,NULL,NULL,15,'1791980334624-816',1,0,NULL); CREATE TABLE IF NOT EXISTS "payment_info" ("id" INTEGER PRIMARY KEY, "status" TEXT NOT NULL, "gateway" TEXT NOT NULL, "order_id" TEXT, "token" TEXT, "merchant_order_id" TEXT NOT NULL, "payload" TEXT); INSERT INTO "payment_info" ("id","status","gateway","order_id","token","merchant_order_id","payload") VALUES(1,'pending','phonepe',NULL,NULL,'order_1763563896010',NULL); INSERT INTO "payment_info" ("id","status","gateway","order_id","token","merchant_order_id","payload") VALUES(2,'pending','phonepe',NULL,NULL,'order_1763564910006',NULL); @@ -9080,6 +9120,7 @@ INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(284,2479,NULL,'na',NULL,NULL,'2026-10-09 02:05:52'); INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(285,2536,NULL,'na',NULL,NULL,'2026-10-13 07:24:14'); INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(286,2543,NULL,'na',NULL,NULL,'2026-10-13 12:49:41'); +INSERT INTO "refunds" ("id","order_id","refund_amount","refund_status","merchant_refund_id","refund_processed_at","created_at") VALUES(287,2545,NULL,'na',NULL,NULL,'2026-10-13 13:30:01'); CREATE TABLE IF NOT EXISTS "reserved_coupons" ("id" INTEGER PRIMARY KEY, "secret_code" TEXT NOT NULL, "coupon_code" TEXT NOT NULL, "discount_percent" REAL, "flat_discount" REAL, "min_order" REAL, "sku_ids" TEXT, "max_value" REAL, "valid_till" TEXT, "max_limit_for_user" INTEGER, "exclusive_apply" INTEGER NOT NULL DEFAULT false, "is_redeemed" INTEGER NOT NULL DEFAULT false, "redeemed_by" INTEGER, "redeemed_at" TEXT, "created_by" INTEGER NOT NULL, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, `is_first_order_only` integer DEFAULT false NOT NULL); INSERT INTO "reserved_coupons" ("id","secret_code","coupon_code","discount_percent","flat_discount","min_order","sku_ids","max_value","valid_till","max_limit_for_user","exclusive_apply","is_redeemed","redeemed_by","redeemed_at","created_by","created_at","is_first_order_only") VALUES(1,'RESERVE_TEST34','RESERVE_TEST34',25,NULL,1000,'[]',250,'2026-01-30T13:16:00.000Z',2,0,1,NULL,'2026-01-12T08:58:20.468Z',6,'2026-01-07T13:16:53.387Z',0); INSERT INTO "reserved_coupons" ("id","secret_code","coupon_code","discount_percent","flat_discount","min_order","sku_ids","max_value","valid_till","max_limit_for_user","exclusive_apply","is_redeemed","redeemed_by","redeemed_at","created_by","created_at","is_first_order_only") VALUES(2,'TEST50OFF','TEST50OFF',10,NULL,250,'[]',500,'2026-08-13T02:30:00.000Z',1,0,1,6,'2026-08-12T16:15:10.211Z',4,'2026-08-12 16:14:27',0); @@ -10133,7 +10174,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(576,'ExponentPushToken[hWDq-zJM-L5Vs59H9Js_BM]','2026-05-01 14:50:56','2026-05-01T14:50:56.287Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(577,'ExponentPushToken[ceIV-PNdap0wS3OWZNxxvd]','2026-05-02 03:14:45','2026-05-02T04:33:43.783Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(578,'ExponentPushToken[4QHIzADKKkWhxXjUd6aznx]','2026-05-03 02:50:35','2026-05-05T04:54:11.719Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(580,'ExponentPushToken[2KeIQoIW7_xfYnmYKLjIxX]','2026-05-03 06:59:21','2026-10-11T02:20:15.066Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(580,'ExponentPushToken[2KeIQoIW7_xfYnmYKLjIxX]','2026-05-03 06:59:21','2026-10-14T02:33:12.531Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(581,'ExponentPushToken[5fX4CmG9w3GtaxvHBEgag-]','2026-05-03 12:37:40','2026-06-30T04:20:16.010Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(582,'ExponentPushToken[QYuKk4PXPchUd3OcWN00x8]','2026-05-03 15:25:57','2026-05-08T06:38:49.961Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(585,'ExponentPushToken[WoQXlUKe6j_G0F6lm1JsCt]','2026-05-04 07:32:29','2026-05-04T07:32:29.494Z'); @@ -10656,7 +10697,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1252,'ExponentPushToken[DN3AShCb0_73Nhp3i7jrjV]','2026-08-16 13:04:14','2026-08-16T13:04:14.701Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1253,'ExponentPushToken[CxJuifGWZ_lzGezVWMzshF]','2026-08-16 13:09:38','2026-08-28T08:58:42.213Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1258,'ExponentPushToken[P6QXRSLm_aixcMSpRb0ccM]','2026-08-17 11:12:12','2026-08-17T11:12:12.707Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1259,'ExponentPushToken[OUHHZDAcdmpUwkHVo6sX1T]','2026-08-18 06:24:11','2026-09-11T15:47:27.462Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1259,'ExponentPushToken[OUHHZDAcdmpUwkHVo6sX1T]','2026-08-18 06:24:11','2026-10-14T10:43:05.129Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1261,'ExponentPushToken[6dpCTAK7Zbaar7mx8KZEQG]','2026-08-18 10:12:50','2026-08-18T10:12:50.211Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1267,'ExponentPushToken[fz2v0-PfOOdQ11TcRYtTA-]','2026-08-19 08:27:17','2026-08-21T06:50:31.442Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1268,'ExponentPushToken[Hgm74YBYAsld_iU-xraKxM]','2026-08-19 08:28:37','2026-08-19T08:28:37.533Z'); @@ -10668,7 +10709,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1280,'ExponentPushToken[V-z0e8LVq3YU6pShKJvknE]','2026-08-21 09:29:20','2026-08-21T09:29:20.159Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1282,'ExponentPushToken[PbLJJ1Lqf7UBNKmz_SVJF7]','2026-08-21 13:47:45','2026-08-23T06:13:02.706Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1284,'ExponentPushToken[urXu7YJ1McDAhgY1bNbI0y]','2026-08-22 03:37:53','2026-08-22T03:37:53.505Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1287,'ExponentPushToken[Q6fBNXEvr9jidD5bAL6eIh]','2026-08-23 21:29:59','2026-08-23T21:29:59.121Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1287,'ExponentPushToken[Q6fBNXEvr9jidD5bAL6eIh]','2026-08-23 21:29:59','2026-10-13T17:29:19.896Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1288,'ExponentPushToken[ccQc_uEZmHOaLHDUKzSd_E]','2026-08-24 13:33:42','2026-08-26T15:42:54.789Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1292,'ExponentPushToken[BNSHMfHe9MQb-BxS_g7x74]','2026-08-25 14:59:50','2026-09-03T07:24:42.065Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1295,'ExponentPushToken[qbOBFrCA4SODinKxsp1-Nj]','2026-08-26 08:47:41','2026-09-11T05:00:46.829Z'); @@ -10898,7 +10939,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1632,'ExponentPushToken[vHVNO3OoQQdLisFiVTvo34]','2026-09-11 15:58:43','2026-09-20T15:53:48.636Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1634,'ExponentPushToken[BME07FMFSbBDh2nrM0yxWH]','2026-09-11 16:00:24','2026-09-22T06:37:31.895Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1637,'ExponentPushToken[vNJ-QVNViKkyPbJD69Nn9c]','2026-09-11 16:01:35','2026-09-13T03:02:29.686Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1639,'ExponentPushToken[tYr9UZNsvRGr2F2Lr0l6yZ]','2026-09-11 16:02:16','2026-10-11T09:53:50.604Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1639,'ExponentPushToken[tYr9UZNsvRGr2F2Lr0l6yZ]','2026-09-11 16:02:16','2026-10-13T16:09:54.994Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1641,'ExponentPushToken[JO8VOFLx1zagNKxXS9bgYc]','2026-09-11 16:02:37','2026-09-11T16:02:37.941Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1642,'ExponentPushToken[-KFqDsP-HC2Q-0s6Fc-Ipy]','2026-09-11 16:03:37','2026-09-15T14:32:12.599Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1645,'ExponentPushToken[dg-_wDCEwufWZx4CxFHRTG]','2026-09-11 16:05:59','2026-10-06T09:28:09.270Z'); @@ -10970,7 +11011,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1737,'ExponentPushToken[VNBDfcNYuLgd8HnBvUckJP]','2026-09-11 18:32:15','2026-09-12T03:15:07.051Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1738,'ExponentPushToken[Lc1aiGJb6K_ZgghBqikBc9]','2026-09-11 18:39:09','2026-09-11T18:39:09.249Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1739,'ExponentPushToken[-G9h8FLQ4623URB19UdMO0]','2026-09-11 18:40:20','2026-09-11T18:40:20.588Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1741,'ExponentPushToken[vbiRaKMOvzgPU5FmGA-FJS]','2026-09-11 18:46:13','2026-09-14T06:14:25.106Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1741,'ExponentPushToken[vbiRaKMOvzgPU5FmGA-FJS]','2026-09-11 18:46:13','2026-10-13T19:21:19.808Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1742,'ExponentPushToken[-STT_6OXE_VGPmkDyd6d2p]','2026-09-11 18:55:51','2026-09-11T18:55:51.645Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1743,'ExponentPushToken[18dx3-IGcOpP4YRacqhHaX]','2026-09-11 19:00:17','2026-09-11T19:00:17.246Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1745,'ExponentPushToken[PVHO9bPjJsEzqz78_bkgFS]','2026-09-11 19:12:19','2026-09-11T19:12:19.048Z'); @@ -11005,7 +11046,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1782,'ExponentPushToken[hm2m15MKRD4d2-tdzRt5gt]','2026-09-12 01:39:46','2026-09-12T01:39:46.755Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1783,'ExponentPushToken[E9sIOQLkdxRyW6wGIU-jlR]','2026-09-12 01:40:10','2026-09-12T03:25:47.117Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1785,'ExponentPushToken[2s238hCCzQIzEC3nnk1YGY]','2026-09-12 01:43:46','2026-09-12T01:43:46.041Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1786,'ExponentPushToken[1ZW7l1F_gtvooempuUjRO5]','2026-09-12 01:49:07','2026-10-07T05:54:24.793Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1786,'ExponentPushToken[1ZW7l1F_gtvooempuUjRO5]','2026-09-12 01:49:07','2026-10-14T03:14:36.668Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1788,'ExponentPushToken[2V25ZQB3JhkpSGqJmhpZEk]','2026-09-12 01:59:44','2026-09-12T01:59:44.011Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1789,'ExponentPushToken[3ag3jYJZRVZ_g99wkBueuJ]','2026-09-12 02:02:11','2026-09-12T02:02:11.728Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(1790,'ExponentPushToken[AkSlKjNmjj68Rhaaeu66Zq]','2026-09-12 02:05:49','2026-09-12T11:25:37.127Z'); @@ -11181,7 +11222,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2019,'ExponentPushToken[r096lxKzJqBfDnPaDsbzUH]','2026-09-12 18:08:31','2026-09-13T02:10:22.417Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2020,'ExponentPushToken[9_nT4-PA-3iihAYY7xW7SZ]','2026-09-12 18:30:10','2026-10-13T09:47:38.142Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2021,'ExponentPushToken[cAMXwxMEnO1FVRPhcwm3il]','2026-09-12 21:13:18','2026-09-12T21:13:18.330Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2022,'ExponentPushToken[Tv_b_iD62s7yV5bI4yvlHd]','2026-09-13 00:01:00','2026-09-13T00:01:00.398Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2022,'ExponentPushToken[Tv_b_iD62s7yV5bI4yvlHd]','2026-09-13 00:01:00','2026-10-14T10:28:09.775Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2024,'ExponentPushToken[6bYAVRFRbNFKNjfUtjBX0f]','2026-09-13 02:10:21','2026-10-10T04:48:58.565Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2025,'ExponentPushToken[Jzlu_BM-1achYZkSqqFcvC]','2026-09-13 02:39:54','2026-09-13T02:39:54.313Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2026,'ExponentPushToken[mO-cXYP174VhxBZf1pcAFO]','2026-09-13 02:47:16','2026-09-13T02:47:16.966Z'); @@ -11368,7 +11409,7 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2252,'ExponentPushToken[FwHIfMLzmfkBBtAhjVFbYl]','2026-09-24 15:11:54','2026-09-24T15:11:54.029Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2253,'ExponentPushToken[wT4Ys6O310Bwy2KHBZyTpy]','2026-09-25 02:41:17','2026-09-25T02:41:17.163Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2254,'ExponentPushToken[stR7dyIbx3l2o97oWS8vLV]','2026-09-25 03:00:15','2026-09-25T03:00:15.853Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2255,'ExponentPushToken[dLKhX5Ox4wHTywsUplzJWe]','2026-09-25 08:30:36','2026-09-28T14:24:07.029Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2255,'ExponentPushToken[dLKhX5Ox4wHTywsUplzJWe]','2026-09-25 08:30:36','2026-10-14T12:06:43.976Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2256,'ExponentPushToken[d7ZlnMAM9_Al3hsl26j2_Y]','2026-09-25 10:58:29','2026-09-25T10:58:29.620Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2257,'ExponentPushToken[EK8crzF5tdn9HfnPOT9H9D]','2026-09-25 11:46:34','2026-09-25T11:46:42.317Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2258,'ExponentPushToken[9SAti5Ixbjd14aawos1PQL]','2026-09-25 13:28:44','2026-09-30T14:04:08.355Z'); @@ -11454,8 +11495,13 @@ INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VAL INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2348,'ExponentPushToken[jh9OpsBESTlmoufy0PYJIi]','2026-10-11 17:08:24','2026-10-11T17:08:24.135Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2349,'ExponentPushToken[tBmqsUG-rRzp86sn13MGqG]','2026-10-12 05:43:03','2026-10-12T05:43:03.123Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2350,'ExponentPushToken[E8zmZIOr5954A7jmCnvmy-]','2026-10-12 06:34:02','2026-10-12T06:34:01.990Z'); -INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2352,'ExponentPushToken[MoHqpvOqYdvNcJVwySrR35]','2026-10-12 16:41:06','2026-10-13T06:21:42.119Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2352,'ExponentPushToken[MoHqpvOqYdvNcJVwySrR35]','2026-10-12 16:41:06','2026-10-13T14:06:50.033Z'); INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2353,'ExponentPushToken[aITcTXM3kUTvLkCku51RVY]','2026-10-13 01:09:38','2026-10-13T01:09:38.688Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2354,'ExponentPushToken[oVlx4lOzXHflUavRWxGcH4]','2026-10-14 01:27:54','2026-10-14T01:27:54.416Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2356,'ExponentPushToken[fx_Z4hJDBIhccI36Sd-7ZV]','2026-10-14 05:48:40','2026-10-14T05:48:40.302Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2357,'ExponentPushToken[uN7Q2SJXcDEsKhYeb2PeVF]','2026-10-14 11:33:41','2026-10-14T11:33:41.784Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2358,'ExponentPushToken[T6VyuGAkKtOnyMGSwa1XuM]','2026-10-14 11:55:18','2026-10-14T11:55:18.566Z'); +INSERT INTO "unlogged_user_tokens" ("id","token","added_at","last_verified") VALUES(2359,'ExponentPushToken[d75jOiFseYEe8N39v2XSV-]','2026-10-14 13:44:19','2026-10-14T13:44:19.755Z'); CREATE TABLE IF NOT EXISTS "upload_url_status" ("id" INTEGER PRIMARY KEY, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "key" TEXT NOT NULL, "status" TEXT NOT NULL DEFAULT 'pending'); INSERT INTO "upload_url_status" ("id","created_at","key","status") VALUES(35,'2025-12-07T08:58:13.136Z','review-images/1765097892914.jpg','pending'); INSERT INTO "upload_url_status" ("id","created_at","key","status") VALUES(36,'2025-12-07T08:58:13.347Z','review-images/1765097893129.png','pending'); @@ -13143,6 +13189,9 @@ INSERT INTO "users" ("id","name","email","mobile","created_at") VALUES(1319,NULL INSERT INTO "users" ("id","name","email","mobile","created_at") VALUES(1320,NULL,NULL,'9177185837','2026-10-12 13:33:27'); INSERT INTO "users" ("id","name","email","mobile","created_at") VALUES(1321,NULL,NULL,'9603864717','2026-10-13 10:03:55'); INSERT INTO "users" ("id","name","email","mobile","created_at") VALUES(1322,NULL,NULL,'9966770420','2026-10-13 11:37:55'); +INSERT INTO "users" ("id","name","email","mobile","created_at") VALUES(1323,NULL,NULL,'9392351189','2026-10-14 05:48:44'); +INSERT INTO "users" ("id","name","email","mobile","created_at") VALUES(1324,NULL,NULL,'6303905300','2026-10-14 05:49:38'); +INSERT INTO "users" ("id","name","email","mobile","created_at") VALUES(1325,NULL,NULL,'7619332531','2026-10-14 07:01:59'); CREATE TABLE IF NOT EXISTS "vendor_snippets" ("id" INTEGER PRIMARY KEY, "snippet_code" TEXT NOT NULL, "slot_id" INTEGER, "sku_ids" TEXT NOT NULL, "valid_till" TEXT, "created_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, "is_permanent" INTEGER NOT NULL DEFAULT false); INSERT INTO "vendor_snippets" ("id","snippet_code","slot_id","sku_ids","valid_till","created_at","is_permanent") VALUES(55,'Allvegetables1',NULL,'[88,66,70,64,91,19,71,27,79,32,5,65,45,77,74,17,16,72,33,13,89,29,78,30,69,31,76,90,18,68]','2027-01-27T17:56:00.000Z','2026-01-27T18:03:18.974Z',1); INSERT INTO "vendor_snippets" ("id","snippet_code","slot_id","sku_ids","valid_till","created_at","is_permanent") VALUES(56,'AllMuttonitems',NULL,'[34,85,14,87,35,84,28,86,4,12,99,98,20]','2027-03-31T02:51:00.000Z','2026-01-28T02:52:14.560Z',1); @@ -13712,7 +13761,7 @@ INSERT INTO "product_market_stats" ("id","sku_id","market_price","our_price","is INSERT INTO "product_market_stats" ("id","sku_id","market_price","our_price","is_flash_available","flash_price","is_out_of_stock","is_suspended") VALUES(73,73,'70.0','59.0',1,NULL,0,0); INSERT INTO "product_market_stats" ("id","sku_id","market_price","our_price","is_flash_available","flash_price","is_out_of_stock","is_suspended") VALUES(74,74,'35.0','29.0',0,'29.0',0,0); INSERT INTO "product_market_stats" ("id","sku_id","market_price","our_price","is_flash_available","flash_price","is_out_of_stock","is_suspended") VALUES(75,75,'599','529',0,'529',0,0); -INSERT INTO "product_market_stats" ("id","sku_id","market_price","our_price","is_flash_available","flash_price","is_out_of_stock","is_suspended") VALUES(76,76,'39.0','29.0',1,'39.0',0,0); +INSERT INTO "product_market_stats" ("id","sku_id","market_price","our_price","is_flash_available","flash_price","is_out_of_stock","is_suspended") VALUES(76,76,'39.0','35',1,'39.0',0,0); INSERT INTO "product_market_stats" ("id","sku_id","market_price","our_price","is_flash_available","flash_price","is_out_of_stock","is_suspended") VALUES(77,77,'20.0','15.0',0,'15.0',0,0); INSERT INTO "product_market_stats" ("id","sku_id","market_price","our_price","is_flash_available","flash_price","is_out_of_stock","is_suspended") VALUES(78,78,'30','25',1,'28',0,0); INSERT INTO "product_market_stats" ("id","sku_id","market_price","our_price","is_flash_available","flash_price","is_out_of_stock","is_suspended") VALUES(79,79,'47.0','39.0',1,NULL,1,0); @@ -22134,6 +22183,44 @@ INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discount INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8562,2541,45,'1','23','23',1,0,NULL); INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8563,2542,23,'1','152','152',1,0,NULL); INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8564,2543,23,'1','152','152',0,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8565,2544,23,'1','152','152',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8566,2544,45,'3','25','25',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8567,2544,71,'1','15.0','15.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8568,2545,136,'1','199','199',0,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8569,2546,9,'1','296.0','296.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8570,2546,23,'2','152','152',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8571,2547,80,'1','799','799',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8572,2547,101,'1','19.0','19.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8573,2547,78,'1','25','25',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8574,2548,24,'1','235','235',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8575,2549,82,'1','399','399',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8576,2550,24,'1','235','235',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8577,2551,144,'1','15','15',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8578,2551,19,'1','15.0','15.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8579,2551,71,'1','15.0','15.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8580,2552,99,'2','675','675',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8581,2553,23,'1','152','152',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8582,2553,18,'1','69','69',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8583,2554,23,'3','152','152',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8584,2554,37,'1','49.0','49.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8585,2554,71,'1','15.0','15.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8586,2554,76,'1','29.0','29.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8587,2554,45,'2','23','23',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8588,2555,23,'2','152','152',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8589,2555,144,'1','19','19',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8590,2555,72,'2','15.0','15.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8591,2555,69,'1','19.0','19.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8592,2555,65,'1','17.0','17.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8593,2555,71,'1','15.0','15.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8594,2555,19,'1','19.0','19.0',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8595,2556,137,'1','305','305',1,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8596,2557,30,'1','17.0','17.0',0,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8597,2557,31,'1','16','16',0,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8598,2557,45,'1','23','23',0,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8599,2557,95,'1','15.0','15.0',0,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8600,2557,94,'1','18','18',0,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8601,2557,103,'1','29.0','29.0',0,0,NULL); +INSERT INTO "order_items" ("id","order_id","sku_id","quantity","price","discounted_price","is_packaged","is_package_verified","packaged_at") VALUES(8602,2557,32,'1','19.0','19.0',0,0,NULL); CREATE TABLE IF NOT EXISTS "special_deals" ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `sku_id` integer NOT NULL, @@ -22572,15 +22659,15 @@ CREATE TABLE `staff_notif_creds` ( FOREIGN KEY (`staff_user_id`) REFERENCES `staff_users`(`id`) ON UPDATE no action ON DELETE no action ); INSERT INTO "staff_notif_creds" ("id","token","added_at","staff_user_id","last_verified") VALUES(1,'ExponentPushToken[HyU1kPNunSJaasQweODhvH]','2026-10-02 10:49:17',6,'2026-10-04T07:19:37.555Z'); -INSERT INTO "staff_notif_creds" ("id","token","added_at","staff_user_id","last_verified") VALUES(2,'ExponentPushToken[QydqxGMsUfzHuiqxel0nA9]','2026-10-02 10:49:27',4,'2026-10-13T11:41:10.722Z'); -INSERT INTO "staff_notif_creds" ("id","token","added_at","staff_user_id","last_verified") VALUES(3,'ExponentPushToken[bqqW02IeK4XcC4iuzpkQIG]','2026-10-05 01:28:42',4,'2026-10-13T11:08:49.256Z'); +INSERT INTO "staff_notif_creds" ("id","token","added_at","staff_user_id","last_verified") VALUES(2,'ExponentPushToken[QydqxGMsUfzHuiqxel0nA9]','2026-10-02 10:49:27',4,'2026-10-14T12:49:10.405Z'); +INSERT INTO "staff_notif_creds" ("id","token","added_at","staff_user_id","last_verified") VALUES(3,'ExponentPushToken[bqqW02IeK4XcC4iuzpkQIG]','2026-10-05 01:28:42',4,'2026-10-14T14:04:15.246Z'); DELETE FROM sqlite_sequence; INSERT INTO "sqlite_sequence" ("name","seq") VALUES('product_skus',150); INSERT INTO "sqlite_sequence" ("name","seq") VALUES('sku_features',182); INSERT INTO "sqlite_sequence" ("name","seq") VALUES('product_market_stats',150); INSERT INTO "sqlite_sequence" ("name","seq") VALUES('product_info',150); INSERT INTO "sqlite_sequence" ("name","seq") VALUES('cart_items',128); -INSERT INTO "sqlite_sequence" ("name","seq") VALUES('order_items',8564); +INSERT INTO "sqlite_sequence" ("name","seq") VALUES('order_items',8602); INSERT INTO "sqlite_sequence" ("name","seq") VALUES('special_deals',12); INSERT INTO "sqlite_sequence" ("name","seq") VALUES('coupon_applicable_products',1); INSERT INTO "sqlite_sequence" ("name","seq") VALUES('product_tags',604); diff --git a/apps/backend/src/trpc/apis/user-apis/apis/address.ts b/apps/backend/src/trpc/apis/user-apis/apis/address.ts index 5fb7eb4..3407836 100644 --- a/apps/backend/src/trpc/apis/user-apis/apis/address.ts +++ b/apps/backend/src/trpc/apis/user-apis/apis/address.ts @@ -13,6 +13,8 @@ import { deleteUserAddress as deleteUserAddressInDb, hasOngoingOrdersForAddress as hasOngoingOrdersForAddressInDb, getEffectiveBoundId as getEffectiveBoundIdInDb, + upsertUserRegion, + reconcileUserRegions, } from '@/src/dbService' import type { UserAddressResponse, @@ -114,6 +116,15 @@ export const addressRouter = router({ googleMapsUrl, }) + // Record the user<->region association for this address's region. Auxiliary + // and derived from the addresses, so a failure here must not fail the + // address write that already committed. + try { + await upsertUserRegion(userId, input.regionId, 'address') + } catch (error) { + console.error('[address.createAddress] user-region association failed', error) + } + return { success: true, data: newAddress } }), @@ -196,6 +207,15 @@ export const addressRouter = router({ vagueBackfilledCoords: coordsChanged ? false : existingAddress.vagueBackfilledCoords, }) + // The address may have moved region: reconcile the user's associations + // (insert the new region, drop an old one no other address uses). Best + // effort: the update above already committed. + try { + await reconcileUserRegions(userId) + } catch (error) { + console.error('[address.updateAddress] user-region reconcile failed', error) + } + return { success: true, data: updatedAddress } }), @@ -236,6 +256,14 @@ export const addressRouter = router({ throw new ApiError('Address not found or does not belong to user', 404) } + // The address's region may no longer be backed by any address. Best + // effort: the delete above already committed. + try { + await reconcileUserRegions(userId) + } catch (error) { + console.error('[address.deleteAddress] user-region reconcile failed', error) + } + return { success: true, message: 'Address deleted successfully' } }), }); diff --git a/apps/backend/src/trpc/apis/user-apis/apis/user.ts b/apps/backend/src/trpc/apis/user-apis/apis/user.ts index 70e8676..282446d 100644 --- a/apps/backend/src/trpc/apis/user-apis/apis/user.ts +++ b/apps/backend/src/trpc/apis/user-apis/apis/user.ts @@ -11,10 +11,12 @@ import { deleteUserUnloggedToken as deleteUserUnloggedTokenInDb, getUserUnloggedToken as getUserUnloggedTokenInDb, upsertUserUnloggedToken as upsertUserUnloggedTokenInDb, + upsertUserRegion as upsertUserRegionInDb, } from '@/src/dbService' import type { UserSelfDataResponse, UserSavePushTokenResponse, + BasicSuccessResponse, } from '@packages/shared' const generateToken = async (userId: number): Promise => { @@ -68,28 +70,61 @@ export const userRouter = router({ }), savePushToken: publicProcedure - .input(z.object({ token: z.string() })) + .input(z.object({ + token: z.string(), + // The caller's current region. Nullable/optional: a token is often + // registered before any region is known. + regionId: z.number().int().positive().nullable().optional(), + })) .mutation(async ({ input, ctx }): Promise => { - const { token } = input; + const { token, regionId } = input; const userId = ctx.user?.userId; if (userId) { // AUTHENTICATED USER - // Check if token exists in notif_creds for this user - await upsertUserNotifCredInDb(userId, token) + // The region is auxiliary: it must never stop the token from being + // registered. Carry a region captured while signed out onto the account's + // creds unless this call already carries one. + let effectiveRegionId: number | null = regionId ?? null + if (effectiveRegionId == null) { + try { + effectiveRegionId = (await getUserUnloggedTokenInDb(token))?.regionId ?? null + } catch (error) { + console.error('[user.savePushToken] reading the signed-out region failed', error) + } + } + + try { + await upsertUserNotifCredInDb(userId, token, effectiveRegionId) + } catch (error) { + // e.g. notif_creds.region_id is not migrated yet — store the token anyway. + console.error('[user.savePushToken] storing the region failed; saving the token without it', error) + await upsertUserNotifCredInDb(userId, token) + } await deleteUserUnloggedTokenInDb(token) } else { // UNAUTHENTICATED USER - // Save/update in unlogged_user_tokens - const existing = await getUserUnloggedTokenInDb(token) - if (existing) { - await upsertUserUnloggedTokenInDb(token) - } else { + try { + await upsertUserUnloggedTokenInDb(token, regionId ?? null) + } catch (error) { + console.error('[user.savePushToken] storing the signed-out region failed; saving the token without it', error) await upsertUserUnloggedTokenInDb(token) } } return { success: true } }), + + /** + * Records that the device location resolved to `regionId`, associating the + * user with that region independently of their addresses. Used when the app + * takes a location fix but the user has no address there yet. + */ + recordTrackedRegion: protectedProcedure + .input(z.object({ regionId: z.number().int().positive() })) + .mutation(async ({ input, ctx }): Promise => { + await upsertUserRegionInDb(ctx.user.userId, input.regionId, 'location') + return { success: true } + }), }); diff --git a/apps/user-ui/app/_layout.tsx b/apps/user-ui/app/_layout.tsx index 450ded5..d15928c 100755 --- a/apps/user-ui/app/_layout.tsx +++ b/apps/user-ui/app/_layout.tsx @@ -27,6 +27,7 @@ import WebViewWrapper from "@/components/WebViewWrapper"; import BackHandlerWrapper from "@/components/BackHandler"; import AddToCartDialog from "@/src/components/AddToCartDialog"; import PendingAddressSync from "@/src/components/PendingAddressSync"; +import NotifRegionSync from "@/src/components/NotifRegionSync"; import LocationTestWrapper from "@/components/LocationTestWrapper"; import React from "react"; import { GestureHandlerRootView } from "react-native-gesture-handler"; @@ -76,6 +77,7 @@ export default function RootLayout() { + diff --git a/apps/user-ui/src/components/NotifRegionSync.tsx b/apps/user-ui/src/components/NotifRegionSync.tsx new file mode 100644 index 0000000..a315859 --- /dev/null +++ b/apps/user-ui/src/components/NotifRegionSync.tsx @@ -0,0 +1,62 @@ +import React, { useEffect, useRef } from 'react' +import { trpc } from '@/src/trpc-client' +import { useRegion } from '@/src/hooks/useRegion' +import { useNotification } from '@/services/notif-service/notif-context' + +/** + * Keeps the region stored alongside the push credentials in step with the user's + * region, and records a location-derived user<->region association. + * + * It renders inside NotificationProvider (see app/_layout.tsx), which is the + * only place the push token is available. Both ways a region becomes known land + * here: + * - a tracked device location — useRegion resolves it (and `bound` is set only + * for that path), or + * - an added address (incl. the signed-out local draft) — the location + * fallback switches the region, which clears the gate and mounts this + * component with the new region already in place. + * + * The region is carried with the push token, so the notif-creds API stores it + * (nullable) for whichever token the device registered. + */ +const NotifRegionSync: React.FC = () => { + const { expoPushToken, notifPermission } = useNotification() + const { regionId, bound } = useRegion() + // Both calls are best-effort telemetry for notifications: a failure is logged + // and ignored, never surfaced or retried. + const savePushToken = trpc.user.user.savePushToken.useMutation({ + onError: (error) => + console.error('[NotifRegionSync] saving the region with the push token failed', error), + }) + const recordTrackedRegion = trpc.user.user.recordTrackedRegion.useMutation({ + onError: (error) => + console.error('[NotifRegionSync] recording the tracked region failed', error), + }) + + // Guards against re-sending for the same (token, region, source). + const lastSynced = useRef(null) + + const savePushTokenMutate = savePushToken.mutate + const recordTrackedRegionMutate = recordTrackedRegion.mutate + + useEffect(() => { + if (!expoPushToken || notifPermission !== 'granted' || regionId == null) return + + const fromLocation = bound != null + const key = `${expoPushToken}:${regionId}:${fromLocation ? 'loc' : 'addr'}` + if (lastSynced.current === key) return + lastSynced.current = key + + savePushTokenMutate({ token: expoPushToken, regionId }) + + // `bound` is set only when the region came from the device fix, so this is + // exactly the "location was tracked" case. + if (fromLocation) { + recordTrackedRegionMutate({ regionId }) + } + }, [expoPushToken, notifPermission, regionId, bound, savePushTokenMutate, recordTrackedRegionMutate]) + + return null +} + +export default NotifRegionSync diff --git a/apps/user-ui/tests/components/notif-region-sync.test.tsx b/apps/user-ui/tests/components/notif-region-sync.test.tsx new file mode 100644 index 0000000..49f5da0 --- /dev/null +++ b/apps/user-ui/tests/components/notif-region-sync.test.tsx @@ -0,0 +1,98 @@ +/** + * NotifRegionSync — carries the browsing region with the push token and records a + * location-derived user<->region association. + * + * The notification context and useRegion are mocked so the test drives the + * token/region directly; the tRPC layer is real against the fetch stub, so the + * outbound mutation input is asserted. + */ + +import React from 'react' +import { waitFor } from '@testing-library/react-native' + +import NotifRegionSync from '@/src/components/NotifRegionSync' +import { useRegion } from '@/src/hooks/useRegion' +import { setupApiMocks } from '../mocks/api' +import { lastProcedureInput, procedureCalls } from '../mocks/procedures' +import { renderWithProviders } from '../helpers/render' + +jest.mock('@/services/notif-service/notif-context', () => ({ + useNotification: () => ({ + expoPushToken: 'ExponentPushToken[test]', + notifPermission: 'granted', + notification: null, + error: null, + }), +})) + +jest.mock('@/src/hooks/useRegion', () => ({ useRegion: jest.fn() })) + +const mockedUseRegion = useRegion as unknown as jest.Mock + +const regionValue = (over: Record = {}) => ({ + region: null, + regionId: 1, + boundId: null, + bound: null, + regionGeneration: 0, + hydrated: true, + coords: null, + locationStatus: 'idle', + isResolvingRegion: false, + setRegion: jest.fn(), + clearRegion: jest.fn(), + refreshLocation: jest.fn(), + ...over, +}) + +const procedures = { + 'user.user.savePushToken': { success: true }, + 'user.user.recordTrackedRegion': { success: true }, +} + +const renderSync = () => + renderWithProviders(, { centralStores: false }) + +describe('NotifRegionSync', () => { + it('sends the region with the push token, without a tracked-region call for an address-derived region', async () => { + mockedUseRegion.mockReturnValue(regionValue({ regionId: 1, bound: null })) + const api = setupApiMocks({ procedures }) + + renderSync() + + await waitFor(() => + expect(lastProcedureInput(api.fetchMock, 'user.user.savePushToken')).toEqual({ + token: 'ExponentPushToken[test]', + regionId: 1, + }) + ) + expect(procedureCalls(api.fetchMock, 'user.user.recordTrackedRegion')).toHaveLength(0) + }) + + it('records a tracked region when the region came from the device fix', async () => { + mockedUseRegion.mockReturnValue(regionValue({ regionId: 3, bound: { id: 9 } })) + const api = setupApiMocks({ procedures }) + + renderSync() + + await waitFor(() => + expect(lastProcedureInput(api.fetchMock, 'user.user.recordTrackedRegion')).toEqual({ + regionId: 3, + }) + ) + expect(lastProcedureInput(api.fetchMock, 'user.user.savePushToken')).toEqual({ + token: 'ExponentPushToken[test]', + regionId: 3, + }) + }) + + it('does nothing until a region is known', () => { + mockedUseRegion.mockReturnValue(regionValue({ regionId: null })) + const api = setupApiMocks({ procedures }) + + renderSync() + + expect(procedureCalls(api.fetchMock, 'user.user.savePushToken')).toHaveLength(0) + expect(procedureCalls(api.fetchMock, 'user.user.recordTrackedRegion')).toHaveLength(0) + }) +}) diff --git a/change-log.txt b/change-log.txt index 515edd6..0df3a5b 100644 --- a/change-log.txt +++ b/change-log.txt @@ -4273,3 +4273,100 @@ user-ui getMultipleProductsSlots(regionId, productIds) for the whole request. => globals get the current region's slots; a foreign-region SKU returns []. No dependency added. No migration. No tests run. + +2026-10-14 20:57:29 admin-ui/admin-web product form: let a regional admin attach a product to a + GLOBAL store (it was invisible in the picker and rejected on save). + + Model (confirmed with user): a global store is usable from EVERY region; the product keeps + the admin's own region_id (it does NOT become a global product). Global-product creation + stays superadmin-only. Global stores are labelled in the picker. + + packages/db_helper_sqlite/src/admin-apis/product.ts + - assertStoreInRegion (~line 136): regional branch relaxed from + `if (store.isGlobal || store.regionId !== regionId) throw` to + `if (!store.isGlobal && store.regionId !== regionId) throw` — a global store is now + accepted for any region; a non-global store from another region is still rejected. + The `regionId == null` branch (a global product must use a global store) is unchanged. + Covers create (~426) and update (~587). Now matches assertStoreIdsInRegion's rule. + packages/db_helper_sqlite/src/user-apis/stores.ts + - getStoresSummary(regionId): where `eq(regionId)` -> `or(eq(regionId), isGlobal)`, and the + selected columns gain `isGlobal`. This is the admin store picker AND the per-store cache + source, so global stores now also get regions/{id}/v-*/stores/{id}.json + cache purge + (previously the storefront listed a global store but 404'd on its detail file). + getStoreDetail already scopes products by storeId + (region_id = regionId OR NULL), so a + global store holding several regions' products does not leak across regions. + packages/shared/types/store.types.ts + - StoreSummary gains `isGlobal?: boolean` (optional; also flows through UserProductStoreInfo). + apps/admin-ui/src/components/ProductForm.tsx + - store options label globals: `${name} (global)`. + apps/admin-web/src/components/ProductForm.tsx + - same (same endpoint; keeps the two forms in parity). + apps/admin-ui/app/(drawer)/dashboard/products/add.tsx + - create default storeId 1 -> the first store option once the list loads (no magic id). + + tests updated (NOT run): apps/admin-ui/tests/components/product-form.test.tsx (+ + products-edit.test.tsx fixtures) now include a global store and assert it is offered/labelled. + No dependency added. No migration. No tests run. + +2026-10-14 22:19:26 User<->region associations + region on notif creds. + + New table user_regions (user_id, region_id, from_address, from_location) kept in sync from + addresses (authoritative, reconciled) AND from a tracked device location (insert-only). + Provenance flags exist so reconciling the address-derived rows can never delete a + location-derived row. notif_creds + unlogged_user_tokens each gain a NULLABLE region_id; + the client sends its region with the push token when a location is tracked or an address is + added, and the signed-out region is carried into notif_creds at login. + + packages/db_helper_sqlite/src/db/schema.ts + - NEW userRegions -> user_regions (id, user_id->users, region_id->regions, from_address, + from_location, created_at, updated_at) + uniqueIndex(user_id, region_id). + - notifCreds gains regionId (nullable, -> regions). unloggedUserTokens gains the same. + - relations: usersRelations.userRegions, regionsRelations.userRegions, notifCredsRelations.region, + NEW userRegionsRelations. + packages/db_helper_sqlite/src/user-apis/user-regions.ts (NEW) + - upsertUserRegion(userId, regionId, 'address'|'location'); reconcileUserRegions(userId) + (sets from_address for the user's current address regions, clears it elsewhere, deletes + rows where BOTH flags are false); getUserRegions(userId). + packages/db_helper_sqlite/index.ts + - export the new user-region helpers. + packages/db_helper_sqlite/src/user-apis/user.ts + - upsertNotifCred(userId, token, regionId?) / upsertUnloggedToken(token, regionId?): set the + region on insert and on an existing row when provided. getUserNotifCredRegion(token) helper + so the authed savePushToken can carry a signed-out region across when the payload omits it. + apps/backend/src/trpc/apis/user-apis/apis/address.ts + - createAddress -> upsertUserRegion(userId, regionId, 'address'); updateAddress + deleteAddress + -> reconcileUserRegions(userId). + apps/backend/src/trpc/apis/user-apis/apis/user.ts + - savePushToken input gains regionId (nullable/optional) and stores it (plus carries the + unlogged region over on login). NEW recordTrackedRegion({ regionId }) -> upsertUserRegion(..., 'location'). + apps/user-ui/src/components/NotifRegionSync.tsx (NEW) + app/_layout.tsx + - inside NotificationProvider: on region change, savePushToken({ token, regionId }); when the + region came from the device fix (useRegion().bound != null) also recordTrackedRegion. + packages/db_helper_sqlite/drizzle/0007_user_regions.sql (NEW, generated) + meta update + - creates user_regions, adds the two nullable region_id columns, and backfills user_regions + from existing addresses (from_address=1). NOT applied. + No dependency added. No migration run. No tests run. + +2026-10-14 22:25:53 Fold the user_regions SQL into migration 0006 (per request), drop 0007. + - packages/db_helper_sqlite/drizzle/0006_regions_and_superadmins.sql: appended a "Phase 5" + section (matching the file's Phase 1..4 layout) — CREATE TABLE IF NOT EXISTS user_regions, + its unique index, the two nullable region_id columns on notif_creds / unlogged_user_tokens, + and the address backfill (INSERT OR IGNORE ... SELECT DISTINCT). + - packages/db_helper_sqlite/drizzle/0007_user_regions.sql: deleted. + - packages/db_helper_sqlite/drizzle/meta/_journal.json: removed the idx 7 entry again (0006 is + the last migration). + No dependency added. No migration run. No tests run. + +2026-10-14 22:27:58 Make the user<->region/notif-region writes best-effort (they are auxiliary and + must never break the primary flow). + + - apps/backend/.../user-apis/apis/address.ts: the upsertUserRegion / reconcileUserRegions + calls after the (already committed) address write are now wrapped in try/catch: a failure + is logged and swallowed, so createAddress / updateAddress / deleteAddress still report the + address change that actually happened. (Previously a throw after the insert made the + mutation fail, which would leave PendingAddressSync retrying the local draft forever.) + - apps/backend/.../user-apis/apis/user.ts savePushToken: the region is now strictly additive. + Reading the signed-out region is guarded, and if upserting WITH the region fails the token + is retried WITHOUT it — so token registration still works on a DB where the region column + is not migrated yet. Same for the unauthenticated branch. + No dependency added. No migration run. No tests run. diff --git a/packages/db_helper_sqlite/drizzle/0006_regions_and_superadmins.sql b/packages/db_helper_sqlite/drizzle/0006_regions_and_superadmins.sql index 4312b50..05cb37f 100644 --- a/packages/db_helper_sqlite/drizzle/0006_regions_and_superadmins.sql +++ b/packages/db_helper_sqlite/drizzle/0006_regions_and_superadmins.sql @@ -940,3 +940,36 @@ DELETE FROM `user_creds` WHERE `id` NOT IN (SELECT MAX(`id`) FROM `user_creds` GROUP BY `user_id`); --> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS `unique_user_creds_user` ON `user_creds` (`user_id`); +--> statement-breakpoint + +-- ===================================================================== +-- Phase 5: user <-> region associations + a nullable region on push creds. +-- from_address 1 when the user has an address in that region, +-- from_location 1 when the device location resolved to it. +-- A row is dropped only once BOTH flags are false, so reconciling the +-- address-derived rows never loses a location-derived association. +-- notif_creds / unlogged_user_tokens get a NULLABLE region_id: the app sends +-- its region with the push token, and a region captured while signed out is +-- carried into notif_creds on login. +-- ===================================================================== +CREATE TABLE IF NOT EXISTS `user_regions` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `user_id` integer NOT NULL, + `region_id` integer NOT NULL, + `from_address` integer DEFAULT false NOT NULL, + `from_location` integer DEFAULT false NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, + FOREIGN KEY (`region_id`) REFERENCES `regions`(`id`) ON UPDATE no action ON DELETE no action +); +--> statement-breakpoint +CREATE UNIQUE INDEX IF NOT EXISTS `unique_user_region` ON `user_regions` (`user_id`,`region_id`); +--> statement-breakpoint +ALTER TABLE `notif_creds` ADD COLUMN `region_id` integer REFERENCES `regions`(`id`); +--> statement-breakpoint +ALTER TABLE `unlogged_user_tokens` ADD COLUMN `region_id` integer REFERENCES `regions`(`id`); +--> statement-breakpoint +-- Backfill one row per existing (user, region) pair from the addresses on file. +INSERT OR IGNORE INTO `user_regions` (`user_id`, `region_id`, `from_address`, `from_location`) +SELECT DISTINCT `user_id`, `region_id`, 1, 0 FROM `addresses` WHERE `region_id` IS NOT NULL; diff --git a/packages/db_helper_sqlite/index.ts b/packages/db_helper_sqlite/index.ts index 4154ce6..0db562c 100644 --- a/packages/db_helper_sqlite/index.ts +++ b/packages/db_helper_sqlite/index.ts @@ -270,6 +270,14 @@ export { upsertUnloggedToken as upsertUserUnloggedToken, } from './src/user-apis/user' +export { + // User <-> Region associations + upsertUserRegion, + reconcileUserRegions, + getUserRegions, + type UserRegionSource, +} from './src/user-apis/user-regions' + export { // User Order validateAndGetCoupons as validateAndGetUserCoupons, diff --git a/packages/db_helper_sqlite/src/admin-apis/product.ts b/packages/db_helper_sqlite/src/admin-apis/product.ts index 87ee5dd..269b9d9 100644 --- a/packages/db_helper_sqlite/src/admin-apis/product.ts +++ b/packages/db_helper_sqlite/src/admin-apis/product.ts @@ -132,8 +132,10 @@ const assertStoreInRegion = async (txOrDb: any, storeId: number, regionId: numbe if (!store.isGlobal) throw new Error('A global product must use a global store') return } - // A regional product must belong to that region's own (non-global) store. - if (store.isGlobal || store.regionId !== regionId) { + // A regional product may use its own region's store OR a global store (a + // global store is shared, so it serves every region). Only a non-global store + // from another region is rejected. + if (!store.isGlobal && store.regionId !== regionId) { throw new Error('Store belongs to a different region') } } diff --git a/packages/db_helper_sqlite/src/db/schema.ts b/packages/db_helper_sqlite/src/db/schema.ts index d819d17..b24ff9e 100644 --- a/packages/db_helper_sqlite/src/db/schema.ts +++ b/packages/db_helper_sqlite/src/db/schema.ts @@ -609,6 +609,9 @@ export const notifCreds = sqliteTable('notif_creds', { addedAt: timestampText('added_at').notNull().default(sql`CURRENT_TIMESTAMP`), userId: integer('user_id').notNull().references(() => users.id), lastVerified: timestampText('last_verified'), + // The region the device was last seen in. Nullable: a token is registered + // before any region is known. + regionId: integer('region_id').references(() => regions.id), }) export const unloggedUserTokens = sqliteTable('unlogged_user_tokens', { @@ -616,8 +619,26 @@ export const unloggedUserTokens = sqliteTable('unlogged_user_tokens', { token: text().notNull().unique(), addedAt: timestampText('added_at').notNull().default(sql`CURRENT_TIMESTAMP`), lastVerified: timestampText('last_verified'), + // Region captured while signed out; carried into notif_creds on login. + regionId: integer('region_id').references(() => regions.id), }) +// User <-> region associations. A row exists while the user has an address in +// that region (`from_address`) and/or the device has been tracked there +// (`from_location`). The address reconciler only ever clears/deletes +// address-derived rows, so a location-derived association is never lost. +export const userRegions = sqliteTable('user_regions', { + id: integer().primaryKey({ autoIncrement: true }), + userId: integer('user_id').notNull().references(() => users.id), + regionId: integer('region_id').notNull().references(() => regions.id), + fromAddress: integer('from_address', { mode: 'boolean' }).notNull().default(false), + fromLocation: integer('from_location', { mode: 'boolean' }).notNull().default(false), + createdAt: timestampText('created_at').notNull().default(sql`CURRENT_TIMESTAMP`), + updatedAt: timestampText('updated_at').notNull().default(sql`CURRENT_TIMESTAMP`), +}, (t) => ({ + unq_user_region: uniqueIndex('unique_user_region').on(t.userId, t.regionId), +})) + export const staffNotifCreds = sqliteTable('staff_notif_creds', { id: integer().primaryKey({ autoIncrement: true }), token: text().notNull().unique(), @@ -639,6 +660,7 @@ export const usersRelations = relations(users, ({ many, one }) => ({ userDetails: one(userDetails), notifCreds: many(notifCreds), userIncidents: many(userIncidents), + userRegions: many(userRegions), })) export const userCredsRelations = relations(userCreds, ({ one }) => ({ @@ -790,6 +812,12 @@ export const userDetailsRelations = relations(userDetails, ({ one }) => ({ export const notifCredsRelations = relations(notifCreds, ({ one }) => ({ user: one(users, { fields: [notifCreds.userId], references: [users.id] }), + region: one(regions, { fields: [notifCreds.regionId], references: [regions.id] }), +})) + +export const userRegionsRelations = relations(userRegions, ({ one }) => ({ + user: one(users, { fields: [userRegions.userId], references: [users.id] }), + region: one(regions, { fields: [userRegions.regionId], references: [regions.id] }), })) export const storeInfoRelations = relations(storeInfo, ({ many }) => ({ @@ -856,6 +884,7 @@ export const vendorSnippetsRelations = relations(vendorSnippets, ({ one }) => ({ export const regionsRelations = relations(regions, ({ many }) => ({ bounds: many(regionBounds), consts: many(regionConsts), + userRegions: many(userRegions), })) export const regionBoundsRelations = relations(regionBounds, ({ one, many }) => ({ diff --git a/packages/db_helper_sqlite/src/user-apis/stores.ts b/packages/db_helper_sqlite/src/user-apis/stores.ts index 91ea091..12d732e 100644 --- a/packages/db_helper_sqlite/src/user-apis/stores.ts +++ b/packages/db_helper_sqlite/src/user-apis/stores.ts @@ -121,11 +121,15 @@ export async function getStoreDetail(regionId: number, storeId: number): Promise export async function getStoresSummary(regionId: number): Promise { return db.query.storeInfo.findMany({ - where: eq(storeInfo.regionId, regionId), + // The region's own stores plus every global store (global stores are usable + // from any region). Also the source for the per-store cache files, so global + // stores get a regions/{id}/stores/.json like regional ones. + where: or(eq(storeInfo.regionId, regionId), eq(storeInfo.isGlobal, true)), columns: { id: true, name: true, description: true, + isGlobal: true, }, }) } diff --git a/packages/db_helper_sqlite/src/user-apis/user-regions.ts b/packages/db_helper_sqlite/src/user-apis/user-regions.ts new file mode 100644 index 0000000..1f85b7f --- /dev/null +++ b/packages/db_helper_sqlite/src/user-apis/user-regions.ts @@ -0,0 +1,90 @@ +import { db } from '../db/db_index' +import { addresses, userRegions } from '../db/schema' +import { and, eq } from 'drizzle-orm' + +/** + * How a user got associated with a region: because they have an address there + * ('address'), or because the device location resolved to it ('location'). + */ +export type UserRegionSource = 'address' | 'location' + +/** + * Ensure a (user, region) association exists and record how it was seen. Safe + * to call repeatedly — the (user_id, region_id) pair is unique. + */ +export async function upsertUserRegion( + userId: number, + regionId: number, + source: UserRegionSource +): Promise { + const isAddress = source === 'address' + + await db + .insert(userRegions) + .values({ + userId, + regionId, + fromAddress: isAddress, + fromLocation: !isAddress, + }) + .onConflictDoUpdate({ + target: [userRegions.userId, userRegions.regionId], + set: isAddress + ? { fromAddress: true, updatedAt: new Date() } + : { fromLocation: true, updatedAt: new Date() }, + }) +} + +/** + * Reconcile the user's address-derived associations with their current set of + * addresses: a region that still backs an address is marked `from_address`, one + * that no longer does is unmarked, and a row is deleted only once BOTH flags are + * false. Location-derived rows are never touched by this. + */ +export async function reconcileUserRegions(userId: number): Promise { + const rows = await db + .selectDistinct({ regionId: addresses.regionId }) + .from(addresses) + .where(eq(addresses.userId, userId)) + + const currentRegionIds = rows + .map((row) => row.regionId) + .filter((id): id is number => id != null) + + await db.transaction(async (tx) => { + for (const regionId of currentRegionIds) { + await tx + .insert(userRegions) + .values({ userId, regionId, fromAddress: true, fromLocation: false }) + .onConflictDoUpdate({ + target: [userRegions.userId, userRegions.regionId], + set: { fromAddress: true, updatedAt: new Date() }, + }) + } + + const addressRows = await tx.query.userRegions.findMany({ + where: and(eq(userRegions.userId, userId), eq(userRegions.fromAddress, true)), + columns: { id: true, regionId: true, fromLocation: true }, + }) + + for (const row of addressRows) { + if (currentRegionIds.includes(row.regionId)) continue + if (row.fromLocation) { + await tx + .update(userRegions) + .set({ fromAddress: false, updatedAt: new Date() }) + .where(eq(userRegions.id, row.id)) + } else { + await tx.delete(userRegions).where(eq(userRegions.id, row.id)) + } + } + }) +} + +/** Every region the user is associated with (address, location or both). */ +export async function getUserRegions(userId: number) { + return db.query.userRegions.findMany({ + where: eq(userRegions.userId, userId), + orderBy: (table, { asc }) => asc(table.regionId), + }) +} diff --git a/packages/db_helper_sqlite/src/user-apis/user.ts b/packages/db_helper_sqlite/src/user-apis/user.ts index 9b35803..359b077 100644 --- a/packages/db_helper_sqlite/src/user-apis/user.ts +++ b/packages/db_helper_sqlite/src/user-apis/user.ts @@ -28,16 +28,28 @@ export async function getUserWithCreds(userId: number) { } export async function getNotifCred(userId: number, token: string) { + // Only the id is needed by the upsert below. Selecting just it keeps the + // lookup working even if a newly added column (`region_id`) has not been + // migrated yet, so a region failure can never stop a token from being saved. return db.query.notifCreds.findFirst({ where: and(eq(notifCreds.userId, userId), eq(notifCreds.token, token)), + columns: { id: true }, }) } -export async function upsertNotifCred(userId: number, token: string): Promise { +export async function upsertNotifCred( + userId: number, + token: string, + regionId: number | null = null +): Promise { const existing = await getNotifCred(userId, token) if (existing) { await db.update(notifCreds) - .set({ lastVerified: new Date() }) + .set({ + lastVerified: new Date(), + // A call that doesn't carry a region must not erase a known one. + ...(regionId != null ? { regionId } : {}), + }) .where(eq(notifCreds.id, existing.id)) return } @@ -46,6 +58,9 @@ export async function upsertNotifCred(userId: number, token: string): Promise { - const existing = await getUnloggedToken(token) +export async function upsertUnloggedToken( + token: string, + regionId: number | null = null +): Promise { + // Id-only lookup (see getNotifCred): the region must never be able to stop the + // token row from being written. + const existing = await db.query.unloggedUserTokens.findFirst({ + where: eq(unloggedUserTokens.token, token), + columns: { id: true }, + }) if (existing) { await db.update(unloggedUserTokens) - .set({ lastVerified: new Date() }) + .set({ + lastVerified: new Date(), + ...(regionId != null ? { regionId } : {}), + }) .where(eq(unloggedUserTokens.id, existing.id)) return } @@ -71,5 +97,7 @@ export async function upsertUnloggedToken(token: string): Promise { await db.insert(unloggedUserTokens).values({ token, lastVerified: new Date(), + // See upsertNotifCred: no region -> no column reference. + ...(regionId != null ? { regionId } : {}), }) } diff --git a/packages/shared/types/store.types.ts b/packages/shared/types/store.types.ts index 8cc1a95..350d89a 100644 --- a/packages/shared/types/store.types.ts +++ b/packages/shared/types/store.types.ts @@ -13,6 +13,8 @@ import type { UserTagSummary } from './user' */ export interface StoreSummary extends IdName { description: string | null; + /** A global store is usable from every region (not owned by one region). */ + isGlobal?: boolean; } /**