@burdenoff/microfe-movethewheels 2026.920.2 → 2026.921.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CarbonFootprintPanel.js +1 -1
- package/dist/components/CustomerPicker.js +271 -0
- package/dist/components/DataTable.js +140 -139
- package/dist/components/DocumentsCard.js +14 -8
- package/dist/generated/wspace-types.d.ts +1043 -5
- package/dist/hooks/useAnalytics.js +21 -1
- package/dist/hooks/useCustomers.js +94 -78
- package/dist/hooks/useDebouncedValue.js +11 -0
- package/dist/hooks/useEntityDocuments.js +28 -18
- package/dist/hooks/useEpod.js +24 -17
- package/dist/hooks/useFleet.js +146 -125
- package/dist/hooks/useInventory.js +255 -186
- package/dist/hooks/useMultiModalShipments.js +35 -27
- package/dist/hooks/useOrders.js +73 -73
- package/dist/hooks/useRoutes.js +97 -75
- package/dist/hooks/useTracking.js +100 -88
- package/dist/movethewheels/components/CustomerPicker.d.ts +19 -0
- package/dist/movethewheels/components/DataTable.d.ts +5 -1
- package/dist/movethewheels/hooks/useCustomers.d.ts +0 -1
- package/dist/movethewheels/hooks/useDebouncedValue.d.ts +1 -0
- package/dist/movethewheels/hooks/useEntityDocuments.d.ts +2 -0
- package/dist/movethewheels/hooks/useEpod.d.ts +6 -1
- package/dist/movethewheels/hooks/useFleet.d.ts +49 -5
- package/dist/movethewheels/hooks/useInventory.d.ts +24 -17
- package/dist/movethewheels/hooks/useMultiModalShipments.d.ts +6 -1
- package/dist/movethewheels/hooks/useOrders.d.ts +33 -5
- package/dist/movethewheels/hooks/useRoutes.d.ts +2 -1
- package/dist/movethewheels/hooks/useTracking.d.ts +12 -11
- package/dist/movethewheels/types/index.d.ts +7 -5
- package/dist/movethewheels/utils/navigation.d.ts +14 -0
- package/dist/pages/CreateOrderPage.js +228 -217
- package/dist/pages/CustomerDetailsPage.js +220 -220
- package/dist/pages/CustomersPage.js +61 -54
- package/dist/pages/DeliveryCapturePage.js +131 -109
- package/dist/pages/DriversPage.js +100 -92
- package/dist/pages/InventoryPage.js +239 -236
- package/dist/pages/MultiModalShipmentPage.js +163 -130
- package/dist/pages/OrderDetailsPage.js +224 -208
- package/dist/pages/OrdersListPage.js +66 -60
- package/dist/pages/ProductDetailsPage.js +241 -200
- package/dist/pages/ProductsPage.js +59 -52
- package/dist/pages/RouteDetailsPage.js +343 -321
- package/dist/pages/RoutesPage.js +55 -48
- package/dist/pages/VehiclesPage.js +63 -56
- package/dist/pages/WarehousesPage.js +60 -53
- package/dist/utils/navigation.js +22 -1
- package/package.json +1 -1
- package/src/generated/wspace-types.ts +1188 -5
- package/src/movethewheels/components/CarbonFootprintPanel.tsx +0 -1
- package/src/movethewheels/components/CustomerPicker.tsx +321 -0
- package/src/movethewheels/components/DataTable.tsx +34 -18
- package/src/movethewheels/components/DocumentsCard.tsx +6 -1
- package/src/movethewheels/components/maps/leaflet-setup.ts +1 -8
- package/src/movethewheels/hooks/useAnalytics.ts +27 -0
- package/src/movethewheels/hooks/useCustomers.ts +64 -24
- package/src/movethewheels/hooks/useDebouncedValue.ts +12 -0
- package/src/movethewheels/hooks/useEntityDocuments.ts +43 -25
- package/src/movethewheels/hooks/useEpod.ts +14 -7
- package/src/movethewheels/hooks/useFleet.ts +58 -37
- package/src/movethewheels/hooks/useFleetIntelligence.ts +1 -4
- package/src/movethewheels/hooks/useInventory.ts +211 -90
- package/src/movethewheels/hooks/useMultiModalShipments.ts +15 -11
- package/src/movethewheels/hooks/useOrders.ts +13 -14
- package/src/movethewheels/hooks/useRoutes.ts +80 -23
- package/src/movethewheels/hooks/useTracking.ts +130 -98
- package/src/movethewheels/pages/CreateOrderPage.tsx +92 -31
- package/src/movethewheels/pages/CustomerDetailsPage.tsx +15 -6
- package/src/movethewheels/pages/CustomersPage.tsx +11 -1
- package/src/movethewheels/pages/DeliveryCapturePage.tsx +31 -1
- package/src/movethewheels/pages/DriversPage.tsx +24 -12
- package/src/movethewheels/pages/InventoryPage.tsx +57 -32
- package/src/movethewheels/pages/MultiModalShipmentPage.tsx +52 -3
- package/src/movethewheels/pages/OrderDetailsPage.tsx +17 -1
- package/src/movethewheels/pages/OrdersListPage.tsx +20 -3
- package/src/movethewheels/pages/ProductDetailsPage.tsx +52 -3
- package/src/movethewheels/pages/ProductsPage.tsx +11 -1
- package/src/movethewheels/pages/RouteDetailsPage.tsx +35 -5
- package/src/movethewheels/pages/RoutesPage.tsx +11 -1
- package/src/movethewheels/pages/VehiclesPage.tsx +19 -2
- package/src/movethewheels/pages/WarehousesPage.tsx +11 -1
- package/src/movethewheels/types/index.ts +7 -5
- package/src/movethewheels/utils/navigation.ts +32 -0
|
@@ -7,7 +7,17 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { useState } from 'react';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Ship,
|
|
12
|
+
Plane,
|
|
13
|
+
Truck,
|
|
14
|
+
TrainFront,
|
|
15
|
+
Plus,
|
|
16
|
+
Trash2,
|
|
17
|
+
Calculator,
|
|
18
|
+
ChevronLeft,
|
|
19
|
+
ChevronRight,
|
|
20
|
+
} from 'lucide-react';
|
|
11
21
|
import { PageLayout, PageSection, EmptyState, LoadingState } from '../components/PageLayout';
|
|
12
22
|
import { FormError } from '../components/FormError';
|
|
13
23
|
import {
|
|
@@ -69,8 +79,20 @@ function formatMoney(
|
|
|
69
79
|
}
|
|
70
80
|
|
|
71
81
|
export default function MultiModalShipmentPage() {
|
|
72
|
-
const
|
|
73
|
-
|
|
82
|
+
const [pageIndex, setPageIndex] = useState(0);
|
|
83
|
+
const pageSize = 10;
|
|
84
|
+
const {
|
|
85
|
+
shipments,
|
|
86
|
+
totalShipments,
|
|
87
|
+
hasMore,
|
|
88
|
+
isLoading,
|
|
89
|
+
error,
|
|
90
|
+
calculateFreightRate,
|
|
91
|
+
planMultiModalShipment,
|
|
92
|
+
} = useMultiModalShipments({
|
|
93
|
+
limit: pageSize,
|
|
94
|
+
offset: pageIndex * pageSize,
|
|
95
|
+
});
|
|
74
96
|
|
|
75
97
|
const [shipmentNumber, setShipmentNumber] = useState('');
|
|
76
98
|
const [originAddress, setOriginAddress] = useState('');
|
|
@@ -149,6 +171,7 @@ export default function MultiModalShipmentPage() {
|
|
|
149
171
|
setDestinationAddress('');
|
|
150
172
|
setLegs([emptyLeg()]);
|
|
151
173
|
setQuotes({});
|
|
174
|
+
setPageIndex(0);
|
|
152
175
|
} catch (submitError) {
|
|
153
176
|
setFormError(submitError instanceof Error ? submitError.message : 'Failed to plan shipment');
|
|
154
177
|
} finally {
|
|
@@ -544,6 +567,32 @@ export default function MultiModalShipmentPage() {
|
|
|
544
567
|
</CardContent>
|
|
545
568
|
</Card>
|
|
546
569
|
))}
|
|
570
|
+
{totalShipments > pageSize && (
|
|
571
|
+
<div className="flex items-center justify-between border-t border-border-seam pt-4">
|
|
572
|
+
<span className="text-sm text-text-secondary">
|
|
573
|
+
Showing {pageIndex * pageSize + 1}–
|
|
574
|
+
{Math.min((pageIndex + 1) * pageSize, totalShipments)} of {totalShipments}
|
|
575
|
+
</span>
|
|
576
|
+
<div className="flex gap-2">
|
|
577
|
+
<Button
|
|
578
|
+
variant="outline"
|
|
579
|
+
size="sm"
|
|
580
|
+
disabled={pageIndex === 0 || isLoading}
|
|
581
|
+
onClick={() => setPageIndex((previous) => Math.max(0, previous - 1))}
|
|
582
|
+
>
|
|
583
|
+
<ChevronLeft size={16} /> Previous
|
|
584
|
+
</Button>
|
|
585
|
+
<Button
|
|
586
|
+
variant="outline"
|
|
587
|
+
size="sm"
|
|
588
|
+
disabled={!hasMore || isLoading}
|
|
589
|
+
onClick={() => setPageIndex((previous) => previous + 1)}
|
|
590
|
+
>
|
|
591
|
+
Next <ChevronRight size={16} />
|
|
592
|
+
</Button>
|
|
593
|
+
</div>
|
|
594
|
+
</div>
|
|
595
|
+
)}
|
|
547
596
|
</div>
|
|
548
597
|
)}
|
|
549
598
|
</PageSection>
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
Button,
|
|
35
35
|
Badge,
|
|
36
36
|
Separator,
|
|
37
|
+
Input,
|
|
37
38
|
Label,
|
|
38
39
|
Select,
|
|
39
40
|
SelectContent,
|
|
@@ -50,6 +51,7 @@ import {
|
|
|
50
51
|
import { EmphasisPanel, NextSteps, PagePurpose } from '@burdenoff/fe-libs/ui';
|
|
51
52
|
import { useOrder, useOrders } from '../hooks/useOrders';
|
|
52
53
|
import { useFleet } from '../hooks/useFleet';
|
|
54
|
+
import { useDebouncedValue } from '../hooks/useDebouncedValue';
|
|
53
55
|
import { FormError } from '../components/FormError';
|
|
54
56
|
import { Notice, useNotice } from '../components/Notice';
|
|
55
57
|
import { DocumentsCard } from '../components/DocumentsCard';
|
|
@@ -96,7 +98,12 @@ export default function OrderDetailsPage() {
|
|
|
96
98
|
const { basePath, navigate } = useMoveTheWheels();
|
|
97
99
|
const { order, isLoading, error, refetch } = useOrder(orderId);
|
|
98
100
|
const { updateOrder, updateOrderStatus } = useOrders();
|
|
99
|
-
const
|
|
101
|
+
const [fleetSearch, setFleetSearch] = useState('');
|
|
102
|
+
const debouncedFleetSearch = useDebouncedValue(fleetSearch);
|
|
103
|
+
const { vehicles, drivers } = useFleet({
|
|
104
|
+
limit: 20,
|
|
105
|
+
filters: { search: debouncedFleetSearch || undefined },
|
|
106
|
+
});
|
|
100
107
|
const { message: notice, notify } = useNotice();
|
|
101
108
|
|
|
102
109
|
const [selectedVehicle, setSelectedVehicle] = useState('');
|
|
@@ -477,6 +484,15 @@ export default function OrderDetailsPage() {
|
|
|
477
484
|
<Separator />
|
|
478
485
|
|
|
479
486
|
<div className="space-y-3">
|
|
487
|
+
<div className="space-y-1.5">
|
|
488
|
+
<Label htmlFor="assign-fleet-search">Search fleet</Label>
|
|
489
|
+
<Input
|
|
490
|
+
id="assign-fleet-search"
|
|
491
|
+
value={fleetSearch}
|
|
492
|
+
onChange={(event) => setFleetSearch(event.target.value)}
|
|
493
|
+
placeholder="Vehicle number, driver name or ID"
|
|
494
|
+
/>
|
|
495
|
+
</div>
|
|
480
496
|
<div className="space-y-1.5">
|
|
481
497
|
<Label htmlFor="assign-vehicle">Vehicle</Label>
|
|
482
498
|
<Select value={selectedVehicle} onValueChange={setSelectedVehicle}>
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
Badge,
|
|
35
35
|
} from '../components/ui';
|
|
36
36
|
import { useOrders, useOrderStats } from '../hooks/useOrders';
|
|
37
|
+
import { useDebouncedValue } from '../hooks/useDebouncedValue';
|
|
37
38
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
38
39
|
import { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';
|
|
39
40
|
import { formatCurrency, formatDate } from '../utils/formatters';
|
|
@@ -51,13 +52,23 @@ export default function OrdersListPage() {
|
|
|
51
52
|
const [unassignedOnly, setUnassignedOnly] = useState(false);
|
|
52
53
|
const [page, setPage] = useState(0);
|
|
53
54
|
const [pageSize, setPageSize] = useState(25);
|
|
55
|
+
const [search, setSearch] = useState('');
|
|
56
|
+
const debouncedSearch = useDebouncedValue(search);
|
|
54
57
|
|
|
55
|
-
const filtersActive = statusFilter !== 'all' || unassignedOnly;
|
|
58
|
+
const filtersActive = statusFilter !== 'all' || unassignedOnly || search.length > 0;
|
|
56
59
|
|
|
57
|
-
const {
|
|
60
|
+
const {
|
|
61
|
+
orders,
|
|
62
|
+
totalOrders: totalMatchingOrders,
|
|
63
|
+
hasMore,
|
|
64
|
+
isLoading,
|
|
65
|
+
error,
|
|
66
|
+
refetch,
|
|
67
|
+
} = useOrders({
|
|
58
68
|
filters: {
|
|
59
69
|
status: statusFilter === 'all' ? undefined : statusFilter,
|
|
60
70
|
unassigned: unassignedOnly || undefined,
|
|
71
|
+
search: debouncedSearch || undefined,
|
|
61
72
|
},
|
|
62
73
|
limit: pageSize,
|
|
63
74
|
offset: page * pageSize,
|
|
@@ -303,6 +314,7 @@ export default function OrdersListPage() {
|
|
|
303
314
|
onClick={() => {
|
|
304
315
|
setStatusFilter('all');
|
|
305
316
|
setUnassignedOnly(false);
|
|
317
|
+
setSearch('');
|
|
306
318
|
resetPage();
|
|
307
319
|
}}
|
|
308
320
|
>
|
|
@@ -323,6 +335,11 @@ export default function OrdersListPage() {
|
|
|
323
335
|
searchable
|
|
324
336
|
searchPlaceholder={t('movethewheels.orders.searchPlaceholder', 'Search orders...')}
|
|
325
337
|
searchFields={['orderNumber', 'customerInfo'] as (keyof Order)[]}
|
|
338
|
+
searchQuery={search}
|
|
339
|
+
onSearchQueryChange={(query) => {
|
|
340
|
+
setSearch(query);
|
|
341
|
+
setPage(0);
|
|
342
|
+
}}
|
|
326
343
|
onRowClick={(row) => goTo(`orders/${row.id}`)}
|
|
327
344
|
getRowId={(row) => row.id}
|
|
328
345
|
pageIndex={page}
|
|
@@ -332,7 +349,7 @@ export default function OrdersListPage() {
|
|
|
332
349
|
setPageSize(size);
|
|
333
350
|
setPage(0);
|
|
334
351
|
}}
|
|
335
|
-
totalItems={
|
|
352
|
+
totalItems={totalMatchingOrders}
|
|
336
353
|
hasNextPage={hasMore}
|
|
337
354
|
emptyMessage={t('movethewheels.orders.empty', 'No orders found')}
|
|
338
355
|
emptyIllustration="empty-data"
|
|
@@ -4,7 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
import { useLocation, useParams } from 'react-router';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Package,
|
|
9
|
+
ArrowLeft,
|
|
10
|
+
Edit,
|
|
11
|
+
Box,
|
|
12
|
+
DollarSign,
|
|
13
|
+
Tag,
|
|
14
|
+
Save,
|
|
15
|
+
Warehouse,
|
|
16
|
+
ChevronLeft,
|
|
17
|
+
ChevronRight,
|
|
18
|
+
} from 'lucide-react';
|
|
8
19
|
import { PageLayout, LoadingState, ErrorState } from '../components/PageLayout';
|
|
9
20
|
import {
|
|
10
21
|
Card,
|
|
@@ -192,12 +203,23 @@ export default function ProductDetailsPage() {
|
|
|
192
203
|
const { product, isLoading, error, refetch } = useProduct(productId);
|
|
193
204
|
const isEditRoute = useLocation().pathname.endsWith('/edit');
|
|
194
205
|
// Where this item is actually stocked — inventoryItems(filter: { cargoItemId }).
|
|
206
|
+
const [stockPage, setStockPage] = useState(0);
|
|
207
|
+
const stockPageSize = 20;
|
|
195
208
|
const {
|
|
196
209
|
levels: stockLevels,
|
|
210
|
+
totalLevels: totalStockLevels,
|
|
211
|
+
totalAvailable,
|
|
212
|
+
hasMore: hasMoreStock,
|
|
197
213
|
isLoading: stockLoading,
|
|
198
214
|
error: stockError,
|
|
199
|
-
} = useProductStockLevels(isEditRoute ? undefined : productId
|
|
200
|
-
|
|
215
|
+
} = useProductStockLevels(isEditRoute ? undefined : productId, {
|
|
216
|
+
limit: stockPageSize,
|
|
217
|
+
offset: stockPage * stockPageSize,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
setStockPage(0);
|
|
222
|
+
}, [productId]);
|
|
201
223
|
|
|
202
224
|
const goBack = () => navigate?.(joinPath(basePath, 'inventory/products'));
|
|
203
225
|
const goTo = (path: string) => navigate?.(joinPath(basePath, path));
|
|
@@ -391,6 +413,33 @@ export default function ProductDetailsPage() {
|
|
|
391
413
|
</span>
|
|
392
414
|
</div>
|
|
393
415
|
))}
|
|
416
|
+
{stockPage > 0 || hasMoreStock ? (
|
|
417
|
+
<div className="flex items-center justify-between gap-2 border-t border-border-seam pt-3">
|
|
418
|
+
<span className="text-xs text-text-secondary">
|
|
419
|
+
{stockPage * stockPageSize + 1}–
|
|
420
|
+
{Math.min(stockPage * stockPageSize + stockLevels.length, totalStockLevels)}{' '}
|
|
421
|
+
of {totalStockLevels}
|
|
422
|
+
</span>
|
|
423
|
+
<div className="flex gap-2">
|
|
424
|
+
<Button
|
|
425
|
+
variant="outline"
|
|
426
|
+
size="sm"
|
|
427
|
+
disabled={stockPage === 0 || stockLoading}
|
|
428
|
+
onClick={() => setStockPage((page) => Math.max(0, page - 1))}
|
|
429
|
+
>
|
|
430
|
+
<ChevronLeft size={14} /> Previous
|
|
431
|
+
</Button>
|
|
432
|
+
<Button
|
|
433
|
+
variant="outline"
|
|
434
|
+
size="sm"
|
|
435
|
+
disabled={!hasMoreStock || stockLoading}
|
|
436
|
+
onClick={() => setStockPage((page) => page + 1)}
|
|
437
|
+
>
|
|
438
|
+
Next <ChevronRight size={14} />
|
|
439
|
+
</Button>
|
|
440
|
+
</div>
|
|
441
|
+
</div>
|
|
442
|
+
) : null}
|
|
394
443
|
<div className="flex items-baseline justify-between gap-3 border-t border-border-seam pt-3">
|
|
395
444
|
<p className="text-sm text-text-secondary">Available across the network</p>
|
|
396
445
|
<span className="font-bold">{totalAvailable.toLocaleString()}</span>
|
|
@@ -10,6 +10,7 @@ import { DataTable, type Column } from '../components/DataTable';
|
|
|
10
10
|
import { Badge } from '../components/ui';
|
|
11
11
|
import { CTAOverflowMenu, PagePurpose } from '@burdenoff/fe-libs/ui';
|
|
12
12
|
import { useProducts, useProductStats } from '../hooks/useInventory';
|
|
13
|
+
import { useDebouncedValue } from '../hooks/useDebouncedValue';
|
|
13
14
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
14
15
|
import { formatCurrency } from '../utils/formatters';
|
|
15
16
|
import { joinPath } from '../utils/navigation';
|
|
@@ -19,9 +20,12 @@ export default function ProductsPage() {
|
|
|
19
20
|
const { basePath, navigate } = useMoveTheWheels();
|
|
20
21
|
const [page, setPage] = useState(0);
|
|
21
22
|
const [pageSize, setPageSize] = useState(25);
|
|
22
|
-
const
|
|
23
|
+
const [search, setSearch] = useState('');
|
|
24
|
+
const debouncedSearch = useDebouncedValue(search);
|
|
25
|
+
const { products, totalProducts, hasMore, isLoading, error, refetch } = useProducts({
|
|
23
26
|
limit: pageSize,
|
|
24
27
|
offset: page * pageSize,
|
|
28
|
+
search: debouncedSearch,
|
|
25
29
|
});
|
|
26
30
|
// Bounded aggregate for the tiles + subtitle — not the truncated page.
|
|
27
31
|
const { stats } = useProductStats();
|
|
@@ -164,6 +168,11 @@ export default function ProductsPage() {
|
|
|
164
168
|
searchable
|
|
165
169
|
searchPlaceholder="Search products..."
|
|
166
170
|
searchFields={['name', 'sku', 'category'] as (keyof Product)[]}
|
|
171
|
+
searchQuery={search}
|
|
172
|
+
onSearchQueryChange={(query) => {
|
|
173
|
+
setSearch(query);
|
|
174
|
+
setPage(0);
|
|
175
|
+
}}
|
|
167
176
|
onRowClick={(row) => goTo(`inventory/products/${row.id}`)}
|
|
168
177
|
getRowId={(row) => row.id}
|
|
169
178
|
pageIndex={page}
|
|
@@ -173,6 +182,7 @@ export default function ProductsPage() {
|
|
|
173
182
|
setPageSize(size);
|
|
174
183
|
setPage(0);
|
|
175
184
|
}}
|
|
185
|
+
totalItems={totalProducts}
|
|
176
186
|
hasNextPage={hasMore}
|
|
177
187
|
emptyIllustration="empty-files"
|
|
178
188
|
emptyTitle="No products yet"
|
|
@@ -40,17 +40,26 @@ import { EmphasisPanel, NextSteps, PagePurpose } from '@burdenoff/fe-libs/ui';
|
|
|
40
40
|
import { RouteMap, type RouteStop as MapRouteStop } from '../components/maps';
|
|
41
41
|
import { firstRealLatLng } from '../utils/mapMarkers';
|
|
42
42
|
import { useRoute, useRoutes } from '../hooks/useRoutes';
|
|
43
|
-
import { useFleet } from '../hooks/useFleet';
|
|
43
|
+
import { useFleet, useVehicle, useDriver } from '../hooks/useFleet';
|
|
44
44
|
import { useAssignmentSuggestions } from '../hooks/useFleetIntelligence';
|
|
45
45
|
import { AssignmentSuggestions } from '../components/AssignmentSuggestions';
|
|
46
46
|
import { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';
|
|
47
47
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
48
|
+
import { useDebouncedValue } from '../hooks/useDebouncedValue';
|
|
48
49
|
import { formatDate, formatAddress, formatCurrency } from '../utils/formatters';
|
|
49
50
|
import { joinPath } from '../utils/navigation';
|
|
50
51
|
import { ROUTE_STATUS_COLORS } from '../constants';
|
|
51
52
|
import { FormError } from '../components/FormError';
|
|
52
53
|
import { Notice, useNotice } from '../components/Notice';
|
|
53
|
-
import type { Route as RouteType, RouteStop } from '../types';
|
|
54
|
+
import type { Route as RouteType, RouteStop, Vehicle, Driver } from '../types';
|
|
55
|
+
|
|
56
|
+
/** Keeps a currently selected fleet item visible even when it falls outside the current search page. */
|
|
57
|
+
function mergeSelected<T extends { id: string }>(items: T[], selected: T | null | undefined): T[] {
|
|
58
|
+
if (!selected || items.some((item) => item.id === selected.id)) {
|
|
59
|
+
return items;
|
|
60
|
+
}
|
|
61
|
+
return [selected, ...items];
|
|
62
|
+
}
|
|
54
63
|
|
|
55
64
|
const ROUTE_STATUS_OPTIONS: { value: RouteType['status']; label: string }[] = [
|
|
56
65
|
{ value: 'planned', label: 'Planned' },
|
|
@@ -63,7 +72,12 @@ function NewRouteForm({ editId }: { editId?: string }) {
|
|
|
63
72
|
const { basePath, navigate } = useMoveTheWheels();
|
|
64
73
|
const { createRoute, updateRoute } = useRoutes();
|
|
65
74
|
const { route } = useRoute(editId);
|
|
66
|
-
const
|
|
75
|
+
const [fleetSearch, setFleetSearch] = useState('');
|
|
76
|
+
const debouncedFleetSearch = useDebouncedValue(fleetSearch);
|
|
77
|
+
const { vehicles, drivers } = useFleet({
|
|
78
|
+
limit: 20,
|
|
79
|
+
filters: { search: debouncedFleetSearch || undefined },
|
|
80
|
+
});
|
|
67
81
|
const isEditing = !!editId;
|
|
68
82
|
const [form, setForm] = useState<{
|
|
69
83
|
name: string;
|
|
@@ -78,6 +92,13 @@ function NewRouteForm({ editId }: { editId?: string }) {
|
|
|
78
92
|
driverId: '',
|
|
79
93
|
stops: [{ address: '', type: 'delivery' }],
|
|
80
94
|
});
|
|
95
|
+
// The selected vehicle/driver may fall outside the current search page (e.g. when
|
|
96
|
+
// editing a route or after the assignee no longer matches the search term); fetch
|
|
97
|
+
// them directly so the Select can still render the current selection.
|
|
98
|
+
const { vehicle: selectedVehicle } = useVehicle(form.vehicleId || undefined);
|
|
99
|
+
const { driver: selectedDriver } = useDriver(form.driverId || undefined);
|
|
100
|
+
const vehicleOptions: Vehicle[] = mergeSelected(vehicles, selectedVehicle);
|
|
101
|
+
const driverOptions: Driver[] = mergeSelected(drivers, selectedDriver);
|
|
81
102
|
const [submitting, setSubmitting] = useState(false);
|
|
82
103
|
const [error, setError] = useState<string | null>(null);
|
|
83
104
|
|
|
@@ -253,6 +274,15 @@ function NewRouteForm({ editId }: { editId?: string }) {
|
|
|
253
274
|
</Select>
|
|
254
275
|
</div>
|
|
255
276
|
</div>
|
|
277
|
+
<div className="space-y-2">
|
|
278
|
+
<Label htmlFor="fleet-search">Search fleet</Label>
|
|
279
|
+
<Input
|
|
280
|
+
id="fleet-search"
|
|
281
|
+
value={fleetSearch}
|
|
282
|
+
onChange={(e) => setFleetSearch(e.target.value)}
|
|
283
|
+
placeholder="Vehicle number, driver name or ID"
|
|
284
|
+
/>
|
|
285
|
+
</div>
|
|
256
286
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
257
287
|
<div className="space-y-2">
|
|
258
288
|
<Label htmlFor="vehicle">Vehicle (optional)</Label>
|
|
@@ -264,7 +294,7 @@ function NewRouteForm({ editId }: { editId?: string }) {
|
|
|
264
294
|
<SelectValue placeholder="Assign later" />
|
|
265
295
|
</SelectTrigger>
|
|
266
296
|
<SelectContent>
|
|
267
|
-
{
|
|
297
|
+
{vehicleOptions.map((vehicle) => (
|
|
268
298
|
<SelectItem key={vehicle.id} value={vehicle.id}>
|
|
269
299
|
{vehicle.vehicleNumber} ({vehicle.type})
|
|
270
300
|
</SelectItem>
|
|
@@ -282,7 +312,7 @@ function NewRouteForm({ editId }: { editId?: string }) {
|
|
|
282
312
|
<SelectValue placeholder="Assign later" />
|
|
283
313
|
</SelectTrigger>
|
|
284
314
|
<SelectContent>
|
|
285
|
-
{
|
|
315
|
+
{driverOptions.map((driver) => (
|
|
286
316
|
<SelectItem key={driver.id} value={driver.id}>
|
|
287
317
|
{driver.fullName} ({driver.employeeId})
|
|
288
318
|
</SelectItem>
|
|
@@ -10,6 +10,7 @@ import { StatusBadge } from '../components/StatusBadge';
|
|
|
10
10
|
import { Badge, Button } from '../components/ui';
|
|
11
11
|
import { CTAOverflowMenu, EmphasisPanel, PagePurpose } from '@burdenoff/fe-libs/ui';
|
|
12
12
|
import { useRoutes, useRouteStats } from '../hooks/useRoutes';
|
|
13
|
+
import { useDebouncedValue } from '../hooks/useDebouncedValue';
|
|
13
14
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
14
15
|
import { formatDate } from '../utils/formatters';
|
|
15
16
|
import { joinPath } from '../utils/navigation';
|
|
@@ -20,9 +21,12 @@ export default function RoutesPage() {
|
|
|
20
21
|
const { basePath, navigate } = useMoveTheWheels();
|
|
21
22
|
const [page, setPage] = useState(0);
|
|
22
23
|
const [pageSize, setPageSize] = useState(25);
|
|
23
|
-
const
|
|
24
|
+
const [search, setSearch] = useState('');
|
|
25
|
+
const debouncedSearch = useDebouncedValue(search);
|
|
26
|
+
const { routes, totalRoutes, hasMore, isLoading, error, refetch } = useRoutes({
|
|
24
27
|
limit: pageSize,
|
|
25
28
|
offset: page * pageSize,
|
|
29
|
+
search: debouncedSearch || undefined,
|
|
26
30
|
});
|
|
27
31
|
// Bounded aggregate for the tiles + subtitle — not the truncated page.
|
|
28
32
|
const { stats } = useRouteStats();
|
|
@@ -131,6 +135,11 @@ export default function RoutesPage() {
|
|
|
131
135
|
searchable
|
|
132
136
|
searchPlaceholder="Search routes..."
|
|
133
137
|
searchFields={['name'] as (keyof Route)[]}
|
|
138
|
+
searchQuery={search}
|
|
139
|
+
onSearchQueryChange={(query) => {
|
|
140
|
+
setSearch(query);
|
|
141
|
+
setPage(0);
|
|
142
|
+
}}
|
|
134
143
|
onRowClick={(row) => goTo(`routes/${row.id}`)}
|
|
135
144
|
getRowId={(row) => row.id}
|
|
136
145
|
pageIndex={page}
|
|
@@ -140,6 +149,7 @@ export default function RoutesPage() {
|
|
|
140
149
|
setPageSize(size);
|
|
141
150
|
setPage(0);
|
|
142
151
|
}}
|
|
152
|
+
totalItems={totalRoutes}
|
|
143
153
|
hasNextPage={hasMore}
|
|
144
154
|
emptyIllustration="empty-data"
|
|
145
155
|
emptyTitle="No routes yet"
|
|
@@ -19,6 +19,7 @@ import { StatusBadge, VehicleTypeBadge } from '../components/StatusBadge';
|
|
|
19
19
|
import { Progress } from '../components/ui';
|
|
20
20
|
import { CTAOverflowMenu, PagePurpose } from '@burdenoff/fe-libs/ui';
|
|
21
21
|
import { useVehicles, useFleetStats } from '../hooks/useFleet';
|
|
22
|
+
import { useDebouncedValue } from '../hooks/useDebouncedValue';
|
|
22
23
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
23
24
|
import { joinPath } from '../utils/navigation';
|
|
24
25
|
import type { Vehicle } from '../types';
|
|
@@ -27,9 +28,19 @@ export default function VehiclesPage() {
|
|
|
27
28
|
const { basePath, navigate } = useMoveTheWheels();
|
|
28
29
|
const [page, setPage] = useState(0);
|
|
29
30
|
const [pageSize, setPageSize] = useState(25);
|
|
30
|
-
const
|
|
31
|
+
const [search, setSearch] = useState('');
|
|
32
|
+
const debouncedSearch = useDebouncedValue(search);
|
|
33
|
+
const {
|
|
34
|
+
vehicles,
|
|
35
|
+
totalVehicles: filteredVehicleCount,
|
|
36
|
+
hasMore,
|
|
37
|
+
isLoading,
|
|
38
|
+
error,
|
|
39
|
+
refetch,
|
|
40
|
+
} = useVehicles({
|
|
31
41
|
limit: pageSize,
|
|
32
42
|
offset: page * pageSize,
|
|
43
|
+
search: debouncedSearch || undefined,
|
|
33
44
|
});
|
|
34
45
|
// Fleet totals + tiles from the live aggregate, not the current page.
|
|
35
46
|
const { stats } = useFleetStats();
|
|
@@ -176,6 +187,11 @@ export default function VehiclesPage() {
|
|
|
176
187
|
searchable
|
|
177
188
|
searchPlaceholder="Search vehicles..."
|
|
178
189
|
searchFields={['vehicleNumber', 'make', 'model'] as (keyof Vehicle)[]}
|
|
190
|
+
searchQuery={search}
|
|
191
|
+
onSearchQueryChange={(query) => {
|
|
192
|
+
setSearch(query);
|
|
193
|
+
setPage(0);
|
|
194
|
+
}}
|
|
179
195
|
onRowClick={(row) => goTo(`fleet/vehicles/${row.id}`)}
|
|
180
196
|
getRowId={(row) => row.id}
|
|
181
197
|
pageIndex={page}
|
|
@@ -185,7 +201,8 @@ export default function VehiclesPage() {
|
|
|
185
201
|
setPageSize(size);
|
|
186
202
|
setPage(0);
|
|
187
203
|
}}
|
|
188
|
-
totalItems={
|
|
204
|
+
totalItems={filteredVehicleCount}
|
|
205
|
+
hasNextPage={hasMore}
|
|
189
206
|
emptyIllustration="empty-data"
|
|
190
207
|
emptyTitle="No vehicles yet"
|
|
191
208
|
emptyDescription="Add vehicles to your fleet to start assigning them to deliveries."
|
|
@@ -10,6 +10,7 @@ import { DataTable, type Column } from '../components/DataTable';
|
|
|
10
10
|
import { Badge, Progress } from '../components/ui';
|
|
11
11
|
import { CTAOverflowMenu, PagePurpose } from '@burdenoff/fe-libs/ui';
|
|
12
12
|
import { useWarehouses, useWarehouseStats } from '../hooks/useInventory';
|
|
13
|
+
import { useDebouncedValue } from '../hooks/useDebouncedValue';
|
|
13
14
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
14
15
|
import { joinPath } from '../utils/navigation';
|
|
15
16
|
import type { Warehouse as WarehouseType } from '../types';
|
|
@@ -18,9 +19,12 @@ export default function WarehousesPage() {
|
|
|
18
19
|
const { basePath, navigate } = useMoveTheWheels();
|
|
19
20
|
const [page, setPage] = useState(0);
|
|
20
21
|
const [pageSize, setPageSize] = useState(25);
|
|
21
|
-
const
|
|
22
|
+
const [search, setSearch] = useState('');
|
|
23
|
+
const debouncedSearch = useDebouncedValue(search);
|
|
24
|
+
const { warehouses, totalWarehouses, hasMore, isLoading, error, refetch } = useWarehouses({
|
|
22
25
|
limit: pageSize,
|
|
23
26
|
offset: page * pageSize,
|
|
27
|
+
search: debouncedSearch,
|
|
24
28
|
});
|
|
25
29
|
// Bounded aggregate for the tiles + subtitle — not the truncated page.
|
|
26
30
|
const { stats } = useWarehouseStats();
|
|
@@ -157,6 +161,11 @@ export default function WarehousesPage() {
|
|
|
157
161
|
searchable
|
|
158
162
|
searchPlaceholder="Search warehouses..."
|
|
159
163
|
searchFields={['name', 'code'] as (keyof WarehouseType)[]}
|
|
164
|
+
searchQuery={search}
|
|
165
|
+
onSearchQueryChange={(query) => {
|
|
166
|
+
setSearch(query);
|
|
167
|
+
setPage(0);
|
|
168
|
+
}}
|
|
160
169
|
onRowClick={(row) => goTo(`inventory/warehouses/${row.id}`)}
|
|
161
170
|
getRowId={(row) => row.id}
|
|
162
171
|
pageIndex={page}
|
|
@@ -166,6 +175,7 @@ export default function WarehousesPage() {
|
|
|
166
175
|
setPageSize(size);
|
|
167
176
|
setPage(0);
|
|
168
177
|
}}
|
|
178
|
+
totalItems={totalWarehouses}
|
|
169
179
|
hasNextPage={hasMore}
|
|
170
180
|
emptyIllustration="empty-data"
|
|
171
181
|
emptyTitle="No warehouses yet"
|
|
@@ -502,7 +502,10 @@ export interface InventoryMovement {
|
|
|
502
502
|
export interface Inventory {
|
|
503
503
|
id: string;
|
|
504
504
|
productId: string;
|
|
505
|
+
productName?: string;
|
|
506
|
+
productSku?: string;
|
|
505
507
|
warehouseId: string;
|
|
508
|
+
warehouseName?: string;
|
|
506
509
|
zoneId: string;
|
|
507
510
|
quantity: number;
|
|
508
511
|
reservedQuantity: number;
|
|
@@ -746,11 +749,8 @@ export interface OrderFilter {
|
|
|
746
749
|
dateFrom?: Date;
|
|
747
750
|
dateTo?: Date;
|
|
748
751
|
priority?: string;
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
* (driverId is null). The backend DeliveryJobFilterInput has no null-driver
|
|
752
|
-
* predicate, so this is applied to the fetched page after mapping.
|
|
753
|
-
*/
|
|
752
|
+
search?: string;
|
|
753
|
+
/** Server-side predicate for orders that still need a driver assigned. */
|
|
754
754
|
unassigned?: boolean;
|
|
755
755
|
}
|
|
756
756
|
|
|
@@ -758,11 +758,13 @@ export interface FleetFilter {
|
|
|
758
758
|
vehicleType?: VehicleType;
|
|
759
759
|
status?: VehicleStatus;
|
|
760
760
|
driverId?: string;
|
|
761
|
+
search?: string;
|
|
761
762
|
}
|
|
762
763
|
|
|
763
764
|
export interface InventoryFilter {
|
|
764
765
|
warehouseId?: string;
|
|
765
766
|
productId?: string;
|
|
767
|
+
search?: string;
|
|
766
768
|
lowStock?: boolean;
|
|
767
769
|
}
|
|
768
770
|
|
|
@@ -68,3 +68,35 @@ export function parseQueryParams(search: string): Record<string, string> {
|
|
|
68
68
|
});
|
|
69
69
|
return params;
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
const CUSTOMER_RETURN_PATHS = [/^orders\/new$/, /^orders\/[^/?#]+\/edit$/];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Return only an internal order destination for customer create-and-return flows.
|
|
76
|
+
* Query strings are intentionally discarded so callers cannot smuggle a second
|
|
77
|
+
* return target or an open redirect through the customer form.
|
|
78
|
+
*/
|
|
79
|
+
export function getSafeCustomerReturnPath(value: string | null | undefined): string | null {
|
|
80
|
+
if (!value || value.length > 200 || value.includes('://') || value.startsWith('/')) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const [pathname] = value.split(/[?#]/, 1);
|
|
85
|
+
return CUSTOMER_RETURN_PATHS.some((pattern) => pattern.test(pathname)) ? pathname : null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Build an order route with a customer preselected after a customer is created.
|
|
90
|
+
*/
|
|
91
|
+
export function buildOrderCustomerPath(orderPath: string, customerId: string): string {
|
|
92
|
+
const safeOrderPath = getSafeCustomerReturnPath(orderPath);
|
|
93
|
+
return safeOrderPath ? buildUrl(safeOrderPath, { customerId }) : orderPath;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Build the local customer creation route while preserving a safe order return path.
|
|
98
|
+
*/
|
|
99
|
+
export function buildCustomerCreatePath(orderPath: string): string {
|
|
100
|
+
const safeOrderPath = getSafeCustomerReturnPath(orderPath);
|
|
101
|
+
return safeOrderPath ? buildUrl('customers/new', { returnTo: safeOrderPath }) : 'customers/new';
|
|
102
|
+
}
|