@burdenoff/microfe-movethewheels 2026.1114.1 → 2026.1123.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/MoveTheWheelsRoot.js +149 -133
- package/dist/MoveTheWheelsRoutes.js +157 -139
- package/dist/components/EntityConversationsCard.js +145 -0
- package/dist/components/maps/MapCanvas.js +4 -3
- package/dist/events/rybbit.js +87 -0
- package/dist/generated/tracking-quality-operations.d.ts +342 -0
- package/dist/hooks/useEntityComments.js +111 -0
- package/dist/hooks/useFleet.js +394 -311
- package/dist/hooks/useInventory.js +378 -313
- package/dist/hooks/useMultiModalShipments.js +58 -53
- package/dist/hooks/useOrders.js +178 -158
- package/dist/hooks/useRoutes.js +146 -130
- package/dist/index.js +35 -34
- package/dist/movethewheels/components/EntityConversationsCard.d.ts +8 -0
- package/dist/movethewheels/events/rybbit.d.ts +27 -0
- package/dist/movethewheels/hooks/useEntityComments.d.ts +26 -0
- package/dist/movethewheels/hooks/useFleet.d.ts +73 -1
- package/dist/movethewheels/hooks/useInventory.d.ts +19 -0
- package/dist/movethewheels/index.d.ts +1 -0
- package/dist/movethewheels/pages/DocumentsLibraryPage.d.ts +1 -0
- package/dist/movethewheels/pages/NotificationsCenterPage.d.ts +1 -0
- package/dist/movethewheels/types/index.d.ts +95 -2
- package/dist/node_modules/lucide-react/dist/esm/icons/check-check.js +10 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/layers.js +17 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/message-square.js +7 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/send.js +10 -0
- package/dist/pages/DocumentsLibraryPage.js +235 -0
- package/dist/pages/DriverDetailsPage.js +625 -351
- package/dist/pages/NotificationsCenterPage.js +310 -0
- package/dist/pages/OrderDetailsPage.js +48 -42
- package/dist/pages/RouteDetailsPage.js +257 -251
- package/dist/pages/TrackingPage.js +202 -196
- package/dist/pages/VehicleDetailsPage.js +616 -314
- package/dist/pages/WarehouseDetailsPage.js +539 -253
- package/dist/stories/ControlTowerWidgets.stories.d.ts +10 -0
- package/dist/stories/DataTable.stories.d.ts +15 -0
- package/dist/stories/FleetCards.stories.d.ts +9 -0
- package/dist/stories/OrderForms.stories.d.ts +8 -0
- package/dist/stories/RouteMap.stories.d.ts +7 -0
- package/dist/stories/ShipmentTimeline.stories.d.ts +6 -0
- package/package.json +3 -2
- package/src/generated/tracking-quality-operations.ts +407 -0
- package/src/movethewheels/MoveTheWheelsRoot.tsx +16 -0
- package/src/movethewheels/MoveTheWheelsRoutes.tsx +17 -2
- package/src/movethewheels/components/EntityConversationsCard.tsx +143 -0
- package/src/movethewheels/components/maps/MapCanvas.tsx +3 -3
- package/src/movethewheels/events/__tests__/rybbit.test.ts +98 -0
- package/src/movethewheels/events/rybbit.ts +191 -0
- package/src/movethewheels/hooks/useEntityComments.ts +258 -0
- package/src/movethewheels/hooks/useFleet.ts +300 -5
- package/src/movethewheels/hooks/useInventory.ts +231 -3
- package/src/movethewheels/hooks/useMultiModalShipments.ts +8 -1
- package/src/movethewheels/hooks/useOrders.ts +19 -3
- package/src/movethewheels/hooks/useRoutes.ts +14 -2
- package/src/movethewheels/index.ts +1 -0
- package/src/movethewheels/pages/DocumentsLibraryPage.tsx +229 -0
- package/src/movethewheels/pages/DriverDetailsPage.tsx +250 -1
- package/src/movethewheels/pages/NotificationsCenterPage.tsx +331 -0
- package/src/movethewheels/pages/OrderDetailsPage.tsx +8 -0
- package/src/movethewheels/pages/RouteDetailsPage.tsx +6 -0
- package/src/movethewheels/pages/TrackingPage.tsx +8 -0
- package/src/movethewheels/pages/VehicleDetailsPage.tsx +255 -1
- package/src/movethewheels/pages/WarehouseDetailsPage.tsx +266 -2
- package/src/movethewheels/types/index.ts +103 -2
- package/src/stories/ControlTowerWidgets.stories.tsx +150 -0
- package/src/stories/DataTable.stories.tsx +94 -0
- package/src/stories/FleetCards.stories.tsx +77 -0
- package/src/stories/OrderForms.stories.tsx +84 -0
- package/src/stories/RouteMap.stories.tsx +43 -0
- package/src/stories/ShipmentTimeline.stories.tsx +128 -0
|
@@ -341,6 +341,39 @@ export interface VehicleDocument {
|
|
|
341
341
|
verified: boolean;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
export interface VehicleDiagnostics {
|
|
345
|
+
engineStatus?: string;
|
|
346
|
+
batteryVoltage?: number;
|
|
347
|
+
coolantTempC?: number;
|
|
348
|
+
oilPressureKpa?: number;
|
|
349
|
+
faultCodes?: string[];
|
|
350
|
+
lastDiagnosticAt?: string;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface VehicleMaintenanceLog {
|
|
354
|
+
id: string;
|
|
355
|
+
vehicleId: string;
|
|
356
|
+
serviceDate: Date;
|
|
357
|
+
serviceType: string;
|
|
358
|
+
description: string;
|
|
359
|
+
mileage?: number;
|
|
360
|
+
cost?: number;
|
|
361
|
+
currency?: string;
|
|
362
|
+
vendor?: string;
|
|
363
|
+
notes?: string;
|
|
364
|
+
createdAt: Date;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface VehicleUtilizationSummary {
|
|
368
|
+
totalRoutes: number;
|
|
369
|
+
completedRoutes: number;
|
|
370
|
+
activeRoutes: number;
|
|
371
|
+
totalDeliveryJobs: number;
|
|
372
|
+
completedDeliveryJobs: number;
|
|
373
|
+
totalDistanceKm: number;
|
|
374
|
+
utilizationRate?: number;
|
|
375
|
+
}
|
|
376
|
+
|
|
344
377
|
export interface Vehicle {
|
|
345
378
|
id: string;
|
|
346
379
|
vehicleNumber: string;
|
|
@@ -370,7 +403,11 @@ export interface Vehicle {
|
|
|
370
403
|
fuelEfficiencyLPer100Km?: number;
|
|
371
404
|
fuelLevel?: number;
|
|
372
405
|
mileage?: number;
|
|
373
|
-
|
|
406
|
+
diagnostics?: VehicleDiagnostics;
|
|
407
|
+
maintenanceLogs?: VehicleMaintenanceLog[];
|
|
408
|
+
utilizationSummary?: VehicleUtilizationSummary;
|
|
409
|
+
/** Documents live in wspace-files-svc and are loaded via DocumentsCard. */
|
|
410
|
+
documents?: VehicleDocument[];
|
|
374
411
|
createdAt: Date;
|
|
375
412
|
}
|
|
376
413
|
|
|
@@ -385,6 +422,28 @@ export interface DriverDocument {
|
|
|
385
422
|
verified: boolean;
|
|
386
423
|
}
|
|
387
424
|
|
|
425
|
+
export interface DriverShift {
|
|
426
|
+
id: string;
|
|
427
|
+
driverId: string;
|
|
428
|
+
shiftDate: Date;
|
|
429
|
+
startTime: string;
|
|
430
|
+
endTime: string;
|
|
431
|
+
status: string;
|
|
432
|
+
maxHours?: number;
|
|
433
|
+
notes?: string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface DriverComplianceRecord {
|
|
437
|
+
id: string;
|
|
438
|
+
driverId: string;
|
|
439
|
+
recordType: string;
|
|
440
|
+
status: string;
|
|
441
|
+
issuedAt?: Date;
|
|
442
|
+
expiresAt?: Date;
|
|
443
|
+
referenceNumber?: string;
|
|
444
|
+
notes?: string;
|
|
445
|
+
}
|
|
446
|
+
|
|
388
447
|
export interface Driver {
|
|
389
448
|
id: string;
|
|
390
449
|
userId: string;
|
|
@@ -412,10 +471,49 @@ export interface Driver {
|
|
|
412
471
|
onLeaveUntil?: Date;
|
|
413
472
|
terminatedAt?: Date;
|
|
414
473
|
terminationReason?: string;
|
|
415
|
-
|
|
474
|
+
shifts?: DriverShift[];
|
|
475
|
+
complianceRecords?: DriverComplianceRecord[];
|
|
476
|
+
/** Documents live in wspace-files-svc and are loaded via DocumentsCard. */
|
|
477
|
+
documents?: DriverDocument[];
|
|
416
478
|
createdAt: Date;
|
|
417
479
|
}
|
|
418
480
|
|
|
481
|
+
export interface WarehouseZone {
|
|
482
|
+
id: string;
|
|
483
|
+
warehouseId: string;
|
|
484
|
+
code: string;
|
|
485
|
+
name: string;
|
|
486
|
+
zoneType: string;
|
|
487
|
+
temperatureRange?: string;
|
|
488
|
+
totalCapacity?: number;
|
|
489
|
+
usedCapacity?: number;
|
|
490
|
+
status: string;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export interface WarehouseStaffMember {
|
|
494
|
+
id: string;
|
|
495
|
+
warehouseId: string;
|
|
496
|
+
userId?: string;
|
|
497
|
+
name: string;
|
|
498
|
+
role: string;
|
|
499
|
+
shift?: string;
|
|
500
|
+
status: string;
|
|
501
|
+
contactEmail?: string;
|
|
502
|
+
contactPhone?: string;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export interface WarehouseMetrics {
|
|
506
|
+
totalLocations: number;
|
|
507
|
+
activeLocations: number;
|
|
508
|
+
zoneCount: number;
|
|
509
|
+
staffCount: number;
|
|
510
|
+
totalSkus: number;
|
|
511
|
+
totalOnHand: number;
|
|
512
|
+
totalAvailable: number;
|
|
513
|
+
lowStockCount: number;
|
|
514
|
+
utilizationPercent?: number;
|
|
515
|
+
}
|
|
516
|
+
|
|
419
517
|
// Warehouse type
|
|
420
518
|
export interface Warehouse {
|
|
421
519
|
id: string;
|
|
@@ -442,6 +540,9 @@ export interface Warehouse {
|
|
|
442
540
|
};
|
|
443
541
|
/** Real computed value: usedSpace / totalSpace, when both values are available. */
|
|
444
542
|
utilization?: number;
|
|
543
|
+
zones?: WarehouseZone[];
|
|
544
|
+
staff?: WarehouseStaffMember[];
|
|
545
|
+
metrics?: WarehouseMetrics;
|
|
445
546
|
createdAt: Date;
|
|
446
547
|
}
|
|
447
548
|
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
4
|
+
import { Package, Truck, AlertTriangle } from 'lucide-react';
|
|
5
|
+
import { MetricCard } from '../movethewheels/components/MetricCard';
|
|
6
|
+
import { FleetAlertsPanel } from '../movethewheels/components/FleetAlertsPanel';
|
|
7
|
+
import { TrackingAlertList } from '../movethewheels/components/TrackingAlertList';
|
|
8
|
+
import { MoveTheWheelsProvider } from '../movethewheels/providers/MoveTheWheelsProvider';
|
|
9
|
+
import type { FleetAlert } from '../movethewheels/hooks/useFleetIntelligence';
|
|
10
|
+
import type { TrackingAlert } from '../movethewheels/types';
|
|
11
|
+
|
|
12
|
+
const noopT = (_key: string, fallback: string) => fallback;
|
|
13
|
+
|
|
14
|
+
const SAMPLE_FLEET_ALERTS: FleetAlert[] = [
|
|
15
|
+
{
|
|
16
|
+
id: 'fa-1',
|
|
17
|
+
type: 'MAINTENANCE_OVERDUE',
|
|
18
|
+
severity: 'CRITICAL',
|
|
19
|
+
subjectType: 'VEHICLE',
|
|
20
|
+
subjectId: 'veh-101',
|
|
21
|
+
subjectName: 'MTW-101',
|
|
22
|
+
message: 'MTW-101 preventive service overdue',
|
|
23
|
+
dueDate: '2026-11-18T00:00:00.000Z',
|
|
24
|
+
daysUntilDue: -4,
|
|
25
|
+
kmUntilDue: -320,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'fa-2',
|
|
29
|
+
type: 'LICENSE_EXPIRING',
|
|
30
|
+
severity: 'WARNING',
|
|
31
|
+
subjectType: 'DRIVER',
|
|
32
|
+
subjectId: 'drv-202',
|
|
33
|
+
subjectName: 'Asha Rao',
|
|
34
|
+
message: 'Asha Rao commercial licence expiring soon',
|
|
35
|
+
dueDate: '2026-12-05T00:00:00.000Z',
|
|
36
|
+
daysUntilDue: 13,
|
|
37
|
+
kmUntilDue: null,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const SAMPLE_TRACKING_ALERTS: TrackingAlert[] = [
|
|
42
|
+
{
|
|
43
|
+
id: 'ta-1',
|
|
44
|
+
type: 'delay',
|
|
45
|
+
severity: 'high',
|
|
46
|
+
kind: 'AT_RISK',
|
|
47
|
+
shipmentId: 'shp-501',
|
|
48
|
+
shipmentNumber: 'SHP-2026-0501',
|
|
49
|
+
riskScore: 84,
|
|
50
|
+
message: 'Predicted arrival slips past customer promise window',
|
|
51
|
+
promisedDelivery: new Date('2026-11-23T14:00:00.000Z'),
|
|
52
|
+
predictedDelivery: new Date('2026-11-23T17:30:00.000Z'),
|
|
53
|
+
signals: ['WEATHER_CORRIDOR', 'LATE_DEPARTURE'],
|
|
54
|
+
acknowledged: false,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
function ControlTowerDashboardDemo({
|
|
59
|
+
onAcknowledge,
|
|
60
|
+
onOpenAlert,
|
|
61
|
+
}: {
|
|
62
|
+
onAcknowledge: (id: string) => Promise<void>;
|
|
63
|
+
onOpenAlert: (alert: FleetAlert) => void;
|
|
64
|
+
}) {
|
|
65
|
+
const [trackingAlerts, setTrackingAlerts] = useState(SAMPLE_TRACKING_ALERTS);
|
|
66
|
+
const [selectedFleetAlert, setSelectedFleetAlert] = useState<string | null>(null);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<MoveTheWheelsProvider basePath="/movethewheels" navigate={() => {}}>
|
|
70
|
+
<div className="space-y-6 max-w-4xl">
|
|
71
|
+
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
|
72
|
+
<MetricCard
|
|
73
|
+
icon={<Package size={20} />}
|
|
74
|
+
value="128"
|
|
75
|
+
label="Active shipments"
|
|
76
|
+
delta={{ value: '+6.2%', direction: 'up' }}
|
|
77
|
+
/>
|
|
78
|
+
<MetricCard
|
|
79
|
+
icon={<Truck size={20} />}
|
|
80
|
+
value="96.4%"
|
|
81
|
+
label="On-time delivery"
|
|
82
|
+
accent="success"
|
|
83
|
+
/>
|
|
84
|
+
<MetricCard
|
|
85
|
+
icon={<AlertTriangle size={20} />}
|
|
86
|
+
value={String(trackingAlerts.length)}
|
|
87
|
+
label="Open exceptions"
|
|
88
|
+
accent="warning"
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<TrackingAlertList
|
|
93
|
+
alerts={trackingAlerts}
|
|
94
|
+
limit={5}
|
|
95
|
+
t={noopT}
|
|
96
|
+
onAcknowledge={async (id) => {
|
|
97
|
+
await onAcknowledge(id);
|
|
98
|
+
setTrackingAlerts((prev) => prev.filter((item) => item.id !== id));
|
|
99
|
+
}}
|
|
100
|
+
onOpenOrder={() => {}}
|
|
101
|
+
onChanged={() => {}}
|
|
102
|
+
/>
|
|
103
|
+
|
|
104
|
+
<FleetAlertsPanel
|
|
105
|
+
alerts={SAMPLE_FLEET_ALERTS}
|
|
106
|
+
isLoading={false}
|
|
107
|
+
error={null}
|
|
108
|
+
onRetry={() => {}}
|
|
109
|
+
onOpen={(alert) => {
|
|
110
|
+
setSelectedFleetAlert(alert.subjectName);
|
|
111
|
+
onOpenAlert(alert);
|
|
112
|
+
}}
|
|
113
|
+
t={noopT}
|
|
114
|
+
/>
|
|
115
|
+
{selectedFleetAlert && (
|
|
116
|
+
<output aria-label="Selected fleet alert">Opened {selectedFleetAlert}</output>
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
</MoveTheWheelsProvider>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const meta: Meta<typeof ControlTowerDashboardDemo> = {
|
|
124
|
+
title: 'MoveTheWheels/ControlTowerWidgets',
|
|
125
|
+
component: ControlTowerDashboardDemo,
|
|
126
|
+
args: {
|
|
127
|
+
onAcknowledge: fn(async () => {}),
|
|
128
|
+
onOpenAlert: fn(),
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default meta;
|
|
133
|
+
type Story = StoryObj<typeof meta>;
|
|
134
|
+
|
|
135
|
+
export const OperationalAlertsInteraction: Story = {
|
|
136
|
+
play: async ({ canvasElement, args }) => {
|
|
137
|
+
const canvas = within(canvasElement);
|
|
138
|
+
await expect(canvas.getByText('Active shipments')).toBeInTheDocument();
|
|
139
|
+
await expect(canvas.getByText(/SHP-2026-0501/)).toBeInTheDocument();
|
|
140
|
+
|
|
141
|
+
await userEvent.click(canvas.getByRole('button', { name: /Acknowledge/i }));
|
|
142
|
+
await expect(args.onAcknowledge).toHaveBeenCalledWith('ta-1');
|
|
143
|
+
|
|
144
|
+
await userEvent.click(
|
|
145
|
+
canvas.getByRole('button', { name: /MTW-101 preventive service overdue/i })
|
|
146
|
+
);
|
|
147
|
+
await expect(args.onOpenAlert).toHaveBeenCalled();
|
|
148
|
+
await expect(canvas.getByLabelText('Selected fleet alert')).toHaveTextContent('Opened MTW-101');
|
|
149
|
+
},
|
|
150
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
4
|
+
import { DataTable, type Column } from '../movethewheels/components/DataTable';
|
|
5
|
+
import { StatusBadge } from '../movethewheels/components/StatusBadge';
|
|
6
|
+
|
|
7
|
+
interface ShipmentRow {
|
|
8
|
+
id: string;
|
|
9
|
+
shipmentNumber: string;
|
|
10
|
+
destination: string;
|
|
11
|
+
status: string;
|
|
12
|
+
weightKg: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const SAMPLE_ROWS: ShipmentRow[] = [
|
|
16
|
+
{
|
|
17
|
+
id: '1',
|
|
18
|
+
shipmentNumber: 'SHP-1001',
|
|
19
|
+
destination: 'Mumbai Hub',
|
|
20
|
+
status: 'in_transit',
|
|
21
|
+
weightKg: 420,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: '2',
|
|
25
|
+
shipmentNumber: 'SHP-1002',
|
|
26
|
+
destination: 'Delhi DC',
|
|
27
|
+
status: 'delivered',
|
|
28
|
+
weightKg: 180,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: '3',
|
|
32
|
+
shipmentNumber: 'SHP-1003',
|
|
33
|
+
destination: 'Bengaluru Port',
|
|
34
|
+
status: 'planned',
|
|
35
|
+
weightKg: 950,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const COLUMNS: Column<ShipmentRow>[] = [
|
|
40
|
+
{ id: 'shipmentNumber', header: 'Shipment', accessorKey: 'shipmentNumber', sortable: true },
|
|
41
|
+
{ id: 'destination', header: 'Destination', accessorKey: 'destination', sortable: true },
|
|
42
|
+
{
|
|
43
|
+
id: 'status',
|
|
44
|
+
header: 'Status',
|
|
45
|
+
cell: (row) => <StatusBadge status={row.status} type="order" size="sm" />,
|
|
46
|
+
},
|
|
47
|
+
{ id: 'weightKg', header: 'Weight (kg)', accessorKey: 'weightKg', sortable: true },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
function ShipmentsDataTableDemo({ onRowClick }: { onRowClick: (row: ShipmentRow) => void }) {
|
|
51
|
+
const [selected, setSelected] = useState<string>('');
|
|
52
|
+
return (
|
|
53
|
+
<div className="space-y-3">
|
|
54
|
+
<DataTable
|
|
55
|
+
columns={COLUMNS}
|
|
56
|
+
data={SAMPLE_ROWS}
|
|
57
|
+
searchable
|
|
58
|
+
searchPlaceholder="Search shipments..."
|
|
59
|
+
searchFields={['shipmentNumber', 'destination']}
|
|
60
|
+
getRowId={(row) => row.id}
|
|
61
|
+
onRowClick={(row) => {
|
|
62
|
+
setSelected(row.shipmentNumber);
|
|
63
|
+
onRowClick(row);
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
{selected && <output aria-label="Selected shipment">{selected}</output>}
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const meta: Meta<typeof ShipmentsDataTableDemo> = {
|
|
72
|
+
title: 'MoveTheWheels/DataTable',
|
|
73
|
+
component: ShipmentsDataTableDemo,
|
|
74
|
+
args: {
|
|
75
|
+
onRowClick: fn(),
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default meta;
|
|
80
|
+
type Story = StoryObj<typeof meta>;
|
|
81
|
+
|
|
82
|
+
export const SearchSortAndSelect: Story = {
|
|
83
|
+
play: async ({ canvasElement, args }) => {
|
|
84
|
+
const canvas = within(canvasElement);
|
|
85
|
+
const search = canvas.getByPlaceholderText('Search shipments...');
|
|
86
|
+
await userEvent.type(search, 'Delhi');
|
|
87
|
+
await expect(canvas.getAllByText('SHP-1002').length).toBeGreaterThan(0);
|
|
88
|
+
await expect(canvas.queryByText('SHP-1001')).toBeNull();
|
|
89
|
+
|
|
90
|
+
await userEvent.click(canvas.getAllByText('SHP-1002')[0]);
|
|
91
|
+
await expect(args.onRowClick).toHaveBeenCalled();
|
|
92
|
+
await expect(canvas.getByLabelText('Selected shipment')).toHaveTextContent('SHP-1002');
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
4
|
+
import { VehicleServiceCard } from '../movethewheels/components/VehicleServiceCard';
|
|
5
|
+
import type { RecordVehicleServiceInput } from '../movethewheels/hooks/useFleetIntelligence';
|
|
6
|
+
import type { Vehicle } from '../movethewheels/types';
|
|
7
|
+
|
|
8
|
+
const noopT = (_key: string, fallback: string) => fallback;
|
|
9
|
+
|
|
10
|
+
const SAMPLE_VEHICLE: Vehicle = {
|
|
11
|
+
id: 'veh-301',
|
|
12
|
+
vehicleNumber: 'MTW-301',
|
|
13
|
+
type: 'truck',
|
|
14
|
+
make: 'Volvo',
|
|
15
|
+
model: 'FH16',
|
|
16
|
+
licensePlate: 'KA-01-MT-301',
|
|
17
|
+
status: 'available',
|
|
18
|
+
capacity: { weight: 18000, volume: 65, pallets: 24 },
|
|
19
|
+
driverIds: ['drv-1'],
|
|
20
|
+
mileage: 84200,
|
|
21
|
+
fuelLevel: 78,
|
|
22
|
+
fuelType: 'DIESEL',
|
|
23
|
+
lastMaintenance: new Date('2026-08-15T12:00:00.000Z'),
|
|
24
|
+
nextMaintenance: new Date('2026-11-30T12:00:00.000Z'),
|
|
25
|
+
nextMaintenanceMileage: 94200,
|
|
26
|
+
documents: [],
|
|
27
|
+
createdAt: new Date('2026-01-10T00:00:00.000Z'),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function FleetServiceCardDemo({
|
|
31
|
+
onRecord,
|
|
32
|
+
}: {
|
|
33
|
+
onRecord: (input: RecordVehicleServiceInput) => Promise<void>;
|
|
34
|
+
}) {
|
|
35
|
+
const [savedMileage, setSavedMileage] = useState<number | null>(null);
|
|
36
|
+
return (
|
|
37
|
+
<div className="max-w-md space-y-3">
|
|
38
|
+
<VehicleServiceCard
|
|
39
|
+
vehicle={SAMPLE_VEHICLE}
|
|
40
|
+
t={noopT}
|
|
41
|
+
onRecord={async (input) => {
|
|
42
|
+
await onRecord(input);
|
|
43
|
+
setSavedMileage(input.mileage ?? null);
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
{savedMileage !== null && (
|
|
47
|
+
<output aria-label="Recorded service mileage">Recorded at {savedMileage} km</output>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const meta: Meta<typeof FleetServiceCardDemo> = {
|
|
54
|
+
title: 'MoveTheWheels/FleetCards',
|
|
55
|
+
component: FleetServiceCardDemo,
|
|
56
|
+
args: {
|
|
57
|
+
onRecord: fn(async () => {}),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default meta;
|
|
62
|
+
type Story = StoryObj<typeof meta>;
|
|
63
|
+
|
|
64
|
+
export const RecordVehicleServiceFlow: Story = {
|
|
65
|
+
play: async ({ canvasElement, args }) => {
|
|
66
|
+
const canvas = within(canvasElement);
|
|
67
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Record service' }));
|
|
68
|
+
const mileageInput = canvas.getByLabelText('Odometer (km)');
|
|
69
|
+
await userEvent.clear(mileageInput);
|
|
70
|
+
await userEvent.type(mileageInput, '85000');
|
|
71
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Save service' }));
|
|
72
|
+
await expect(args.onRecord).toHaveBeenCalled();
|
|
73
|
+
await expect(canvas.getByLabelText('Recorded service mileage')).toHaveTextContent(
|
|
74
|
+
'Recorded at 85000 km'
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
4
|
+
import { OrderItemRow } from '../movethewheels/components/OrderItemRow';
|
|
5
|
+
import { MoveTheWheelsProvider } from '../movethewheels/providers/MoveTheWheelsProvider';
|
|
6
|
+
import type { OrderItem, Product } from '../movethewheels/types';
|
|
7
|
+
|
|
8
|
+
const SAMPLE_PRODUCTS: Product[] = [
|
|
9
|
+
{
|
|
10
|
+
id: 'prod-1',
|
|
11
|
+
sku: 'SKU-PALLET-01',
|
|
12
|
+
name: 'Industrial Pump Assembly',
|
|
13
|
+
weight: 42.5,
|
|
14
|
+
value: 1450,
|
|
15
|
+
dimensions: { length: 80, width: 60, height: 55, unit: 'cm' },
|
|
16
|
+
images: [],
|
|
17
|
+
attributes: [],
|
|
18
|
+
hazardous: false,
|
|
19
|
+
temperatureControlled: false,
|
|
20
|
+
fragile: false,
|
|
21
|
+
createdAt: new Date('2026-10-01T00:00:00.000Z'),
|
|
22
|
+
updatedAt: new Date('2026-10-01T00:00:00.000Z'),
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
function OrderFormLinesDemo({ onRemove }: { onRemove: (index: number) => void }) {
|
|
27
|
+
const [item, setItem] = useState<OrderItem>({
|
|
28
|
+
id: 'line-1',
|
|
29
|
+
productId: '',
|
|
30
|
+
name: 'Standard Freight Crate',
|
|
31
|
+
sku: 'CRATE-10',
|
|
32
|
+
quantity: 2,
|
|
33
|
+
weight: 18,
|
|
34
|
+
value: 500,
|
|
35
|
+
dimensions: { length: 50, width: 40, height: 35, unit: 'cm' },
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const handleUpdate = (_index: number, field: string, value: unknown) => {
|
|
39
|
+
setItem((prev) => ({ ...prev, [field]: value }));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<MoveTheWheelsProvider basePath="/movethewheels" navigate={() => {}}>
|
|
44
|
+
<div className="max-w-3xl space-y-4">
|
|
45
|
+
<OrderItemRow
|
|
46
|
+
item={item}
|
|
47
|
+
index={0}
|
|
48
|
+
products={SAMPLE_PRODUCTS}
|
|
49
|
+
productsLoading={false}
|
|
50
|
+
errors={item.quantity <= 0 ? { quantity: 'Quantity must be at least 1' } : {}}
|
|
51
|
+
onUpdate={handleUpdate}
|
|
52
|
+
onRemove={onRemove}
|
|
53
|
+
/>
|
|
54
|
+
<output aria-label="Order line summary">
|
|
55
|
+
{item.name} × {item.quantity}
|
|
56
|
+
</output>
|
|
57
|
+
</div>
|
|
58
|
+
</MoveTheWheelsProvider>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const meta: Meta<typeof OrderFormLinesDemo> = {
|
|
63
|
+
title: 'MoveTheWheels/OrderForms',
|
|
64
|
+
component: OrderFormLinesDemo,
|
|
65
|
+
args: {
|
|
66
|
+
onRemove: fn(),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default meta;
|
|
71
|
+
type Story = StoryObj<typeof meta>;
|
|
72
|
+
|
|
73
|
+
export const EditLineItemInteraction: Story = {
|
|
74
|
+
play: async ({ canvasElement }) => {
|
|
75
|
+
const canvas = within(canvasElement);
|
|
76
|
+
await expect(canvas.getByText('Item 1')).toBeInTheDocument();
|
|
77
|
+
const nameInput = canvas.getByDisplayValue('Standard Freight Crate');
|
|
78
|
+
await userEvent.clear(nameInput);
|
|
79
|
+
await userEvent.type(nameInput, 'Express Medical Kit');
|
|
80
|
+
await expect(canvas.getByLabelText('Order line summary')).toHaveTextContent(
|
|
81
|
+
'Express Medical Kit × 2'
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { expect, within } from 'storybook/test';
|
|
3
|
+
import { RouteMap, type RouteStop } from '../movethewheels/components/maps/RouteMap';
|
|
4
|
+
|
|
5
|
+
const SAMPLE_STOPS: RouteStop[] = [
|
|
6
|
+
{ lat: 12.9716, lng: 77.5946, label: 'Bengaluru Fulfillment Hub', sequence: 1 },
|
|
7
|
+
{ lat: 13.0827, lng: 80.2707, label: 'Chennai Port Gate', sequence: 2 },
|
|
8
|
+
{ lat: 17.385, lng: 78.4867, label: 'Hyderabad Regional DC', sequence: 3 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof RouteMap> = {
|
|
12
|
+
title: 'MoveTheWheels/RouteMap',
|
|
13
|
+
component: RouteMap,
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: 'padded',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof meta>;
|
|
21
|
+
|
|
22
|
+
export const MultiStopRoute: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
stops: SAMPLE_STOPS,
|
|
25
|
+
height: 360,
|
|
26
|
+
},
|
|
27
|
+
play: async ({ canvasElement }) => {
|
|
28
|
+
const container = canvasElement.querySelector('.leaflet-container');
|
|
29
|
+
await expect(container).not.toBeNull();
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const EmptyRouteStops: Story = {
|
|
34
|
+
args: {
|
|
35
|
+
stops: [],
|
|
36
|
+
height: 280,
|
|
37
|
+
emptyMessage: 'No stops with coordinates yet',
|
|
38
|
+
},
|
|
39
|
+
play: async ({ canvasElement }) => {
|
|
40
|
+
const canvas = within(canvasElement);
|
|
41
|
+
await expect(canvas.getByText('No stops with coordinates yet')).toBeInTheDocument();
|
|
42
|
+
},
|
|
43
|
+
};
|