This commit is contained in:
2026-09-08 15:40:48 +05:30
parent 024fc4adfd
commit 59828811f9
12 changed files with 437 additions and 71 deletions

View File

@@ -5,7 +5,14 @@ import { useDeliveryMoves } from './DeliveryProgress';
import { Drawer } from './Drawer';
import { Badge, DrawerButton, DrawerCard, Metric, Metrics, Note, Row, Section } from './drawerKit';
import { branchLabel, moneyExact } from './format';
import { DELIVERY_STATUS, ORDER_STATUS, orderQuantity, orderValue, statusColor } from './orderStatus';
import {
DELIVERY_STATUS,
ORDER_STATUS,
orderQuantity,
orderValue,
stampAfterMs,
statusColor,
} from './orderStatus';
type Row_ = OrderRow | DeliveryRow;
@@ -303,15 +310,21 @@ function MoveCaption({ moves }: { moves: Moves }) {
* data-quality problem the operator opened this sheet to find.
*/
function Timeline({ row, isCancelled }: { row: Row_; isCancelled: boolean }) {
const steps = STEPS.map((step) => ({
label: step.label,
const fields = row as unknown as Record<string, string | undefined>;
/* Every later stamp is measured against when the order was placed, because no
step of the journey can have happened before it — see `stampAfterMs`.
`getorders` returns a `deliverydate` 5:30 BEHIND `orderdate` on every row,
and drawn raw this timeline read backwards. */
const placed = fields['orderdate'];
const steps = STEPS.map((step) => {
// Read by name: the two row shapes do not carry the same stamps — a
// delivery has no `packtime`, an order has no `arrivaltime` — so a step
// whose field is absent simply reads undefined and renders as not-yet.
at: step.fields
.map((field) => (row as unknown as Record<string, string | undefined>)[field])
.find(Boolean),
}));
const raw = step.fields.map((field) => fields[field]).find(Boolean);
const at = stampAfterMs(raw, placed);
return { label: step.label, at: at === null ? undefined : at };
});
/* The step the job is sitting on: the first one without a stamp. Marked as
"current" rather than merely "not done", so the eye lands on where the
@@ -400,7 +413,7 @@ function Party({
);
}
const when = (at: string): string =>
const when = (at: string | number): string =>
new Date(at).toLocaleString('en-IN', {
day: '2-digit',
month: 'short',