enhancement
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import type { DateRange } from '@/api/insights';
|
||||
import { DateRangePicker, presetRange, type RangePreset } from '@/features/store-admin/DateRangePicker';
|
||||
import { useMemo } from 'react';
|
||||
import { useDateScope } from '@/components/shell/DateScope';
|
||||
import { useBranchScope } from '@/features/store-admin/BranchScope';
|
||||
import { summariseBranch } from '@/features/store-admin/posStatus';
|
||||
import {
|
||||
@@ -50,12 +49,11 @@ export function ConsolePage() {
|
||||
useBranchScope();
|
||||
|
||||
const base = isPinned ? '/store' : '/admin';
|
||||
const [preset, setPreset] = useState<RangePreset>('today');
|
||||
const [range, setRange] = useState<DateRange>(() => presetRange('today'));
|
||||
const dates = useDateScope();
|
||||
|
||||
const branchIds = useMemo(() => scoped.map((branch) => branch.locationid), [scoped]);
|
||||
const orders = useLocationSummary(tenantid || undefined);
|
||||
const posNow = usePosSalesByBranch(branchIds, range);
|
||||
const posNow = usePosSalesByBranch(branchIds, dates.range);
|
||||
const posHealth = usePosHealthByBranch(branchIds);
|
||||
const products = useLocationProducts(tenantid || undefined, selected ?? undefined, 0, {
|
||||
allBranches: true,
|
||||
@@ -68,7 +66,7 @@ export function ConsolePage() {
|
||||
() => posNow.flatMap((query) => (query.data ? [query.data] : [])),
|
||||
[posNow],
|
||||
);
|
||||
const series = useConsoleSeries(tenantid, selected, range, posNowData);
|
||||
const series = useConsoleSeries(tenantid, selected, dates.range, posNowData);
|
||||
|
||||
// One instant for the whole board, so two tills read a second apart are not
|
||||
// judged against two different "nows".
|
||||
@@ -130,27 +128,7 @@ export function ConsolePage() {
|
||||
|
||||
return (
|
||||
<div className="console">
|
||||
<header className="console-head">
|
||||
<div className="console-title">
|
||||
<div className="console-title-row">
|
||||
<h1>Console</h1>
|
||||
<span className="console-scope">{scope.countLabel}</span>
|
||||
<span className="console-live"><i />Live</span>
|
||||
</div>
|
||||
<p className="console-blurb">{scope.blurb}</p>
|
||||
</div>
|
||||
|
||||
<div className="console-actions">
|
||||
<DateRangePicker
|
||||
preset={preset}
|
||||
range={range}
|
||||
onChange={(nextPreset, nextRange) => {
|
||||
setPreset(nextPreset);
|
||||
setRange(nextRange);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</header>
|
||||
<h1 className="sr-only">Console</h1>
|
||||
|
||||
<KpiStrip totals={totals} isLoading={isBusy} />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user