diff --git a/src/App.tsx b/src/App.tsx index f919685..c94e642 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -20,6 +20,7 @@ import { Store, TrendingUp, Settings, + Users, Truck } from 'lucide-react'; @@ -164,6 +165,19 @@ export default function App() { [locationsQ.data], ); + /** + * The header filter as a `locationid`, handed to every admin page. + * + * Until now this state reached nothing but the assistant's scope — the + * control looked like it worked and changed nothing on screen, while each + * page carried its own store picker instead. Those page-level pickers are + * gone; this is the single scope for the admin workspace. + * + * `undefined` (not 0) for "all branches": every read treats a missing + * locationid as tenant-wide, and 0 would be sent as a real id. + */ + const scopedBranch = adminBranch === 'all' ? undefined : adminBranch; + const today = new Date(); const monthStart = new Date(today); monthStart.setDate(today.getDate() - 30); @@ -231,6 +245,12 @@ export default function App() { const [storesFilter, setStoresFilter] = useState<'ALL' | 'ACTIVE' | 'INACTIVE'>('ALL'); const filteredStoresList = storesList.filter((st) => { + // The header branch filter scopes the store cards too. These are rendered + // here rather than inside DashboardView, so filtering the view's own list + // left the cards showing all five outlets while the KPIs above them read + // "1 / 1" — the page disagreeing with itself. + if (scopedBranch && Number(st.locationid) !== scopedBranch) return false; + const q = storesSearch.trim().toLowerCase(); // Match across every field shown on the card — name, zone, manager/contact, // and the outlet id — coercing each to a string so a missing/numeric value @@ -616,6 +636,13 @@ export default function App() { isAssistantOpen={assistantOpen} navItems={ADMIN_NAV_ITEMS} navBasePath="/admin" + // The three panels of the settings page, deep-linked. Kept in sync with + // SettingsView's own `tabs` array by the `?tab=` values it accepts. + settingsSections={[ + { label: 'Business Profile', icon: Building, to: '/admin/settings' }, + { label: 'Outlets', icon: Store, to: '/admin/settings?tab=outlets' }, + { label: 'Users & Access', icon: Users, to: '/admin/settings?tab=users' }, + ]} branches={adminBranches} selectedBranch={adminBranch} onBranchChange={setAdminBranch} @@ -678,7 +705,7 @@ export default function App() { renderStoresSection() ) : (
- +
{renderStoresSection()}
@@ -692,6 +719,7 @@ export default function App() { isCoimbatoreView={isCoimbatoreView} tenantId={tenantId} isSidebarOpen={sidebarOpen} + locationid={scopedBranch} /> } /> @@ -703,6 +731,7 @@ export default function App() { isCoimbatoreView={isCoimbatoreView} setIsCoimbatoreView={setIsCoimbatoreView} tenantId={tenantId} + locationid={scopedBranch} /> } /> @@ -711,13 +740,13 @@ export default function App() { } /> + } /> {/* Tenant-wide POS: no locationid, so the view fans out over every outlet under the tenant. */} + } /> diff --git a/src/components/AssistantRail.tsx b/src/components/AssistantRail.tsx index f406bbb..a41a53f 100644 --- a/src/components/AssistantRail.tsx +++ b/src/components/AssistantRail.tsx @@ -121,7 +121,7 @@ export default function AssistantRail({ open, onClose, scope }: AssistantRailPro />