dispatch page
This commit is contained in:
34
src/App.tsx
34
src/App.tsx
@@ -102,12 +102,17 @@ export default function App() {
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [sidebarOpen, setSidebarOpen] = useState(true);
|
||||
|
||||
// Scope every Fiesta query to the signed-in merchant. The login record carries
|
||||
// the user's tenantid; fall back to the shared constant only when it's absent
|
||||
// (e.g. a legacy session before tenantid was captured) so the page still loads.
|
||||
const tenantId = authUser?.tenantid || FIESTA_TENANT_ID;
|
||||
|
||||
// ── Live data for the secondary sections (Fiesta) ─────────────────────────
|
||||
// Stores ← tenant locations + per-location order summary (seeded into local
|
||||
// state so the "Add Store" handler keeps working). Users management now lives
|
||||
// under Settings → Users & Access (see UsersPanel).
|
||||
const locationsQ = useFiestaTenantLocations(FIESTA_TENANT_ID);
|
||||
const locSummaryQ = useFiestaLocationSummary(FIESTA_TENANT_ID);
|
||||
const locationsQ = useFiestaTenantLocations(tenantId);
|
||||
const locSummaryQ = useFiestaLocationSummary(tenantId);
|
||||
|
||||
const STORE_COVERS = [
|
||||
'https://images.unsplash.com/photo-1542838132-92c53300491e?auto=format&fit=crop&w=600&q=80',
|
||||
@@ -141,12 +146,14 @@ export default function App() {
|
||||
const [storesFilter, setStoresFilter] = useState<'ALL' | 'ACTIVE' | 'CRITICAL'>('ALL');
|
||||
|
||||
const filteredStoresList = storesList.filter((st) => {
|
||||
const q = storesSearch.toLowerCase();
|
||||
const matchesSearch =
|
||||
!q ||
|
||||
st.name.toLowerCase().includes(q) ||
|
||||
st.zone.toLowerCase().includes(q) ||
|
||||
st.staff.toLowerCase().includes(q);
|
||||
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
|
||||
// never throws and silently breaks the whole filter.
|
||||
const haystack = [st.name, st.zone, st.staff, st.locationid]
|
||||
.map((v) => String(v ?? '').toLowerCase())
|
||||
.join(' ');
|
||||
const matchesSearch = !q || haystack.includes(q);
|
||||
|
||||
if (storesFilter === 'ACTIVE') {
|
||||
return matchesSearch && st.status.toLowerCase() === 'active';
|
||||
@@ -262,6 +269,7 @@ export default function App() {
|
||||
<StoreDetailView
|
||||
store={activeStore}
|
||||
onBack={selectedStore ? () => setSelectedStore(null) : undefined}
|
||||
tenantId={tenantId}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -533,7 +541,7 @@ export default function App() {
|
||||
}
|
||||
|
||||
case 'settings':
|
||||
return <SettingsView tenantId={FIESTA_TENANT_ID} />;
|
||||
return <SettingsView tenantId={tenantId} />;
|
||||
|
||||
default:
|
||||
return null;
|
||||
@@ -575,6 +583,7 @@ export default function App() {
|
||||
isCoimbatoreView={isCoimbatoreView}
|
||||
setIsCoimbatoreView={setIsCoimbatoreView}
|
||||
isOpen={sidebarOpen}
|
||||
isAdmin={authRole === 'admin'}
|
||||
/>
|
||||
|
||||
{/* Main core pages payload area */}
|
||||
@@ -582,13 +591,14 @@ export default function App() {
|
||||
<div className="w-full p-container-margin md:p-xl space-y-lg transition-all duration-300">
|
||||
{/* Nav content routing */}
|
||||
{currentSection === 'dashboard' && (
|
||||
<DashboardView searchQuery={searchQuery} isCoimbatoreView={isCoimbatoreView} />
|
||||
<DashboardView searchQuery={searchQuery} isCoimbatoreView={isCoimbatoreView} tenantId={tenantId} />
|
||||
)}
|
||||
|
||||
|
||||
{currentSection === 'inventory' && (
|
||||
<InventoryView
|
||||
searchQuery={searchQuery}
|
||||
isCoimbatoreView={isCoimbatoreView}
|
||||
tenantId={tenantId}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -597,9 +607,11 @@ export default function App() {
|
||||
searchQuery={searchQuery}
|
||||
isCoimbatoreView={isCoimbatoreView}
|
||||
setIsCoimbatoreView={setIsCoimbatoreView}
|
||||
tenantId={tenantId}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
{/* Handle alternative sections: Stores, Settings */}
|
||||
{['stores', 'settings'].includes(currentSection) &&
|
||||
renderSecondarySection()
|
||||
|
||||
Reference in New Issue
Block a user