+ )
+}
+
+export default RegionTabs
diff --git a/apps/superadmin-ui/src/routes/dashboard.tsx b/apps/superadmin-ui/src/routes/dashboard.tsx
index 58f43aa..27595b0 100644
--- a/apps/superadmin-ui/src/routes/dashboard.tsx
+++ b/apps/superadmin-ui/src/routes/dashboard.tsx
@@ -23,19 +23,19 @@ const CARDS = [
},
{
to: '/global-stores',
- title: 'Global Stores',
- description: 'Create stores that are available in every region.',
+ title: 'Stores',
+ description: 'Global stores plus each region’s own stores.',
icon: Store,
},
{
to: '/global-products',
- title: 'Global Products',
- description: 'Create products that are shared across every region.',
+ title: 'Products',
+ description: 'Global products plus each region’s own products.',
icon: Package,
},
{
to: '/send-notifications',
- title: 'Send Admin Notifications',
+ title: 'Admin Notifs',
description: 'Push a message to every admin device.',
icon: Send,
},
diff --git a/apps/superadmin-ui/src/routes/global-products.tsx b/apps/superadmin-ui/src/routes/global-products.tsx
index 9ce3f8d..31418f9 100644
--- a/apps/superadmin-ui/src/routes/global-products.tsx
+++ b/apps/superadmin-ui/src/routes/global-products.tsx
@@ -4,6 +4,7 @@ import { AppContainer, MyButton, p as MyText, pInput as PInput } from 'web-compo
import { Plus, Trash2, X } from 'lucide-react'
import { ProtectedRoute } from '../components/ProtectedRoute'
import { AppShell } from '../components/AppShell'
+import { RegionTabs, type RegionTabKey } from '../components/RegionTabs'
import { trpc } from '../lib/trpc-client'
import { useUploadToObjectStorage } from '../hooks/useUploadToObjectStorage'
@@ -11,7 +12,7 @@ export const Route = createFileRoute('/global-products')({
component: () => (
-
+
),
@@ -77,40 +78,32 @@ const skuToDraft = (sku: any): SkuDraft => ({
comboItems: (sku.comboItems ?? []).map((ci: any) => ({ skuId: ci.skuId })),
})
-function GlobalProductsPage() {
- const [tab, setTab] = useState<'global' | 'all'>('global')
- const tabClass = (active: boolean) =>
- `rounded-lg px-4 py-2 text-sm font-semibold ${active ? 'bg-blue-500 text-white' : 'bg-gray-200 text-gray-700'}`
+function ProductsPage() {
+ const regionsQuery = trpc.superadmin.regions.list.useQuery()
+ const regions = (regionsQuery.data ?? []) as { id: number; name: string }[]
+ const [tab, setTab] = useState('global')
return (
Products
- Create and manage global products, or elevate a regional product to global.
+ The Global tab holds the catalogue shared across every region; each region tab lists that
+ region's own products (which can be elevated to global).
-
- Global Products
-
- Products shared across every region. Creating one seeds the initial price & stock into
- each region; editing the structure leaves each region's market data untouched.
-
+
+
+ Products shared across every region. Creating one seeds the initial price & stock into
+ each region; editing the structure leaves each region's market data untouched.
+
{editing ? (
))}
-
-
+
)
}
diff --git a/apps/superadmin-ui/src/routes/global-stores.tsx b/apps/superadmin-ui/src/routes/global-stores.tsx
index 984f6f3..f16c2f4 100644
--- a/apps/superadmin-ui/src/routes/global-stores.tsx
+++ b/apps/superadmin-ui/src/routes/global-stores.tsx
@@ -3,19 +3,42 @@ import { useState } from 'react'
import { AppContainer, MyButton, p as MyText, pInput as PInput } from 'web-components'
import { ProtectedRoute } from '../components/ProtectedRoute'
import { AppShell } from '../components/AppShell'
+import { RegionTabs, type RegionTabKey } from '../components/RegionTabs'
import { trpc } from '../lib/trpc-client'
export const Route = createFileRoute('/global-stores')({
component: () => (
-
+
),
})
-function GlobalStoresPage() {
+function StoresPage() {
+ const regionsQuery = trpc.superadmin.regions.list.useQuery()
+ const regions = (regionsQuery.data ?? []) as { id: number; name: string }[]
+ const [tab, setTab] = useState('global')
+
+ return (
+
+
+ Stores
+
+ The Global tab lists the stores available in every region; each region tab lists that
+ region's own stores.
+
+
+
+
+ {tab === 'global' ? : }
+
- Global Stores
-
- Stores available in every region. Regional admins can view them but not edit them.
-
+
+
+ Stores available in every region. Regional admins can view them but not edit them.
+
-
+
- {listQuery.isLoading && Loading stores…}
+ {listQuery.isLoading && Loading stores…}
-
)
}
diff --git a/apps/superadmin-ui/src/routes/send-notifications.tsx b/apps/superadmin-ui/src/routes/send-notifications.tsx
index 402d00f..93abe39 100644
--- a/apps/superadmin-ui/src/routes/send-notifications.tsx
+++ b/apps/superadmin-ui/src/routes/send-notifications.tsx
@@ -50,7 +50,7 @@ function SendAdminNotifications() {
- Send Admin Notifications
+ Admin Notifs
This push notification is delivered to every admin device.
diff --git a/change-log.txt b/change-log.txt
index 00c9008..021090d 100644
--- a/change-log.txt
+++ b/change-log.txt
@@ -4047,8 +4047,85 @@ user-ui
apps/user-ui/test-case-info.md: updated the address-form / cart-screen / location-wrapper entries
and added the new suites.
No dependency added. No migration. No tests run (typecheck only).
+
+2026-10-13 23:06:50 Superadmin: region tabs for Products and Stores + nav label cleanup.
+ 1/9 packages/db_helper_sqlite/src/superadmin-apis/stores.ts (NEW): listRegionStores(regionId) —
+ stores owned by one region (regionId = X AND isGlobal = false), name-ordered, Store shape.
+ 2/9 packages/db_helper_sqlite/index.ts: export listRegionStores (superadmin section).
+ 3/9 apps/backend/.../superadmin-apis/apis/stores.ts (NEW): superadmin.stores.list({regionId}) →
+ region stores with scaffolded imageUrl (mirrors the global-stores router).
+ 4/9 apps/backend/.../superadmin-apis/apis/superadmin-trpc-index.ts: register the stores router.
+ 5/9 apps/superadmin-ui/src/components/RegionTabs.tsx (NEW): shared Global + one-tab-per-region tab bar.
+ 6/9 apps/superadmin-ui/src/routes/global-products.tsx: Products page is now tabbed (Global first,
+ then every region). Global keeps the create/edit form; each region lists its own products via
+ superadmin.products.list({regionId}) with search, pagination and Elevate-to-global.
+ 7/9 apps/superadmin-ui/src/routes/global-stores.tsx: Stores page is now tabbed (Global first, then
+ every region). Global keeps the create/edit form; each region lists its stores via
+ superadmin.stores.list({regionId}).
+ 8/9 apps/superadmin-ui/src/components/AppShell.tsx: left-panel labels "Global Stores" → "Stores",
+ "Global Products" → "Products".
+ 9/9 apps/superadmin-ui/src/routes/dashboard.tsx: matching card titles dropped "Global".
+ No dependency added. No migration. No tests run.
+
+2026-10-13 23:07:22 Superadmin: rename "Send Admin Notifications" to "Admin Notifs".
+ apps/superadmin-ui/src/components/AppShell.tsx: left-panel label.
+ apps/superadmin-ui/src/routes/dashboard.tsx: matching dashboard card title.
+ apps/superadmin-ui/src/routes/send-notifications.tsx: page heading.
+ No dependency added. No migration. No tests run.
+
+2026-10-13 23:15:01 Superadmin: elevate a regional store to global.
+ 1/4 packages/db_helper_sqlite/src/superadmin-apis/stores.ts: add elevateStoreToGlobal(storeId) —
+ region_id -> NULL, is_global -> true (products untouched). Rejects missing/already-global.
+ 2/4 packages/db_helper_sqlite/index.ts: export elevateStoreToGlobal.
+ 3/4 apps/backend/.../superadmin-apis/apis/stores.ts: superadmin.stores.elevate({storeId}) mutation
+ + scheduleStoreInitialization (mirrors superadmin.products.elevate).
+ 4/4 apps/superadmin-ui/src/routes/global-stores.tsx: "Elevate to global" action on each store in a
+ region tab (confirm + invalidate the region list and the global list).
+ NOTE: per the chosen behaviour the store's products keep their region and storeId. Since a global
+ store may only hold global products (assertStoreInRegion), regional edits that submit storeId
+ for those products will be rejected. No dependency added. No migration. No tests run.
+
+2026-10-13 23:13:00 Superadmin: horizonally scrollable region tabs.
+ apps/superadmin-ui/src/components/RegionTabs.tsx: tab bar is now a single-row
+ overflow-x-auto strip (was flex-wrap); buttons get shrink-0 so they stay on one
+ line instead of wrapping when there are many regions.
+ + apps/superadmin-ui/src/components/AppShell.tsx: added min-w-0 to the main flex item so the
+ nowrap tab strip scrolls inside itself instead of widening the page horizontally.
+ No dependency added. No migration. No tests run.
+
+2026-10-13 23:53:07 Fix: admin stock toggles / bulk prices rejected global products ("Product not found").
+ Root cause: the write guards matched `product_info.region_id = ` only, while the
+ read path (getProductById) already matches `region_id IS NULL OR region_id = `. So a
+ global product showed up in the admin list but every stock write 404'd.
+ packages/db_helper_sqlite/src/admin-apis/product.ts:
+ + toggleProductOutOfStock: accept isNull(productInfo.regionId) (global products)
+ + setProductSkusOutOfStock: same
+ + updateProductPrices: a global SKU (product.regionId == null) is now valid instead of being
+ reported in invalidIds (the catalogued "Global SKU rejected by bulk prices" defect)
+ Market writes still target product_market_stats for the caller's region only, so a global
+ product's stock/price stays per-region.
+ No dependency added. No migration. No tests run.
+
- Added apps/backend/scripts/create-user.ts: creates/updates a user + bcrypt password.
Hashes with bcryptjs (12 rounds, matches signup) and writes via `wrangler d1 execute`
(--local default, --remote optional). Auto-detects existing user by mobile/email;
refuses to clobber unless --update. Supports --show-sql. No tests run.
- apps/backend/package.json: added "create-user" script -> bun run scripts/create-user.ts.
+
+2026-10-14 00:04:05 Global products: serve them across every region (storefront caches) + fix SKU ownership.
+ Same "region = X only" guard class as the stock-toggle bug, but on the read/cache path: global
+ products (product_info.region_id IS NULL) were dropped from every region's slots/tags/deals/combos,
+ so they landed in the catalogue with no slots (unorderable / "No delivery slots available").
+ packages/db_helper_sqlite/src/stores/store-helpers.ts:
+ + getInRegionSkuIds: include region_id IS NULL (this feeds slot skuIds AND banner skuIds)
+ + getInRegionStoreIds: include isGlobal stores (tag relatedStores)
+ + getAllSpecialDealsForCache / getAllProductTagsForCache / getAllTagProductMappings: include globals
+ + getAllProductCombosForCache: allow global combo parts, and include globals in the suspended set
+ + getAllSlotsWithProductsForCache: allow global products
+ packages/db_helper_sqlite/src/user-apis/slots.ts: getProductAvailability includes globals.
+ packages/db_helper_sqlite/src/user-apis/product.ts: getSuspendedSkuIds includes globals.
+ packages/db_helper_sqlite/src/admin-apis/product.ts: resolveSkuRegions derives isGlobal from
+ product_info.region_id (NULL) instead of the store's is_global flag, so a regional product in a
+ (possibly elevated) global store is no longer treated as global by the tag/combo guards.
+ Reviews deliberately left as-is (regional admins still can't see global products' reviews).
+ No dependency added. No migration. No tests run.
diff --git a/packages/db_helper_sqlite/index.ts b/packages/db_helper_sqlite/index.ts
index 51a83c0..e93a5c0 100644
--- a/packages/db_helper_sqlite/index.ts
+++ b/packages/db_helper_sqlite/index.ts
@@ -432,6 +432,11 @@ export {
deleteGlobalStore,
} from './src/superadmin-apis/global-stores'
+export {
+ listRegionStores,
+ elevateStoreToGlobal,
+} from './src/superadmin-apis/stores'
+
export {
listGlobalProducts,
getGlobalProduct,
diff --git a/packages/db_helper_sqlite/src/admin-apis/product.ts b/packages/db_helper_sqlite/src/admin-apis/product.ts
index 58eced3..87ee5dd 100644
--- a/packages/db_helper_sqlite/src/admin-apis/product.ts
+++ b/packages/db_helper_sqlite/src/admin-apis/product.ts
@@ -84,19 +84,19 @@ const getStringArray = (value: unknown): string[] | null => {
// Region guards: SKUs resolve to a region through their parent product
// (productSkus.productId -> productInfo.regionId). A global SKU (its product's
-// store is global) is valid in every region. Throws on unknown ids or ids whose
+// region is null) is valid in every region. Throws on unknown ids or ids whose
// parent product lives in another (non-global) region.
const resolveSkuRegions = async (txOrDb: any, skuIds: number[]): Promise