@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.
Files changed (70) hide show
  1. package/dist/MoveTheWheelsRoot.js +149 -133
  2. package/dist/MoveTheWheelsRoutes.js +157 -139
  3. package/dist/components/EntityConversationsCard.js +145 -0
  4. package/dist/components/maps/MapCanvas.js +4 -3
  5. package/dist/events/rybbit.js +87 -0
  6. package/dist/generated/tracking-quality-operations.d.ts +342 -0
  7. package/dist/hooks/useEntityComments.js +111 -0
  8. package/dist/hooks/useFleet.js +394 -311
  9. package/dist/hooks/useInventory.js +378 -313
  10. package/dist/hooks/useMultiModalShipments.js +58 -53
  11. package/dist/hooks/useOrders.js +178 -158
  12. package/dist/hooks/useRoutes.js +146 -130
  13. package/dist/index.js +35 -34
  14. package/dist/movethewheels/components/EntityConversationsCard.d.ts +8 -0
  15. package/dist/movethewheels/events/rybbit.d.ts +27 -0
  16. package/dist/movethewheels/hooks/useEntityComments.d.ts +26 -0
  17. package/dist/movethewheels/hooks/useFleet.d.ts +73 -1
  18. package/dist/movethewheels/hooks/useInventory.d.ts +19 -0
  19. package/dist/movethewheels/index.d.ts +1 -0
  20. package/dist/movethewheels/pages/DocumentsLibraryPage.d.ts +1 -0
  21. package/dist/movethewheels/pages/NotificationsCenterPage.d.ts +1 -0
  22. package/dist/movethewheels/types/index.d.ts +95 -2
  23. package/dist/node_modules/lucide-react/dist/esm/icons/check-check.js +10 -0
  24. package/dist/node_modules/lucide-react/dist/esm/icons/layers.js +17 -0
  25. package/dist/node_modules/lucide-react/dist/esm/icons/message-square.js +7 -0
  26. package/dist/node_modules/lucide-react/dist/esm/icons/send.js +10 -0
  27. package/dist/pages/DocumentsLibraryPage.js +235 -0
  28. package/dist/pages/DriverDetailsPage.js +625 -351
  29. package/dist/pages/NotificationsCenterPage.js +310 -0
  30. package/dist/pages/OrderDetailsPage.js +48 -42
  31. package/dist/pages/RouteDetailsPage.js +257 -251
  32. package/dist/pages/TrackingPage.js +202 -196
  33. package/dist/pages/VehicleDetailsPage.js +616 -314
  34. package/dist/pages/WarehouseDetailsPage.js +539 -253
  35. package/dist/stories/ControlTowerWidgets.stories.d.ts +10 -0
  36. package/dist/stories/DataTable.stories.d.ts +15 -0
  37. package/dist/stories/FleetCards.stories.d.ts +9 -0
  38. package/dist/stories/OrderForms.stories.d.ts +8 -0
  39. package/dist/stories/RouteMap.stories.d.ts +7 -0
  40. package/dist/stories/ShipmentTimeline.stories.d.ts +6 -0
  41. package/package.json +3 -2
  42. package/src/generated/tracking-quality-operations.ts +407 -0
  43. package/src/movethewheels/MoveTheWheelsRoot.tsx +16 -0
  44. package/src/movethewheels/MoveTheWheelsRoutes.tsx +17 -2
  45. package/src/movethewheels/components/EntityConversationsCard.tsx +143 -0
  46. package/src/movethewheels/components/maps/MapCanvas.tsx +3 -3
  47. package/src/movethewheels/events/__tests__/rybbit.test.ts +98 -0
  48. package/src/movethewheels/events/rybbit.ts +191 -0
  49. package/src/movethewheels/hooks/useEntityComments.ts +258 -0
  50. package/src/movethewheels/hooks/useFleet.ts +300 -5
  51. package/src/movethewheels/hooks/useInventory.ts +231 -3
  52. package/src/movethewheels/hooks/useMultiModalShipments.ts +8 -1
  53. package/src/movethewheels/hooks/useOrders.ts +19 -3
  54. package/src/movethewheels/hooks/useRoutes.ts +14 -2
  55. package/src/movethewheels/index.ts +1 -0
  56. package/src/movethewheels/pages/DocumentsLibraryPage.tsx +229 -0
  57. package/src/movethewheels/pages/DriverDetailsPage.tsx +250 -1
  58. package/src/movethewheels/pages/NotificationsCenterPage.tsx +331 -0
  59. package/src/movethewheels/pages/OrderDetailsPage.tsx +8 -0
  60. package/src/movethewheels/pages/RouteDetailsPage.tsx +6 -0
  61. package/src/movethewheels/pages/TrackingPage.tsx +8 -0
  62. package/src/movethewheels/pages/VehicleDetailsPage.tsx +255 -1
  63. package/src/movethewheels/pages/WarehouseDetailsPage.tsx +266 -2
  64. package/src/movethewheels/types/index.ts +103 -2
  65. package/src/stories/ControlTowerWidgets.stories.tsx +150 -0
  66. package/src/stories/DataTable.stories.tsx +94 -0
  67. package/src/stories/FleetCards.stories.tsx +77 -0
  68. package/src/stories/OrderForms.stories.tsx +84 -0
  69. package/src/stories/RouteMap.stories.tsx +43 -0
  70. package/src/stories/ShipmentTimeline.stories.tsx +128 -0
