rider status
This commit is contained in:
@@ -2,7 +2,7 @@ import { useMemo, useState } from 'react';
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { Button } from '@astryxdesign/core/Button';
|
||||
import { Selector } from '@astryxdesign/core/Selector';
|
||||
import { Route, UserCheck } from 'lucide-react';
|
||||
import { Route, TriangleAlert, UserCheck } from 'lucide-react';
|
||||
import { errorMessage } from '@/api/client';
|
||||
import {
|
||||
RIDER_MESSAGE,
|
||||
@@ -14,6 +14,7 @@ import { useAllPartners, useOwnTenant, useRiders } from '@/queries/hooks';
|
||||
import { queryKeys } from '@/queries/keys';
|
||||
import { useBranchScope } from './BranchScope';
|
||||
import { buildDeliveries, riderName, riderVehicle } from './assignDelivery';
|
||||
import { hasNoDevice } from './riderReach';
|
||||
import { RoutePlanDrawer } from './RoutePlanDrawer';
|
||||
import './pages/deliveries.css';
|
||||
|
||||
@@ -35,11 +36,20 @@ export interface AssignBarProps {
|
||||
orders: OrderRow[];
|
||||
branchOf: (row: OrderRow) => TenantLocation | undefined;
|
||||
assigned: ReadonlySet<number>;
|
||||
/** Orders whose delivery is dead — see `releasedFrom`. */
|
||||
released?: ReadonlySet<number>;
|
||||
onClear: () => void;
|
||||
onDone: () => void;
|
||||
}
|
||||
|
||||
export function AssignBar({ orders, branchOf, assigned, onClear, onDone }: AssignBarProps) {
|
||||
export function AssignBar({
|
||||
orders,
|
||||
branchOf,
|
||||
assigned,
|
||||
released,
|
||||
onClear,
|
||||
onDone,
|
||||
}: AssignBarProps) {
|
||||
const client = useQueryClient();
|
||||
const [riderId, setRiderId] = useState('');
|
||||
const [outcome, setOutcome] = useState<string | null>(null);
|
||||
@@ -103,7 +113,7 @@ export function AssignBar({ orders, branchOf, assigned, onClear, onDone }: Assig
|
||||
const send = useMutation({
|
||||
mutationFn: async () => {
|
||||
if (!rider) throw new Error('Pick a rider first');
|
||||
const { drafts, skipped } = buildDeliveries(orders, rider, branchOf, new Date(), assigned);
|
||||
const { drafts, skipped } = buildDeliveries(orders, rider, branchOf, new Date(), assigned, released);
|
||||
if (drafts.length === 0) {
|
||||
throw new Error(skipped[0]?.reason ?? 'None of these orders can be assigned');
|
||||
}
|
||||
@@ -205,6 +215,25 @@ export function AssignBar({ orders, branchOf, assigned, onClear, onDone }: Assig
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/*
|
||||
Said before the hand-off, not after it.
|
||||
|
||||
A rider who has never opened the app has no device to push to, so the
|
||||
job lands in a queue nobody is told about. That used to surface as
|
||||
"NOT notified" in the outcome line AFTER the deliveries were written —
|
||||
by which point the only remedy is a phone call, and one navigation
|
||||
later there was no record of it at all.
|
||||
|
||||
It disables nothing. Assigning to a rider you are about to ring is a
|
||||
legitimate thing to do; being surprised by it afterwards is not.
|
||||
*/}
|
||||
{rider && hasNoDevice(rider) ? (
|
||||
<span className="assign-bar-warn" role="status">
|
||||
<TriangleAlert size={14} />
|
||||
No app on this rider’s phone yet — they will not be told. Call them.
|
||||
</span>
|
||||
) : null}
|
||||
|
||||
{/* Two ways to commit the same selection, and the difference is worth the
|
||||
second button: "Assign" hands the orders over as they are, which is
|
||||
right for one or two. "Plan the route" sequences them first — real
|
||||
|
||||
Reference in New Issue
Block a user