cards removed

This commit is contained in:
2026-09-03 15:45:15 +05:30
parent 5345809951
commit bbe313ba48
9 changed files with 128 additions and 448 deletions

View File

@@ -6,21 +6,20 @@ import { summariseBranch } from '@/features/store-admin/posStatus';
import {
useLocationProducts,
useLocationSummary,
useOwnTenant,
usePosHealthByBranch,
usePosSalesByBranch,
useStockRequests,
} from '@/queries/hooks';
import { buildAlerts, rollupHealth, totalsOf, type BranchRow } from './consoleModel';
import { buildAlerts, totalsOf, type BranchRow } from './consoleModel';
import { consoleScope } from './consoleScope';
import { previousRange, useConsoleSeries } from './useConsoleSeries';
import { useConsoleSeries } from './useConsoleSeries';
import { BranchOverview } from './sections/BranchOverview';
import { KpiStrip } from './sections/KpiStrip';
import { NeedsAttention } from './sections/NeedsAttention';
import { SalesOverview } from './sections/SalesOverview';
import { StoreHealth } from './sections/StoreHealth';
import { TillSync } from './sections/TillSync';
import { YourShop } from './sections/YourShop';
import { QuickActions } from './sections/QuickActions';
import './console.css';
/**
@@ -53,14 +52,11 @@ export function ConsolePage() {
const base = isPinned ? '/store' : '/admin';
const [preset, setPreset] = useState<RangePreset>('today');
const [range, setRange] = useState<DateRange>(() => presetRange('today'));
const prev = useMemo(() => previousRange(range), [range]);
const branchIds = useMemo(() => scoped.map((branch) => branch.locationid), [scoped]);
const orders = useLocationSummary(tenantid || undefined);
const posNow = usePosSalesByBranch(branchIds, range);
const posBefore = usePosSalesByBranch(branchIds, prev);
const posHealth = usePosHealthByBranch(branchIds);
const shop = useOwnTenant(tenantid || undefined);
const products = useLocationProducts(tenantid || undefined, selected ?? undefined, 0, {
allBranches: true,
});
@@ -72,12 +68,7 @@ export function ConsolePage() {
() => posNow.flatMap((query) => (query.data ? [query.data] : [])),
[posNow],
);
const posBeforeData = useMemo(
() => posBefore.flatMap((query) => (query.data ? [query.data] : [])),
[posBefore],
);
const series = useConsoleSeries(tenantid, selected, range, posNowData, posBeforeData);
const series = useConsoleSeries(tenantid, selected, range, posNowData);
// One instant for the whole board, so two tills read a second apart are not
// judged against two different "nows".
@@ -122,7 +113,6 @@ export function ConsolePage() {
};
}, [rows, series]);
const rollup = useMemo(() => rollupHealth(rows), [rows]);
const alerts = useMemo(() => buildAlerts(rows, base), [rows, base]);
const scope = consoleScope({
@@ -162,24 +152,24 @@ export function ConsolePage() {
</div>
</header>
<KpiStrip
totals={totals}
days={series.days}
trends={series.trends}
comparisonLabel={preset === 'today' ? 'yesterday' : 'previous period'}
isLoading={isBusy}
/>
<KpiStrip totals={totals} isLoading={isBusy} />
<div className="console-split">
<SalesOverview days={series.days} isLoading={isBusy} />
{/* Full width. A trend needs the page: at two thirds it showed six days
before scrolling, which is not a trend, it is a sample. */}
<SalesOverview days={series.days} isLoading={isBusy} />
{/* Store health takes the slot the shop card had. The shop’s name and
address were the least useful thing on the board — a merchant knows
which shop they are in — and the health panel earns the width. */}
<div className="panel-pair">
<StoreHealth
rows={rows}
totals={totals}
rollup={rollup}
isAggregate={scope.isAggregate}
productCount={(products.data ?? []).length}
base={base}
/>
<QuickActions base={base} />
</div>
{scope.showBranchOverview ? (
@@ -194,9 +184,7 @@ export function ConsolePage() {
</header>
<BranchOverview rows={rows} onSelect={select} />
</section>
) : (
<YourShop row={rows[0]} shop={shop.data} title={scope.shopSectionTitle} base={base} />
)}
) : null}
<TillSync rows={rows} showBranch={scope.showBranchColumn} base={base} />