@@ -27,6 +27,8 @@ import {
27
27
  Settings,
28
28
  Plug,
29
29
  FileBarChart,
30
+ Bell,
31
+ FileText,
30
32
  } from 'lucide-react';
31
33
  import { MoveTheWheelsProvider } from './providers/MoveTheWheelsProvider';
32
34
  import { ModuleSettingsProvider } from './providers/ModuleSettingsProvider';
@@ -309,6 +311,20 @@ const NavRegistrar: FC<Pick<MoveTheWheelsRootProps, 'registerNavItems' | 'basePa
309
311
  icon: <FileBarChart size={16} />,
310
312
  order: 10,
311
313
  },
314
+ {
315
+ id: 'mtw-documents',
316
+ label: tr('movethewheels.root.nav.documents', 'Documents'),
317
+ path: joinPath(basePath, 'documents'),
318
+ icon: <FileText size={16} />,
319
+ order: 11,
320
+ },
321
+ {
322
+ id: 'mtw-notifications',
323
+ label: tr('movethewheels.root.nav.notifications', 'Notifications'),
324
+ path: joinPath(basePath, 'notifications'),
325
+ icon: <Bell size={16} />,
326
+ order: 12,
327
+ },
312
328
  {
313
329
  id: 'mtw-ai-assistant',
314
330
  label: tr('movethewheels.root.nav.aiOperations', 'AI Operations'),
@@ -5,12 +5,14 @@
5
5
  * Uses lazy loading for code splitting.
6
6
  */
7
7
 
8
- import { Routes, Route, Navigate, useNavigate } from 'react-router';
9
- import { lazy, Suspense } from 'react';
8
+ import { Routes, Route, Navigate, useLocation, useNavigate } from 'react-router';
9
+ import { lazy, Suspense, useEffect } from 'react';
10
10
  import { NotFoundPage } from '@burdenoff/fe-libs/shared/pages';
11
+ import { useEventBus } from '@burdenoff/fe-libs/shared/events';
11
12
  import { useMoveTheWheels } from './providers/MoveTheWheelsProvider';
12
13
  import { useModuleSettings } from './providers/ModuleSettingsProvider';
13
14
  import { useTr } from './hooks';
15
+ import { emitPageViewed } from './events/rybbit';
14
16
 
15
17
  /**
16
18
  * Catch-all 404 rendered inside the content area (previously a redirect to ""
@@ -98,12 +100,21 @@ const TripUtilizationPage = lazy(() => import('./pages/TripUtilizationPage'));
98
100
  const DispatchPlanPage = lazy(() => import('./pages/DispatchPlanPage'));
99
101
  const ConsumedFuelPreviewPage = lazy(() => import('./pages/ConsumedFuelPreviewPage'));
100
102
  const EmptyReusePage = lazy(() => import('./pages/EmptyReusePage'));
103
+ const NotificationsCenterPage = lazy(() => import('./pages/NotificationsCenterPage'));
104
+ const DocumentsLibraryPage = lazy(() => import('./pages/DocumentsLibraryPage'));
101
105
 
102
106
  export function MoveTheWheelsRoutes() {
103
107
  // Subscribing here re-renders every page when the workspace's display
104
108
  // defaults load or change, so amounts, units and dates follow them
105
109
  // (BOFF-10488). The value itself is read through the shared formatters.
106
110
  useModuleSettings();
111
+ const bus = useEventBus();
112
+ const location = useLocation();
113
+ const { workspaceId } = useMoveTheWheels();
114
+
115
+ useEffect(() => {
116
+ emitPageViewed(bus, location.pathname, workspaceId);
117
+ }, [bus, location.pathname, workspaceId]);
107
118
  return (
108
119
  <Suspense fallback={<PageLoader />}>
109
120
  <Routes>
@@ -178,6 +189,10 @@ export function MoveTheWheelsRoutes() {
178
189
  {/* Workspace operational defaults: currency, units, time zone (BOFF-10488) */}
