diff --git a/src/pages/nearle/orders/orders.js b/src/pages/nearle/orders/orders.js index 0578650..7f8dfea 100644 --- a/src/pages/nearle/orders/orders.js +++ b/src/pages/nearle/orders/orders.js @@ -37,7 +37,6 @@ import { MdNotes, MdMyLocation, MdOutlineFlag, - MdPerson, MdFlashOn, MdCancel, MdStraighten, @@ -56,9 +55,6 @@ import { Divider } from '@astryxdesign/core/Divider'; import { CheckboxInput } from '@astryxdesign/core/CheckboxInput'; import { Pagination } from '@astryxdesign/core/Pagination'; import { DropdownMenu, DropdownMenuCheckboxItem } from '@astryxdesign/core/DropdownMenu'; -import { Dialog, DialogHeader } from '@astryxdesign/core/Dialog'; -import { Layout, LayoutContent, LayoutFooter } from '@astryxdesign/core/Layout'; -import { Spinner } from '@astryxdesign/core/Spinner'; import { EmptyState } from '@astryxdesign/core/EmptyState'; import { Table, TableHeader, TableBody, TableRow, TableCell, TableHeaderCell } from '@astryxdesign/core/Table'; @@ -72,12 +68,10 @@ import { PageShell, DataCard } from 'components/nearle_components/PageLayout'; import { useQuery, useMutation } from '@tanstack/react-query'; import { useNavigate } from 'react-router-dom'; import { fetchPercentageData, createAutomationDeliveries, getallriders, buildMilerLookup, notifyRider } from '../../api/api'; -import { getBookings, getAdminCustomers, getBookingTrack, batchAssignBookings, getMilers } from 'pages/api/doormileApi'; +import { getBookings, getAdminCustomers, batchAssignBookings, getMilers } from 'pages/api/doormileApi'; import { parseDoormileTimestamp } from 'utils/doormileTimestamp'; import { DT, STATUS, tint } from 'themes/dt/tokens'; -import { TableScroll, AccentAvatar } from 'themes/dt/primitives'; - -const BRAND = DT.brand; +import { TableScroll } from 'themes/dt/primitives'; // Top-level pill tabs. GET /admin/bookings has no documented status filter // param, so bookings are fetched in bulk (up to the API's pagesize cap) and @@ -164,11 +158,6 @@ const haversineKm = (lat1, lon1, lat2, lon2) => { return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); }; -// Shared by the Track Order dialog's header (booking's own createdat) and its -// body (service ETA, assignment timestamps) — one formatter so the two never -// drift into different date styles. -const formatTrackTimestamp = (d) => (d ? dayjs(d).format('DD MMM, hh:mm A') : '—'); - // --------------------------------------------------------------------------- // Row primitives. // @@ -328,18 +317,6 @@ const Orders = () => { // mount guarantees the column-def `size`/`minSize` values below are always // the ones that actually render, with no other place width can come from. const [columnSizing, setColumnSizing] = useState({}); - const [trackBookingId, setTrackBookingId] = useState(null); - - // GET /admin/bookings/:id/track — confirmed live shape (not documented in - // express-console-api.md): { booking: {...full booking incl. parcels[], - // serviceoptions[], payments[]}, assignments: [], riders: [] }. assignments/ - // riders field names beyond that haven't been observed non-empty yet, so - // they're rendered defensively (see the Track Order dialog below). - const { data: trackData, isLoading: trackLoading } = useQuery({ - queryKey: ['booking-track', trackBookingId], - queryFn: () => getBookingTrack(trackBookingId), - enabled: !!trackBookingId - }); const locationId = 0; const locoName = 'All Locations'; // No date-filter UI on this page — the toolbar is search-only. These stay @@ -1146,13 +1123,8 @@ const Orders = () => { key={row.id} // A checked row keeps a faint brand wash so the solver // selection stays visible while you scroll past it; the - // transition keeps hover from snapping. Clicking the row - // opens the Track Order dialog — the select checkbox's - // own cell stops propagation below so ticking it doesn't - // also pop the dialog. - onClick={() => setTrackBookingId(row.original.bookingid)} + // transition keeps hover from snapping. style={{ - cursor: 'pointer', backgroundColor: row.getIsSelected() ? tint(DT.brand) : undefined, transition: 'background-color 140ms ease' }} @@ -1161,7 +1133,6 @@ const Orders = () => { e.stopPropagation() : undefined} > {flexRender(cell.column.columnDef.cell, cell.getContext())} @@ -1201,178 +1172,6 @@ const Orders = () => { )} - - !next && setTrackBookingId(null)} width={560} purpose="info"> - !next && setTrackBookingId(null)} - startContent={ - - - - } - /> - } - content={ - - {trackLoading ? ( - - - - ) : trackData?.booking ? ( - (() => { - const b = trackData.booking; - const assignments = trackData.assignments || []; - const riders = trackData.riders || []; - return ( - - {/* Status now lives on its own row instead of doubling - up with the order number/booked date, which moved - into DialogHeader's title/subtitle above. */} - - Status - - - - - - {/* Same PlaceCell the Orders table uses for its own - Pickup/Drop columns — a tinted icon tile + primary/ - secondary text — so the dialog and the row it was - opened from read as the same design language. */} - - - Pickup - } - primary={b.pickupaddress || '—'} - secondary={b.pickuppincode ? `Pincode ${b.pickuppincode}` : ''} - /> - - - Delivery - } - primary={b.deliveryaddress || '—'} - secondary={[b.deliverycity, b.deliverypincode].filter(Boolean).join(' · ')} - /> - - {b.notes && ( - - Notes - - - {b.notes} - - - )} - - - {b.parcels?.length > 0 && ( - <> - - - Parcels - - {b.parcels.map((p) => ( - } - label={`${p.itemcategory || 'Item'} · ₹${Number(p.declaredvalue || 0).toFixed(2)}`} - /> - ))} - - - - )} - - {b.serviceoptions?.length > 0 && ( - <> - - - Service - {b.serviceoptions.map((s, i) => ( - - {s.servicetype || '—'} - - - ETA {formatTrackTimestamp(s.estimateddeliveryat)} - - - ₹{Number(s.estimatedprice || 0).toFixed(2)} - - - - ))} - - - )} - - - - - Rider - {riders.length === 0 && assignments.length === 0 ? ( - Not assigned to a rider yet. - ) : ( - - {riders.map((r, i) => ( - - - - - - {r.displayname || r.name || 'Rider'} - {r.phone && ( - - {r.phone} - - )} - - - ))} - {/* Each assignment update as a small status chip + - timestamp row, instead of the bare "Assigned" - text repeating with no visual differentiation - between entries. */} - {assignments.length > 0 && ( - - {assignments.map((a, i) => ( - - - - {formatTrackTimestamp(a.createdat || a.assignedat)} - - - ))} - - )} - - )} - - - ); - })() - ) : ( - - No tracking data available for this order yet. - - )} - - } - footer={ - - - ); };