updats on the dispatch page
This commit is contained in:
@@ -21,7 +21,8 @@ import { branchLabel, count, money, moneyExact } from '../format';
|
||||
import {
|
||||
DELIVERY_STATUS,
|
||||
ORDER_STATUS,
|
||||
STATUS_TABS,
|
||||
DELIVERY_STATUS_TABS,
|
||||
ORDER_STATUS_TABS,
|
||||
matchesStatus,
|
||||
orderQuantity,
|
||||
orderValue,
|
||||
@@ -130,11 +131,21 @@ export function SalesPage() {
|
||||
.sort((a, b) => (billedAtMs(b.bill) ?? 0) - (billedAtMs(a.bill) ?? 0));
|
||||
}, [billPages, branchIds, branches, keyword]);
|
||||
|
||||
/**
|
||||
* The tab strip for whichever sub-tab is open.
|
||||
*
|
||||
* Orders and deliveries move through different ladders — an order is never
|
||||
* "arrived", a delivery is never "created" — so each gets its own tabs rather
|
||||
* than a shared set with half of it stuck at zero.
|
||||
*/
|
||||
const statusTabs = tab === 'deliveries' ? DELIVERY_STATUS_TABS : ORDER_STATUS_TABS;
|
||||
|
||||
/** Counts for the tab strip, from the unfiltered set. */
|
||||
const tabCounts = useMemo(() => {
|
||||
const source = tab === 'deliveries' ? allDeliveries : allOrders;
|
||||
const tabs = tab === 'deliveries' ? DELIVERY_STATUS_TABS : ORDER_STATUS_TABS;
|
||||
return Object.fromEntries(
|
||||
STATUS_TABS.map((entry) => [
|
||||
tabs.map((entry) => [
|
||||
entry.key,
|
||||
source.filter((row) => matchesStatus(entry.key, row.orderstatus)).length,
|
||||
]),
|
||||
@@ -291,6 +302,7 @@ export function SalesPage() {
|
||||
|
||||
<VStack gap={1.5}>
|
||||
<FilterRow
|
||||
tabs={statusTabs}
|
||||
status={status}
|
||||
counts={tabCounts}
|
||||
onStatus={setStatus}
|
||||
@@ -374,6 +386,7 @@ export function SalesPage() {
|
||||
|
||||
<VStack gap={1.5}>
|
||||
<FilterRow
|
||||
tabs={statusTabs}
|
||||
status={status}
|
||||
counts={tabCounts}
|
||||
onStatus={setStatus}
|
||||
@@ -507,11 +520,14 @@ function freshRow(
|
||||
* downward now follows that order.
|
||||
*/
|
||||
function FilterRow({
|
||||
tabs,
|
||||
status,
|
||||
counts,
|
||||
onStatus,
|
||||
search,
|
||||
}: {
|
||||
/** Which ladder to show — orders and deliveries do not share one. */
|
||||
tabs: readonly { readonly key: StatusKey; readonly label: string }[];
|
||||
status: StatusKey;
|
||||
counts: Record<StatusKey, number>;
|
||||
onStatus: (key: StatusKey) => void;
|
||||
@@ -520,7 +536,7 @@ function FilterRow({
|
||||
return (
|
||||
<HStack justify="between" align="center" gap={2} wrap="wrap">
|
||||
<HStack gap={0.5} wrap="wrap">
|
||||
{STATUS_TABS.map((entry) => (
|
||||
{tabs.map((entry) => (
|
||||
<StatusTab
|
||||
key={entry.key}
|
||||
label={entry.label}
|
||||
|
||||
Reference in New Issue
Block a user