179
190
  <Route path="settings" element={<SettingsPage />} />
180
191
 
192
+ {/* In-product notifications center and workspace documents hub (BOFF-3992) */}
193
+ <Route path="notifications" element={<NotificationsCenterPage />} />
194
+ <Route path="documents" element={<DocumentsLibraryPage />} />
195
+
181
196
  {/* Carrier, ELD and GPS tracking feeds as signed webhooks (BOFF-4404) */}
182
197
  <Route path="integrations" element={<IntegrationsPage />} />
183
198
 
@@ -0,0 +1,143 @@
1
+ /**
2
+ * EntityConversationsCard — embedded entity-level conversation threads (BOFF-3992).
3
+ *
4
+ * Mounts on Order, Shipment, and Route detail pages and consumes
5
+ * `wspace-conversations-svc` through `useEntityComments`. Enforces ownership
6
+ * cues (delete shown for author's own comments) and links to the full
7
+ * workspace `/conversations` center.
8
+ */
9
+ import { useState, type FormEvent } from 'react';
10
+ import { MessageSquare, Send, CheckCircle2, Trash2, ExternalLink } from 'lucide-react';
11
+ import { Badge, Button, Card, CardContent, CardHeader, CardTitle, Textarea } from './ui';
12
+ import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
13
+ import { useEntityComments, type ConversationEntityType } from '../hooks/useEntityComments';
14
+ import { formatDate } from '../utils/formatters';
15
+
16
+ interface EntityConversationsCardProps {
17
+ entityType: ConversationEntityType;
18
+ entityId: string;
19
+ title?: string;
20
+ }
21
+
22
+ export function EntityConversationsCard({
23
+ entityType,
24
+ entityId,
25
+ title = 'Conversations',
26
+ }: EntityConversationsCardProps) {
27
+ const { navigate } = useMoveTheWheels();
28
+ const {
29
+ comments,
30
+ total,
31
+ isLoading,
32
+ isSubmitting,
33
+ error,
34
+ addComment,
35
+ toggleResolve,
36
+ deleteComment,
37
+ currentUserId,
38
+ } = useEntityComments(entityType, entityId);
39
+ const [draft, setDraft] = useState('');
40
+ const [actionError, setActionError] = useState<string | null>(null);
41
+
42
+ const handleSubmit = async (event: FormEvent) => {
43
+ event.preventDefault();
44
+ if (!draft.trim()) return;
45
+ setActionError(null);
46
+ try {
47
+ await addComment(draft);
48
+ setDraft('');
49
+ } catch (err) {
50
+ setActionError(err instanceof Error ? err.message : 'Failed to post message.');
51
+ }
52
+ };
53
+
54
+ return (
55
+ <Card data-testid={`entity-conversations-${entityType}`}>
56
+ <CardHeader className="flex flex-row items-center justify-between gap-2">
57
+ <CardTitle className="flex items-center gap-2">
58
+ <MessageSquare size={18} aria-hidden="true" />
59
+ <span>{title}</span>
60
+ {total > 0 && <Badge variant="secondary">{total}</Badge>}
61
+ </CardTitle>
62
+ <Button variant="ghost" size="sm" onClick={() => navigate('/conversations')}>
63
+ <ExternalLink size={14} aria-hidden="true" /> All threads
64
+ </Button>
65
+ </CardHeader>
66
+ <CardContent className="space-y-4">
67
+ {error && <p className="text-sm text-status-error-text">{error.message}</p>}
68
+ {actionError && <p className="text-sm text-status-error-text">{actionError}</p>}
69
+
70
+ {isLoading ? (
71
+ <p className="text-sm text-text-secondary py-2">Loading conversation…</p>
72
+ ) : comments.length === 0 ? (
73
+ <p className="text-sm text-text-secondary py-2">
74
+ No notes or comments on this record yet. Start a thread for dispatchers, drivers, or
75
+ ops.
76
+ </p>
77
+ ) : (
78
+ <ul className="space-y-3" aria-label={title}>
79
+ {comments.map((comment) => {
80
+ const isResolved = comment.status.toUpperCase() === 'RESOLVED';
81
+ const isOwn = Boolean(currentUserId && comment.authorId === currentUserId);
82
+ return (
83
+ <li
84
+ key={comment.id}
85
+ className="rounded-lg border border-border-seam bg-bg-surface p-3 space-y-2"
86
+ >
87
+ <div className="flex items-center justify-between gap-2 text-xs text-text-secondary">
88
+ <span className="font-medium text-text-primary">
89
+ {isOwn ? 'You' : `Member ${comment.authorId.slice(0, 8)}`}
90
+ </span>
91
+ <div className="flex items-center gap-2">
92
+ {isResolved && <Badge variant="outline">Resolved</Badge>}
93
+ <span>{formatDate(comment.createdAt, 'relative')}</span>
94
+ </div>
95
+ </div>
96
+ <p className="text-sm whitespace-pre-wrap text-text-primary">{comment.text}</p>
97
+ <div className="flex items-center gap-2 pt-1">
98
+ <Button
99
+ type="button"
100
+ variant="ghost"
101
+ size="sm"
102
+ onClick={() => void toggleResolve(comment.id, !isResolved)}
103
+ >
104
+ <CheckCircle2 size={14} aria-hidden="true" />
105
+ {isResolved ? 'Reopen' : 'Resolve'}
106
+ </Button>
107
+ {isOwn && (
108
+ <Button
109
+ type="button"
110
+ variant="ghost"
111
+ size="sm"
112
+ className="text-status-error-text"
113
+ onClick={() => void deleteComment(comment.id)}
114
+ >
115
+ <Trash2 size={14} aria-hidden="true" /> Delete
116
+ </Button>
117
+ )}
118
+ </div>
119
+ </li>
120
+ );
121
+ })}
122
+ </ul>
123
+ )}
124
+
125
+ <form onSubmit={handleSubmit} className="space-y-2 border-t border-border-seam pt-3">
126
+ <Textarea
127
+ value={draft}
128
+ onChange={(event) => setDraft(event.target.value)}
129
+ placeholder="Add an operational update or dispatch note..."
130
+ rows={2}
131
+ aria-label="New conversation message"
132
+ />
133
+ <div className="flex justify-end">
134
+ <Button type="submit" size="sm" disabled={isSubmitting || !draft.trim()}>
135
+ <Send size={14} aria-hidden="true" />
136
+ {isSubmitting ? 'Posting…' : 'Post note'}
137
+ </Button>
138
+ </div>
139
+ </form>
140
+ </CardContent>
141
+ </Card>
142
+ );
143
+ }
@@ -27,18 +27,18 @@ export function FitBounds({
27
27
  const map = useMap();
28
28
 
29
29
  useEffect(() => {
30
- const t = setTimeout(() => map.invalidateSize(), 0);
30
+ const t = setTimeout(() => map.invalidateSize({ animate: false }), 0);
31
31
  return () => clearTimeout(t);
32
32
  }, [map]);
33
33
 
34
34
  useEffect(() => {
35
35
  if (points.length === 0) return;
36
36
  if (points.length === 1) {
37
- map.setView(points[0], Math.min(maxZoom, 12));
37
+ map.setView(points[0], Math.min(maxZoom, 12), { animate: false });
38
38
  return;
39
39
  }
40
40
  const bounds = L.latLngBounds(points);
41
- map.fitBounds(bounds, { padding: [padding, padding], maxZoom });
41
+ map.fitBounds(bounds, { padding: [padding, padding], maxZoom, animate: false });
42
42
  }, [map, points, padding, maxZoom]);
43
43
 
44
44
  return null;
@@ -0,0 +1,98 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import type { EventBus } from '@burdenoff/fe-libs/shared/events';
3
+ import {
4
+ MOVETHEWHEELS_RYBBIT_EVENT_ALLOWLIST,
5
+ emitDeliveryJobAssigned,
6
+ emitOrderCreated,
7
+ emitPageViewed,
8
+ emitRoutePlanned,
9
+ emitShipmentCreated,
10
+ emitShipmentDelivered,
11
+ emitVehicleAssigned,
12
+ emitVehicleServiceRecorded,
13
+ emitWarehouseInboundReceived,
14
+ normalizeAnalyticsPagePath,
15
+ } from '../rybbit';
16
+
17
+ type EmittedEvent = {
18
+ name: string;
19
+ payload: Record<string, unknown>;
20
+ meta?: Record<string, unknown>;
21
+ };
22
+
23
+ function makeBus(): { events: EmittedEvent[]; bus: EventBus } {
24
+ const events: EmittedEvent[] = [];
25
+ const bus: EventBus = {
26
+ emit() {},
27
+ emitCustom(name, payload, meta) {
28
+ events.push({
29
+ name,
30
+ payload: (payload ?? {}) as Record<string, unknown>,
31
+ meta: meta as Record<string, unknown> | undefined,
32
+ });
33
+ },
34
+ on() {
35
+ return () => {};
36
+ },
37
+ once() {
38
+ return () => {};
39
+ },
40
+ onAny() {
41
+ return () => {};
42
+ },
43
+ getBuffer() {
44
+ return [];
45
+ },
46
+ };
47
+ return { events, bus };
48
+ }
49
+
50
+ describe('rybbit privacy-safe MoveTheWheels analytics emitters (BOFF-3327)', () => {
51
+ it('strips query strings, hashes, UUIDs, and numeric IDs from route paths', () => {
52
+ expect(
53
+ normalizeAnalyticsPagePath(
54
+ '/movethewheels/orders/550e8400-e29b-41d4-a716-446655440000/edit?email=a@b.com#top'
55
+ )
56
+ ).toBe('/movethewheels/orders/:id/edit');
57
+ expect(normalizeAnalyticsPagePath('/movethewheels/fleet/vehicles/1234567890')).toBe(
58
+ '/movethewheels/fleet/vehicles/:id'
59
+ );
60
+ });
61
+
62
+ it('emits canonical MoveTheWheels analytics events without PII', () => {
63
+ const { bus, events } = makeBus();
64
+ emitPageViewed(bus, '/movethewheels/orders/550e8400-e29b-41d4-a716-446655440000', 'ws-1');
65
+ emitOrderCreated(bus, 'ord-1', 'ws-1', { priority: 'HIGH', itemCount: 3 });
66
+ emitDeliveryJobAssigned(bus, 'ord-1', 'ws-1', { hasDriver: true, hasVehicle: true });
67
+ emitShipmentCreated(bus, 'shp-1', 'ws-1', { mode: 'ROAD', isMultiModal: true });
68
+ emitShipmentDelivered(bus, 'shp-1', 'ws-1');
69
+ emitRoutePlanned(bus, 'rt-1', 'ws-1', { stopCount: 6, optimized: true });
70
+ emitVehicleAssigned(bus, 'veh-1', 'drv-1', 'ws-1');
71
+ emitVehicleServiceRecorded(bus, 'veh-1', 'ws-1', 'PREVENTIVE');
72
+ emitWarehouseInboundReceived(bus, 'wh-1', 'inv-1', 'ws-1');
73
+
74
+ const emittedNames = events.map((event) => event.name);
75
+ expect(emittedNames).toEqual([
76
+ 'movethewheels.page.viewed',
77
+ 'movethewheels.order.created',
78
+ 'movethewheels.delivery_job.assigned',
79
+ 'movethewheels.shipment.created',
80
+ 'movethewheels.shipment.delivered',
81
+ 'movethewheels.route.planned',
82
+ 'movethewheels.vehicle.assigned',
83
+ 'movethewheels.vehicle.service_recorded',
84
+ 'movethewheels.warehouse.inbound_received',
85
+ ]);
86
+
87
+ for (const name of emittedNames) {
88
+ expect(MOVETHEWHEELS_RYBBIT_EVENT_ALLOWLIST as readonly string[]).toContain(name);
89
+ }
90
+
91
+ expect(events[0]?.payload).toEqual({
92
+ workspaceId: 'ws-1',
93
+ path: '/movethewheels/orders/:id',
94
+ product: 'movethewheels',
95
+ });
96
+ expect(JSON.stringify(events)).not.toContain('550e8400');
97
+ });
98
+ });
@@ -0,0 +1,191 @@
1
+ /**
2
+ * MoveTheWheels Rybbit & platform product-analytics emitters (BOFF-3327).
3
+ *
4
+ * Emits canonical `movethewheels.<area>.<fact>` events onto the shared fe-libs
5
+ * event bus after mutations succeed or routes change. The host shell's
6
+ * RybbitSink forwards allowlisted events to Rybbit Cloud (after privacy consent)
7
+ * and strips identifier/PII keys before transmission.
8
+ *
9
+ * Payload rule: IDs and non-PII enum/dimension values ONLY — never emails,
10
+ * customer names, phone numbers, street addresses, or free text.
11
+ */
12
+ import type { EventBus } from '@burdenoff/fe-libs/shared/events';
13
+
14
+ /** Canonical MoveTheWheels product events aligned with ANALYTICS_PLAN.md and fe-libs AppShellProvider. */
15
+ export const MOVETHEWHEELS_RYBBIT_EVENT_ALLOWLIST = [
16
+ 'movethewheels.page.viewed',
17
+ 'movethewheels.order.created',
18
+ 'movethewheels.shipment.created',
19
+ 'movethewheels.shipment.delivered',
20
+ 'movethewheels.delivery_job.assigned',
21
+ 'movethewheels.route.planned',
22
+ 'movethewheels.vehicle.assigned',
23
+ 'movethewheels.warehouse.inbound_received',
24
+ 'movethewheels.vehicle.service_recorded',
25
+ 'billing.plan.upgraded',
26
+ ] as const;
27
+
28
+ export type MoveTheWheelsAnalyticsEventName = (typeof MOVETHEWHEELS_RYBBIT_EVENT_ALLOWLIST)[number];
29
+
30
+ /** Sanitize pathname to strip UUID/ID segments before emitting page views. */
31
+ export function normalizeAnalyticsPagePath(pathname: string): string {
32
+ const clean = pathname.split('?')[0]?.split('#')[0] ?? '/';
33
+ return clean
34
+ .replace(/\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?=\/|$)/gi, '/:id')
35
+ .replace(/\/[0-9]{4,}(?=\/|$)/g, '/:id');
36
+ }
37
+
38
+ function ws(workspaceId?: string | null): string | undefined {
39
+ return workspaceId ?? undefined;
40
+ }
41
+
42
+ export function emitPageViewed(bus: EventBus, pathname: string, workspaceId?: string | null): void {
43
+ const path = normalizeAnalyticsPagePath(pathname);
44
+ bus.emitCustom(
45
+ 'movethewheels.page.viewed',
46
+ {
47
+ workspaceId: ws(workspaceId),
48
+ path,
49
+ product: 'movethewheels',
50
+ },
51
+ { component: 'movethewheels-router' }
52
+ );
53
+ }
54
+
55
+ export function emitOrderCreated(
56
+ bus: EventBus,
57
+ orderId: string | undefined,
58
+ workspaceId?: string | null,
59
+ meta?: { priority?: string; itemCount?: number }
60
+ ): void {
61
+ bus.emitCustom(
62
+ 'movethewheels.order.created',
63
+ {
64
+ workspaceId: ws(workspaceId),
65
+ orderId,
66
+ priority: meta?.priority,
67
+ itemCount: meta?.itemCount,
68
+ },
69
+ { component: 'movethewheels-orders' }
70
+ );
71
+ }
72
+
73
+ export function emitShipmentCreated(
74
+ bus: EventBus,
75
+ shipmentId: string | undefined,
76
+ workspaceId?: string | null,
77
+ meta?: { mode?: string; isMultiModal?: boolean }
78
+ ): void {
79
+ bus.emitCustom(
80
+ 'movethewheels.shipment.created',
81
+ {
82
+ workspaceId: ws(workspaceId),
83
+ shipmentId,
84
+ mode: meta?.mode,
85
+ isMultiModal: meta?.isMultiModal,
86
+ },
87
+ { component: 'movethewheels-shipments' }
88
+ );
89
+ }
90
+
91
+ export function emitShipmentDelivered(
92
+ bus: EventBus,
93
+ shipmentId: string | undefined,
94
+ workspaceId?: string | null
95
+ ): void {
96
+ bus.emitCustom(
97
+ 'movethewheels.shipment.delivered',
98
+ {
99
+ workspaceId: ws(workspaceId),
100
+ shipmentId,
101
+ },
102
+ { component: 'movethewheels-shipments' }
103
+ );
104
+ }
105
+
106
+ export function emitDeliveryJobAssigned(
107
+ bus: EventBus,
108
+ deliveryJobId: string | undefined,
109
+ workspaceId?: string | null,
110
+ meta?: { hasDriver?: boolean; hasVehicle?: boolean }
111
+ ): void {
112
+ bus.emitCustom(
113
+ 'movethewheels.delivery_job.assigned',
114
+ {
115
+ workspaceId: ws(workspaceId),
116
+ deliveryJobId,
117
+ hasDriver: meta?.hasDriver,
118
+ hasVehicle: meta?.hasVehicle,
119
+ },
120
+ { component: 'movethewheels-dispatch' }
121
+ );
122
+ }
123
+
124
+ export function emitRoutePlanned(
125
+ bus: EventBus,
126
+ routeId: string | undefined,
127
+ workspaceId?: string | null,
128
+ meta?: { optimized?: boolean; stopCount?: number }
129
+ ): void {
130
+ bus.emitCustom(
131
+ 'movethewheels.route.planned',
132
+ {
133
+ workspaceId: ws(workspaceId),
134
+ routeId,
135
+ optimized: meta?.optimized,
136
+ stopCount: meta?.stopCount,
137
+ },
138
+ { component: 'movethewheels-routes' }
139
+ );
140
+ }
141
+
142
+ export function emitVehicleAssigned(
143
+ bus: EventBus,
144
+ vehicleId: string | undefined,
145
+ driverId: string | undefined,
146
+ workspaceId?: string | null
147
+ ): void {
148
+ bus.emitCustom(
149
+ 'movethewheels.vehicle.assigned',
150
+ {
151
+ workspaceId: ws(workspaceId),
152
+ vehicleId,
153
+ driverId,
154
+ },
155
+ { component: 'movethewheels-fleet' }
156
+ );
157
+ }
158
+
159
+ export function emitWarehouseInboundReceived(
160
+ bus: EventBus,
161
+ warehouseId: string | undefined,
162
+ inventoryItemId: string | undefined,
163
+ workspaceId?: string | null
164
+ ): void {
165
+ bus.emitCustom(
166
+ 'movethewheels.warehouse.inbound_received',
167
+ {
168
+ workspaceId: ws(workspaceId),
169
+ warehouseId,
170
+ inventoryItemId,
171
+ },
172
+ { component: 'movethewheels-inventory' }
173
+ );
174
+ }
175
+
176
+ export function emitVehicleServiceRecorded(
177
+ bus: EventBus,
178
+ vehicleId: string | undefined,
179
+ workspaceId?: string | null,
180
+ serviceType?: string
181
+ ): void {
182
+ bus.emitCustom(
183
+ 'movethewheels.vehicle.service_recorded',
184
+ {
185
+ workspaceId: ws(workspaceId),
186
+ vehicleId,
187
+ serviceType,
188
+ },
189
+ { component: 'movethewheels-fleet' }
190
+ );
191
+ }