weekend update
This commit is contained in:
@@ -87,13 +87,11 @@ function pickupLatLon(r: Row): [number, number] | null {
|
||||
}
|
||||
|
||||
// ── View modes (match #strat-row tabs) ───────────────────────────────────────────
|
||||
type ViewMode = 'kitchens' | 'zones' | 'riders' | 'orders' | 'deliveries';
|
||||
type ViewMode = 'kitchens' | 'zones' | 'riders';
|
||||
const VIEW_TABS: Array<{ id: ViewMode; label: string; icon: typeof MapIcon }> = [
|
||||
{ id: 'kitchens', label: 'By Location', icon: MapPin },
|
||||
{ id: 'zones', label: 'By Zone', icon: MapIcon },
|
||||
{ id: 'riders', label: 'By Rider', icon: Bike },
|
||||
{ id: 'orders', label: 'By Orders', icon: ShoppingBag },
|
||||
{ id: 'deliveries', label: 'By Deliveries', icon: Truck },
|
||||
];
|
||||
|
||||
interface Group {
|
||||
@@ -112,12 +110,13 @@ interface Group {
|
||||
interface DispatchViewProps {
|
||||
locationid?: number;
|
||||
tenantId?: number;
|
||||
headerTabs?: React.ReactNode;
|
||||
}
|
||||
|
||||
const WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
|
||||
export default function DispatchView({ locationid, tenantId = FIESTA_TENANT_ID }: DispatchViewProps) {
|
||||
export default function DispatchView({ locationid, tenantId = FIESTA_TENANT_ID, headerTabs }: DispatchViewProps) {
|
||||
const today = new Date();
|
||||
const [date, setDate] = useState<string>(ymd(today));
|
||||
const [viewMode, setViewMode] = useState<ViewMode>('riders');
|
||||
@@ -164,16 +163,6 @@ export default function DispatchView({ locationid, tenantId = FIESTA_TENANT_ID }
|
||||
const name = fstr(r.pickupcustomer) || fstr(r.pickuplocation) || 'Pickup';
|
||||
return { id: name.toLowerCase(), name };
|
||||
}
|
||||
if (viewMode === 'orders') {
|
||||
// Bucket by ORDER status (created / pending / processing / delivered / cancelled).
|
||||
const s = fstr(r.orderstatus).toLowerCase() || 'unknown';
|
||||
return { id: `o:${s}`, name: titleCase(s) };
|
||||
}
|
||||
if (viewMode === 'deliveries') {
|
||||
// Bucket by DELIVERY/dispatch status (falls back to order status, then unassigned).
|
||||
const s = (fstr(r.deliverystatus) || fstr(r.orderstatus)).toLowerCase() || 'unassigned';
|
||||
return { id: `d:${s}`, name: titleCase(s) };
|
||||
}
|
||||
const name = fstr(r.deliverysuburb) || fstr(r.zone_name) || 'Unzoned';
|
||||
return { id: name.toLowerCase(), name };
|
||||
};
|
||||
@@ -294,15 +283,18 @@ export default function DispatchView({ locationid, tenantId = FIESTA_TENANT_ID }
|
||||
<div className="dispatch-container embedded">
|
||||
{/* ── Header ── */}
|
||||
<div id="hdr">
|
||||
<div className="logo">
|
||||
<div className="logo-badge">D</div>
|
||||
<div className="logo-name">Dispatch</div>
|
||||
<div className="logo-city-wrap">
|
||||
<span className="logo-city" style={{ cursor: 'default' }}>
|
||||
<MapPin size={13} />
|
||||
<span className="logo-city-text">Coimbatore</span>
|
||||
</span>
|
||||
<div className="logo flex items-center gap-5">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="logo-badge shadow-sm">D</div>
|
||||
<div className="logo-name tracking-tight">Dispatch</div>
|
||||
<div className="logo-city-wrap ml-1">
|
||||
<span className="logo-city" style={{ cursor: 'default' }}>
|
||||
<MapPin size={13} className="text-purple-500" />
|
||||
<span className="logo-city-text font-semibold text-slate-700">Coimbatore</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{headerTabs}
|
||||
</div>
|
||||
|
||||
<div className="hdr-stats">
|
||||
@@ -430,7 +422,7 @@ export default function DispatchView({ locationid, tenantId = FIESTA_TENANT_ID }
|
||||
) : (
|
||||
<>
|
||||
<div className="ph">
|
||||
{viewMode === 'riders' ? 'Riders' : viewMode === 'kitchens' ? 'Pickup points' : viewMode === 'orders' ? 'Order statuses' : viewMode === 'deliveries' ? 'Delivery statuses' : 'Zones'} ({groups.length})
|
||||
{viewMode === 'riders' ? 'Riders' : viewMode === 'kitchens' ? 'Pickup points' : 'Zones'} ({groups.length})
|
||||
</div>
|
||||
{groups.map((g) => (
|
||||
<React.Fragment key={g.id}>
|
||||
|
||||
Reference in New Issue
Block a user