@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
|
@@ -18,6 +18,9 @@ import {
|
|
|
18
18
|
Trash2,
|
|
19
19
|
Truck,
|
|
20
20
|
StickyNote,
|
|
21
|
+
ShieldCheck,
|
|
22
|
+
Calendar,
|
|
23
|
+
Plus,
|
|
21
24
|
} from 'lucide-react';
|
|
22
25
|
import { PageLayout, LoadingState, ErrorState } from '../components/PageLayout';
|
|
23
26
|
import { StatusBadge } from '../components/StatusBadge';
|
|
@@ -728,7 +731,30 @@ export default function DriverDetailsPage() {
|
|
|
728
731
|
const { driverId } = useParams<{ driverId: string }>();
|
|
729
732
|
const isEditRoute = useLocation().pathname.endsWith('/edit');
|
|
730
733
|
const { basePath, navigate } = useMoveTheWheels();
|
|
731
|
-
const {
|
|
734
|
+
const {
|
|
735
|
+
driver,
|
|
736
|
+
isLoading,
|
|
737
|
+
error,
|
|
738
|
+
refetch,
|
|
739
|
+
addShift,
|
|
740
|
+
removeShift,
|
|
741
|
+
addComplianceRecord,
|
|
742
|
+
removeComplianceRecord,
|
|
743
|
+
} = useDriver(driverId);
|
|
744
|
+
const [showShiftForm, setShowShiftForm] = useState(false);
|
|
745
|
+
const [shiftForm, setShiftForm] = useState({
|
|
746
|
+
shiftDate: new Date().toISOString().slice(0, 10),
|
|
747
|
+
startTime: '08:00',
|
|
748
|
+
endTime: '16:00',
|
|
749
|
+
status: 'SCHEDULED',
|
|
750
|
+
});
|
|
751
|
+
const [showComplianceForm, setShowComplianceForm] = useState(false);
|
|
752
|
+
const [complianceForm, setComplianceForm] = useState({
|
|
753
|
+
recordType: 'MEDICAL_CERT',
|
|
754
|
+
status: 'VALID',
|
|
755
|
+
expiresAt: '',
|
|
756
|
+
referenceNumber: '',
|
|
757
|
+
});
|
|
732
758
|
useRefetchOnLeaveEdit(isEditRoute, refetch);
|
|
733
759
|
const { vehicle: assignedVehicle } = useVehicle(driver?.assignedVehicle);
|
|
734
760
|
|
|
@@ -873,6 +899,229 @@ export default function DriverDetailsPage() {
|
|
|
873
899
|
|
|
874
900
|
{/* Documents — real files via wspace-files-svc */}
|
|
875
901
|
<DocumentsCard entityType="driver" entityId={driver.id} />
|
|
902
|
+
|
|
903
|
+
{/* Persisted Shift Roster (BOFF-3993) */}
|
|
904
|
+
<Card>
|
|
905
|
+
<CardHeader className="flex flex-row items-center justify-between gap-2">
|
|
906
|
+
<CardTitle className="flex items-center gap-2">
|
|
907
|
+
<Calendar size={18} aria-hidden="true" /> Shift Roster
|
|
908
|
+
</CardTitle>
|
|
909
|
+
<Button variant="outline" size="sm" onClick={() => setShowShiftForm((v) => !v)}>
|
|
910
|
+
<Plus size={14} aria-hidden="true" /> {showShiftForm ? 'Close' : 'Add shift'}
|
|
911
|
+
</Button>
|
|
912
|
+
</CardHeader>
|
|
913
|
+
<CardContent className="space-y-4">
|
|
914
|
+
{showShiftForm && (
|
|
915
|
+
<form
|
|
916
|
+
className="space-y-3 rounded-lg border border-border-seam p-3"
|
|
917
|
+
onSubmit={async (e) => {
|
|
918
|
+
e.preventDefault();
|
|
919
|
+
await addShift({
|
|
920
|
+
shiftDate: `${shiftForm.shiftDate}T12:00:00.000Z`,
|
|
921
|
+
startTime: shiftForm.startTime,
|
|
922
|
+
endTime: shiftForm.endTime,
|
|
923
|
+
status: shiftForm.status,
|
|
924
|
+
});
|
|
925
|
+
setShowShiftForm(false);
|
|
926
|
+
}}
|
|
927
|
+
>
|
|
928
|
+
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
|
|
929
|
+
<div className="space-y-1">
|
|
930
|
+
<Label htmlFor="shift-date">Date</Label>
|
|
931
|
+
<Input
|
|
932
|
+
id="shift-date"
|
|
933
|
+
type="date"
|
|
934
|
+
required
|
|
935
|
+
value={shiftForm.shiftDate}
|
|
936
|
+
onChange={(e) => setShiftForm((p) => ({ ...p, shiftDate: e.target.value }))}
|
|
937
|
+
/>
|
|
938
|
+
</div>
|
|
939
|
+
<div className="space-y-1">
|
|
940
|
+
<Label htmlFor="shift-start">Start</Label>
|
|
941
|
+
<Input
|
|
942
|
+
id="shift-start"
|
|
943
|
+
type="time"
|
|
944
|
+
required
|
|
945
|
+
value={shiftForm.startTime}
|
|
946
|
+
onChange={(e) => setShiftForm((p) => ({ ...p, startTime: e.target.value }))}
|
|
947
|
+
/>
|
|
948
|
+
</div>
|
|
949
|
+
<div className="space-y-1">
|
|
950
|
+
<Label htmlFor="shift-end">End</Label>
|
|
951
|
+
<Input
|
|
952
|
+
id="shift-end"
|
|
953
|
+
type="time"
|
|
954
|
+
required
|
|
955
|
+
value={shiftForm.endTime}
|
|
956
|
+
onChange={(e) => setShiftForm((p) => ({ ...p, endTime: e.target.value }))}
|
|
957
|
+
/>
|
|
958
|
+
</div>
|
|
959
|
+
</div>
|
|
960
|
+
<Button type="submit" size="sm">
|
|
961
|
+
Save shift
|
|
962
|
+
</Button>
|
|
963
|
+
</form>
|
|
964
|
+
)}
|
|
965
|
+
|
|
966
|
+
{driver.shifts && driver.shifts.length > 0 ? (
|
|
967
|
+
<ul className="divide-y divide-border-seam">
|
|
968
|
+
{driver.shifts.map((shift) => (
|
|
969
|
+
<li
|
|
970
|
+
key={shift.id}
|
|
971
|
+
className="flex items-center justify-between gap-3 py-2 text-sm"
|
|
972
|
+
>
|
|
973
|
+
<div>
|
|
974
|
+
<p className="font-medium">
|
|
975
|
+
{formatDate(shift.shiftDate, 'short')} · {shift.startTime} –{' '}
|
|
976
|
+
{shift.endTime}
|
|
977
|
+
</p>
|
|
978
|
+
<p className="text-xs text-text-secondary">
|
|
979
|
+
{shift.status}
|
|
980
|
+
{shift.notes ? ` · ${shift.notes}` : ''}
|
|
981
|
+
</p>
|
|
982
|
+
</div>
|
|
983
|
+
<Button
|
|
984
|
+
variant="ghost"
|
|
985
|
+
size="sm"
|
|
986
|
+
className="text-status-error-text"
|
|
987
|
+
aria-label={`Delete shift ${shift.startTime}`}
|
|
988
|
+
onClick={() => void removeShift(shift.id)}
|
|
989
|
+
>
|
|
990
|
+
<Trash2 size={14} aria-hidden="true" />
|
|
991
|
+
</Button>
|
|
992
|
+
</li>
|
|
993
|
+
))}
|
|
994
|
+
</ul>
|
|
995
|
+
) : (
|
|
996
|
+
<p className="text-sm text-text-secondary">No shifts scheduled yet.</p>
|
|
997
|
+
)}
|
|
998
|
+
</CardContent>
|
|
999
|
+
</Card>
|
|
1000
|
+
|
|
1001
|
+
{/* Persisted Compliance Records (BOFF-3993) */}
|
|
1002
|
+
<Card>
|
|
1003
|
+
<CardHeader className="flex flex-row items-center justify-between gap-2">
|
|
1004
|
+
<CardTitle className="flex items-center gap-2">
|
|
1005
|
+
<ShieldCheck size={18} aria-hidden="true" /> Compliance Records
|
|
1006
|
+
</CardTitle>
|
|
1007
|
+
<Button variant="outline" size="sm" onClick={() => setShowComplianceForm((v) => !v)}>
|
|
1008
|
+
<Plus size={14} aria-hidden="true" /> {showComplianceForm ? 'Close' : 'Add record'}
|
|
1009
|
+
</Button>
|
|
1010
|
+
</CardHeader>
|
|
1011
|
+
<CardContent className="space-y-4">
|
|
1012
|
+
{showComplianceForm && (
|
|
1013
|
+
<form
|
|
1014
|
+
className="space-y-3 rounded-lg border border-border-seam p-3"
|
|
1015
|
+
onSubmit={async (e) => {
|
|
1016
|
+
e.preventDefault();
|
|
1017
|
+
await addComplianceRecord({
|
|
1018
|
+
recordType: complianceForm.recordType,
|
|
1019
|
+
status: complianceForm.status,
|
|
1020
|
+
expiresAt: complianceForm.expiresAt
|
|
1021
|
+
? `${complianceForm.expiresAt}T12:00:00.000Z`
|
|
1022
|
+
: undefined,
|
|
1023
|
+
referenceNumber: complianceForm.referenceNumber.trim() || undefined,
|
|
1024
|
+
});
|
|
1025
|
+
setShowComplianceForm(false);
|
|
1026
|
+
setComplianceForm({
|
|
1027
|
+
recordType: 'MEDICAL_CERT',
|
|
1028
|
+
status: 'VALID',
|
|
1029
|
+
expiresAt: '',
|
|
1030
|
+
referenceNumber: '',
|
|
1031
|
+
});
|
|
1032
|
+
}}
|
|
1033
|
+
>
|
|
1034
|
+
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
|
|
1035
|
+
<div className="space-y-1">
|
|
1036
|
+
<Label htmlFor="comp-type">Record Type</Label>
|
|
1037
|
+
<Select
|
|
1038
|
+
value={complianceForm.recordType}
|
|
1039
|
+
onValueChange={(value) =>
|
|
1040
|
+
setComplianceForm((p) => ({ ...p, recordType: value }))
|
|
1041
|
+
}
|
|
1042
|
+
>
|
|
1043
|
+
<SelectTrigger id="comp-type">
|
|
1044
|
+
<SelectValue />
|
|
1045
|
+
</SelectTrigger>
|
|
1046
|
+
<SelectContent>
|
|
1047
|
+
{[
|
|
1048
|
+
'LICENSE',
|
|
1049
|
+
'MEDICAL_CERT',
|
|
1050
|
+
'BACKGROUND_CHECK',
|
|
1051
|
+
'HAZMAT',
|
|
1052
|
+
'TRAINING',
|
|
1053
|
+
'INSURANCE',
|
|
1054
|
+
'OTHER',
|
|
1055
|
+
].map((opt) => (
|
|
1056
|
+
<SelectItem key={opt} value={opt}>
|
|
1057
|
+
{opt.replace('_', ' ')}
|
|
1058
|
+
</SelectItem>
|
|
1059
|
+
))}
|
|
1060
|
+
</SelectContent>
|
|
1061
|
+
</Select>
|
|
1062
|
+
</div>
|
|
1063
|
+
<div className="space-y-1">
|
|
1064
|
+
<Label htmlFor="comp-ref">Reference #</Label>
|
|
1065
|
+
<Input
|
|
1066
|
+
id="comp-ref"
|
|
1067
|
+
placeholder="CERT-2026-01"
|
|
1068
|
+
value={complianceForm.referenceNumber}
|
|
1069
|
+
onChange={(e) =>
|
|
1070
|
+
setComplianceForm((p) => ({ ...p, referenceNumber: e.target.value }))
|
|
1071
|
+
}
|
|
1072
|
+
/>
|
|
1073
|
+
</div>
|
|
1074
|
+
<div className="space-y-1">
|
|
1075
|
+
<Label htmlFor="comp-exp">Expires</Label>
|
|
1076
|
+
<Input
|
|
1077
|
+
id="comp-exp"
|
|
1078
|
+
type="date"
|
|
1079
|
+
value={complianceForm.expiresAt}
|
|
1080
|
+
onChange={(e) =>
|
|
1081
|
+
setComplianceForm((p) => ({ ...p, expiresAt: e.target.value }))
|
|
1082
|
+
}
|
|
1083
|
+
/>
|
|
1084
|
+
</div>
|
|
1085
|
+
</div>
|
|
1086
|
+
<Button type="submit" size="sm">
|
|
1087
|
+
Save compliance record
|
|
1088
|
+
</Button>
|
|
1089
|
+
</form>
|
|
1090
|
+
)}
|
|
1091
|
+
|
|
1092
|
+
{driver.complianceRecords && driver.complianceRecords.length > 0 ? (
|
|
1093
|
+
<ul className="divide-y divide-border-seam">
|
|
1094
|
+
{driver.complianceRecords.map((rec) => (
|
|
1095
|
+
<li
|
|
1096
|
+
key={rec.id}
|
|
1097
|
+
className="flex items-center justify-between gap-3 py-2 text-sm"
|
|
1098
|
+
>
|
|
1099
|
+
<div>
|
|
1100
|
+
<p className="font-medium">
|
|
1101
|
+
{rec.recordType.replace('_', ' ')} ({rec.status.replace('_', ' ')})
|
|
1102
|
+
</p>
|
|
1103
|
+
<p className="text-xs text-text-secondary">
|
|
1104
|
+
{rec.referenceNumber ? `Ref: ${rec.referenceNumber}` : 'No reference #'}
|
|
1105
|
+
{rec.expiresAt ? ` · Expires ${formatDate(rec.expiresAt, 'short')}` : ''}
|
|
1106
|
+
</p>
|
|
1107
|
+
</div>
|
|
1108
|
+
<Button
|
|
1109
|
+
variant="ghost"
|
|
1110
|
+
size="sm"
|
|
1111
|
+
className="text-status-error-text"
|
|
1112
|
+
aria-label={`Delete compliance record ${rec.recordType}`}
|
|
1113
|
+
onClick={() => void removeComplianceRecord(rec.id)}
|
|
1114
|
+
>
|
|
1115
|
+
<Trash2 size={14} aria-hidden="true" />
|
|
1116
|
+
</Button>
|
|
1117
|
+
</li>
|
|
1118
|
+
))}
|
|
1119
|
+
</ul>
|
|
1120
|
+
) : (
|
|
1121
|
+
<p className="text-sm text-text-secondary">No compliance records stored yet.</p>
|
|
1122
|
+
)}
|
|
1123
|
+
</CardContent>
|
|
1124
|
+
</Card>
|
|
876
1125
|
</div>
|
|
877
1126
|
|
|
878
1127
|
<div className="space-y-6">
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NotificationsCenterPage — In-product MoveTheWheels notifications center (BOFF-3992).
|
|
3
|
+
*
|
|
4
|
+
* Consumes `global-notification-svc` through the shell's global gateway Apollo
|
|
5
|
+
* client (`useSafeGatewayClient('global')`) with `{ preferWorkspaceAuth: true }`
|
|
6
|
+
* so results are scoped to the active workspace's organization. Supports
|
|
7
|
+
* All/Unread/Read filtering, MoveTheWheels-only vs workspace-wide scope,
|
|
8
|
+
* mark-as-read, mark-all-as-read, delete, and deep links to notification
|
|
9
|
+
* preferences (`/notifications/preferences`).
|
|
10
|
+
*/
|
|
11
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
12
|
+
import { gql } from '@apollo/client';
|
|
13
|
+
import { Bell, Check, CheckCheck, ExternalLink, RefreshCw, Settings, Trash2 } from 'lucide-react';
|
|
14
|
+
import { useSafeGatewayClient } from '@burdenoff/fe-libs/shared/graphql';
|
|
15
|
+
import { PageLayout } from '../components/PageLayout';
|
|
16
|
+
import { Badge, Button, Card, CardContent, CardHeader, CardTitle } from '../components/ui';
|
|
17
|
+
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
18
|
+
import { formatDate } from '../utils/formatters';
|
|
19
|
+
|
|
20
|
+
type FilterTab = 'all' | 'unread' | 'read';
|
|
21
|
+
|
|
22
|
+
interface NotificationRow {
|
|
23
|
+
id: string;
|
|
24
|
+
title: string;
|
|
25
|
+
message: string;
|
|
26
|
+
type: string;
|
|
27
|
+
priority: string;
|
|
28
|
+
appName?: string | null;
|
|
29
|
+
redirectUrl?: string | null;
|
|
30
|
+
isRead: boolean;
|
|
31
|
+
readAt?: string | null;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const SCOPE_CONTEXT = { preferWorkspaceAuth: true } as const;
|
|
36
|
+
|
|
37
|
+
const NOTIFICATIONS_QUERY = gql`
|
|
38
|
+
query MtwGetNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {
|
|
39
|
+
notifications(filter: $filter, limit: $limit, offset: $offset) {
|
|
40
|
+
items {
|
|
41
|
+
id
|
|
42
|
+
title
|
|
43
|
+
message
|
|
44
|
+
type
|
|
45
|
+
priority
|
|
46
|
+
appName
|
|
47
|
+
redirectUrl
|
|
48
|
+
isRead
|
|
49
|
+
readAt
|
|
50
|
+
createdAt
|
|
51
|
+
}
|
|
52
|
+
total
|
|
53
|
+
hasMore
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const UNREAD_COUNT_QUERY = gql`
|
|
59
|
+
query MtwUnreadNotificationCount($filter: NotificationFilterInput) {
|
|
60
|
+
myUnreadNotificationCount(filter: $filter)
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const MARK_READ_MUTATION = gql`
|
|
65
|
+
mutation MtwMarkNotificationRead($id: ID!) {
|
|
66
|
+
markNotificationAsRead(id: $id) {
|
|
67
|
+
id
|
|
68
|
+
isRead
|
|
69
|
+
readAt
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
const MARK_ALL_READ_MUTATION = gql`
|
|
75
|
+
mutation MtwMarkAllNotificationsRead {
|
|
76
|
+
markAllMyNotificationsAsRead {
|
|
77
|
+
success
|
|
78
|
+
count
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
const DELETE_NOTIFICATION_MUTATION = gql`
|
|
84
|
+
mutation MtwDeleteNotification($id: ID!) {
|
|
85
|
+
deleteNotification(id: $id)
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
export default function NotificationsCenterPage() {
|
|
90
|
+
const globalClient = useSafeGatewayClient('global');
|
|
91
|
+
const { navigate, workspaceId } = useMoveTheWheels();
|
|
92
|
+
const [filterTab, setFilterTab] = useState<FilterTab>('all');
|
|
93
|
+
const [productOnly, setProductOnly] = useState(false);
|
|
94
|
+
const [items, setItems] = useState<NotificationRow[]>([]);
|
|
95
|
+
const [unreadCount, setUnreadCount] = useState(0);
|
|
96
|
+
const [total, setTotal] = useState(0);
|
|
97
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
98
|
+
const [error, setError] = useState<string | null>(null);
|
|
99
|
+
|
|
100
|
+
const load = useCallback(async () => {
|
|
101
|
+
if (!globalClient) {
|
|
102
|
+
setItems([]);
|
|
103
|
+
setTotal(0);
|
|
104
|
+
setUnreadCount(0);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
setIsLoading(true);
|
|
108
|
+
setError(null);
|
|
109
|
+
try {
|
|
110
|
+
const filter: Record<string, unknown> = { channel: 'IN_APP', archived: false };
|
|
111
|
+
if (filterTab === 'unread') filter.isRead = false;
|
|
112
|
+
if (filterTab === 'read') filter.isRead = true;
|
|
113
|
+
if (productOnly) filter.appName = 'movethewheels';
|
|
114
|
+
|
|
115
|
+
const [listRes, countRes] = await Promise.all([
|
|
116
|
+
globalClient.query<{
|
|
117
|
+
notifications?: { items: NotificationRow[]; total: number; hasMore: boolean };
|
|
118
|
+
}>({
|
|
119
|
+
context: SCOPE_CONTEXT,
|
|
120
|
+
query: NOTIFICATIONS_QUERY,
|
|
121
|
+
variables: { filter, limit: 30, offset: 0 },
|
|
122
|
+
fetchPolicy: 'network-only',
|
|
123
|
+
}),
|
|
124
|
+
globalClient.query<{ myUnreadNotificationCount?: number }>({
|
|
125
|
+
context: SCOPE_CONTEXT,
|
|
126
|
+
query: UNREAD_COUNT_QUERY,
|
|
127
|
+
variables: {
|
|
128
|
+
filter: productOnly
|
|
129
|
+
? { channel: 'IN_APP', archived: false, appName: 'movethewheels' }
|
|
130
|
+
: { channel: 'IN_APP', archived: false },
|
|
131
|
+
},
|
|
132
|
+
fetchPolicy: 'network-only',
|
|
133
|
+
}),
|
|
134
|
+
]);
|
|
135
|
+
|
|
136
|
+
setItems(listRes.data?.notifications?.items ?? []);
|
|
137
|
+
setTotal(listRes.data?.notifications?.total ?? 0);
|
|
138
|
+
setUnreadCount(countRes.data?.myUnreadNotificationCount ?? 0);
|
|
139
|
+
} catch (err) {
|
|
140
|
+
setError(err instanceof Error ? err.message : 'Failed to load notifications.');
|
|
141
|
+
} finally {
|
|
142
|
+
setIsLoading(false);
|
|
143
|
+
}
|
|
144
|
+
}, [filterTab, globalClient, productOnly]);
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
void load();
|
|
148
|
+
}, [load, workspaceId]);
|
|
149
|
+
|
|
150
|
+
const markAsRead = async (id: string) => {
|
|
151
|
+
if (!globalClient) return;
|
|
152
|
+
await globalClient.mutate({
|
|
153
|
+
context: SCOPE_CONTEXT,
|
|
154
|
+
mutation: MARK_READ_MUTATION,
|
|
155
|
+
variables: { id },
|
|
156
|
+
});
|
|
157
|
+
setItems((prev) =>
|
|
158
|
+
prev.map((row) =>
|
|
159
|
+
row.id === id ? { ...row, isRead: true, readAt: new Date().toISOString() } : row
|
|
160
|
+
)
|
|
161
|
+
);
|
|
162
|
+
setUnreadCount((prev) => Math.max(0, prev - 1));
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const markAllAsRead = async () => {
|
|
166
|
+
if (!globalClient) return;
|
|
167
|
+
await globalClient.mutate({
|
|
168
|
+
context: SCOPE_CONTEXT,
|
|
169
|
+
mutation: MARK_ALL_READ_MUTATION,
|
|
170
|
+
});
|
|
171
|
+
setItems((prev) =>
|
|
172
|
+
prev.map((row) => ({ ...row, isRead: true, readAt: row.readAt ?? new Date().toISOString() }))
|
|
173
|
+
);
|
|
174
|
+
setUnreadCount(0);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const remove = async (id: string) => {
|
|
178
|
+
if (!globalClient) return;
|
|
179
|
+
const target = items.find((row) => row.id === id);
|
|
180
|
+
await globalClient.mutate({
|
|
181
|
+
context: SCOPE_CONTEXT,
|
|
182
|
+
mutation: DELETE_NOTIFICATION_MUTATION,
|
|
183
|
+
variables: { id },
|
|
184
|
+
});
|
|
185
|
+
setItems((prev) => prev.filter((row) => row.id !== id));
|
|
186
|
+
setTotal((prev) => Math.max(0, prev - 1));
|
|
187
|
+
if (target && !target.isRead) {
|
|
188
|
+
setUnreadCount((prev) => Math.max(0, prev - 1));
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<PageLayout
|
|
194
|
+
title="Notifications"
|
|
195
|
+
subtitle="Workspace shipment alerts, delivery updates, and operational notices"
|
|
196
|
+
icon={<Bell size={24} />}
|
|
197
|
+
headerActions={
|
|
198
|
+
<div className="flex flex-wrap gap-2">
|
|
199
|
+
<Button variant="outline" size="sm" onClick={() => void load()} disabled={isLoading}>
|
|
200
|
+
<RefreshCw size={14} aria-hidden="true" /> Refresh
|
|
201
|
+
</Button>
|
|
202
|
+
{unreadCount > 0 && (
|
|
203
|
+
<Button variant="outline" size="sm" onClick={() => void markAllAsRead()}>
|
|
204
|
+
<CheckCheck size={14} aria-hidden="true" /> Mark all read
|
|
205
|
+
</Button>
|
|
206
|
+
)}
|
|
207
|
+
<Button
|
|
208
|
+
variant="outline"
|
|
209
|
+
size="sm"
|
|
210
|
+
onClick={() => navigate('/notifications/preferences')}
|
|
211
|
+
>
|
|
212
|
+
<Settings size={14} aria-hidden="true" /> Preferences
|
|
213
|
+
</Button>
|
|
214
|
+
</div>
|
|
215
|
+
}
|
|
216
|
+
>
|
|
217
|
+
<div className="space-y-6">
|
|
218
|
+
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
219
|
+
<div className="flex gap-2" role="tablist" aria-label="Notification read status">
|
|
220
|
+
{(['all', 'unread', 'read'] as const).map((tab) => (
|
|
221
|
+
<Button
|
|
222
|
+
key={tab}
|
|
223
|
+
type="button"
|
|
224
|
+
role="tab"
|
|
225
|
+
aria-selected={filterTab === tab}
|
|
226
|
+
variant={filterTab === tab ? 'default' : 'outline'}
|
|
227
|
+
size="sm"
|
|
228
|
+
className="capitalize"
|
|
229
|
+
onClick={() => setFilterTab(tab)}
|
|
230
|
+
>
|
|
231
|
+
{tab}
|
|
232
|
+
{tab === 'unread' && unreadCount > 0 ? ` (${unreadCount})` : ''}
|
|
233
|
+
</Button>
|
|
234
|
+
))}
|
|
235
|
+
</div>
|
|
236
|
+
<div className="flex items-center gap-2">
|
|
237
|
+
<Button
|
|
238
|
+
type="button"
|
|
239
|
+
variant={productOnly ? 'default' : 'outline'}
|
|
240
|
+
size="sm"
|
|
241
|
+
onClick={() => setProductOnly((prev) => !prev)}
|
|
242
|
+
>
|
|
243
|
+
{productOnly ? 'Showing: MoveTheWheels only' : 'Showing: All workspace alerts'}
|
|
244
|
+
</Button>
|
|
245
|
+
<Button variant="ghost" size="sm" onClick={() => navigate('/notifications')}>
|
|
246
|
+
<ExternalLink size={14} aria-hidden="true" /> Platform inbox
|
|
247
|
+
</Button>
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<Card>
|
|
252
|
+
<CardHeader>
|
|
253
|
+
<CardTitle className="flex items-center gap-2">
|
|
254
|
+
<Bell size={18} aria-hidden="true" />
|
|
255
|
+
Inbox
|
|
256
|
+
<Badge variant="secondary">{total}</Badge>
|
|
257
|
+
</CardTitle>
|
|
258
|
+
</CardHeader>
|
|
259
|
+
<CardContent>
|
|
260
|
+
{error && <p className="text-sm text-status-error-text mb-3">{error}</p>}
|
|
261
|
+
{isLoading ? (
|
|
262
|
+
<p className="text-sm text-text-secondary py-6 text-center">Loading notifications…</p>
|
|
263
|
+
) : items.length === 0 ? (
|
|
264
|
+
<div className="py-10 text-center space-y-2">
|
|
265
|
+
<Bell size={32} className="mx-auto text-text-secondary opacity-50" />
|
|
266
|
+
<p className="text-sm text-text-secondary">
|
|
267
|
+
{filterTab === 'unread'
|
|
268
|
+
? 'You are all caught up — no unread notifications.'
|
|
269
|
+
: 'No notifications match this filter.'}
|
|
270
|
+
</p>
|
|
271
|
+
</div>
|
|
272
|
+
) : (
|
|
273
|
+
<ul className="divide-y divide-border-seam">
|
|
274
|
+
{items.map((item) => (
|
|
275
|
+
<li
|
|
276
|
+
key={item.id}
|
|
277
|
+
className={`flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3 py-3 ${
|
|
278
|
+
item.isRead ? 'opacity-80' : ''
|
|
279
|
+
}`}
|
|
280
|
+
>
|
|
281
|
+
<div className="min-w-0 space-y-1">
|
|
282
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
283
|
+
{!item.isRead && (
|
|
284
|
+
<span
|
|
285
|
+
className="inline-block h-2 w-2 rounded-full bg-action-primary-bg"
|
|
286
|
+
aria-label="Unread"
|
|
287
|
+
/>
|
|
288
|
+
)}
|
|
289
|
+
<p className="font-medium text-text-primary">{item.title}</p>
|
|
290
|
+
{item.appName && <Badge variant="outline">{item.appName}</Badge>}
|
|
291
|
+
</div>
|
|
292
|
+
<p className="text-sm text-text-secondary">{item.message}</p>
|
|
293
|
+
<p className="text-xs text-text-secondary">
|
|
294
|
+
{formatDate(new Date(item.createdAt), 'relative')}
|
|
295
|
+
</p>
|
|
296
|
+
</div>
|
|
297
|
+
<div className="flex items-center gap-1 shrink-0">
|
|
298
|
+
{item.redirectUrl && (
|
|
299
|
+
<Button
|
|
300
|
+
variant="ghost"
|
|
301
|
+
size="sm"
|
|
302
|
+
onClick={() => navigate(item.redirectUrl!)}
|
|
303
|
+
>
|
|
304
|
+
Open
|
|
305
|
+
</Button>
|
|
306
|
+
)}
|
|
307
|
+
{!item.isRead && (
|
|
308
|
+
<Button variant="ghost" size="sm" onClick={() => void markAsRead(item.id)}>
|
|
309
|
+
<Check size={14} aria-hidden="true" /> Mark read
|
|
310
|
+
</Button>
|
|
311
|
+
)}
|
|
312
|
+
<Button
|
|
313
|
+
variant="ghost"
|
|
314
|
+
size="sm"
|
|
315
|
+
className="text-status-error-text"
|
|
316
|
+
aria-label={`Delete notification ${item.title}`}
|
|
317
|
+
onClick={() => void remove(item.id)}
|
|
318
|
+
>
|
|
319
|
+
<Trash2 size={14} aria-hidden="true" />
|
|
320
|
+
</Button>
|
|
321
|
+
</div>
|
|
322
|
+
</li>
|
|
323
|
+
))}
|
|
324
|
+
</ul>
|
|
325
|
+
)}
|
|
326
|
+
</CardContent>
|
|
327
|
+
</Card>
|
|
328
|
+
</div>
|
|
329
|
+
</PageLayout>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
@@ -56,6 +56,7 @@ import { isVehicleAssignable } from '../utils/orderVehicleHold';
|
|
|
56
56
|
import { reuseRecoveryScope, reuseRecoveryContextKey } from '../utils/reuseRecovery';
|
|
57
57
|
import { useTr } from '../shared/hooks/useTr';
|
|
58
58
|
import { DocumentsCard } from '../components/DocumentsCard';
|
|
59
|
+
import { EntityConversationsCard } from '../components/EntityConversationsCard';
|
|
59
60
|
import { ProofOfDeliveryCard } from '../components/ProofOfDeliveryCard';
|
|
60
61
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
61
62
|
import { formatCurrency, formatDate, formatAddress } from '../utils/formatters';
|
|
@@ -856,6 +857,13 @@ function OrderDetails({ contextKey, contextReady }: { contextKey: string; contex
|
|
|
856
857
|
{/* Documents — real files via wspace-files-svc */}
|
|
857
858
|
<DocumentsCard entityType="order" entityId={order.id} />
|
|
858
859
|
|
|
860
|
+
{/* Entity conversation thread via wspace-conversations-svc (BOFF-3992) */}
|
|
861
|
+
<EntityConversationsCard
|
|
862
|
+
entityType="mtw_order"
|
|
863
|
+
entityId={order.id}
|
|
864
|
+
title="Order conversation"
|
|
865
|
+
/>
|
|
866
|
+
|
|
859
867
|
{/* Proof of delivery — captured by the driver on completion (BOFF-4399) */}
|
|
860
868
|
<ProofOfDeliveryCard deliveryJobId={order.id} />
|
|
861
869
|
|
|
@@ -52,6 +52,7 @@ import { firstRealLatLng } from '../utils/mapMarkers';
|
|
|
52
52
|
import { EntityCombobox } from '../components/EntityCombobox';
|
|
53
53
|
import { useRoute, useRoutes } from '../hooks/useRoutes';
|
|
54
54
|
import { DocumentsCard } from '../components/DocumentsCard';
|
|
55
|
+
import { EntityConversationsCard } from '../components/EntityConversationsCard';
|
|
55
56
|
import { useVehicles, useVehicle, useDrivers, useDriver } from '../hooks/useFleet';
|
|
56
57
|
import { useAssignmentSuggestions } from '../hooks/useFleetIntelligence';
|
|
57
58
|
import { useRefetchOnLeaveEdit } from '../hooks/useRefetchOnLeaveEdit';
|
|
@@ -801,6 +802,11 @@ export default function RouteDetailsPage() {
|
|
|
801
802
|
|
|
802
803
|
<div className="space-y-6">
|
|
803
804
|
<DocumentsCard entityType="route" entityId={route.id} />
|
|
805
|
+
<EntityConversationsCard
|
|
806
|
+
entityType="mtw_route"
|
|
807
|
+
entityId={route.id}
|
|
808
|
+
title="Route conversation"
|
|
809
|
+
/>
|
|
804
810
|
{(route.status === 'planned' || route.status === 'in_progress') && (
|
|
805
811
|
<AssignmentSuggestions
|
|
806
812
|
suggestions={suggestions.data}
|
|
@@ -13,6 +13,7 @@ import { Card, CardContent, CardHeader, CardTitle, Button, Input } from '../comp
|
|
|
13
13
|
import { EmphasisPanel, PagePurpose } from '@burdenoff/fe-libs/ui';
|
|
14
14
|
import { TrackingMap, type TrackEndpoint, type TrackPoint } from '../components/maps';
|
|
15
15
|
import { ProofOfDeliveryCard } from '../components/ProofOfDeliveryCard';
|
|
16
|
+
import { EntityConversationsCard } from '../components/EntityConversationsCard';
|
|
16
17
|
import { firstRealLatLng } from '../utils/mapMarkers';
|
|
17
18
|
import { useOrderTracking } from '../hooks/useTracking';
|
|
18
19
|
import { formatDate, formatAddress } from '../utils/formatters';
|
|
@@ -554,6 +555,13 @@ export default function TrackingPage() {
|
|
|
554
555
|
{/* Proof of delivery — captured by the driver on completion (BOFF-4399) */}
|
|
555
556
|
<ProofOfDeliveryCard deliveryJobId={order.id} />
|
|
556
557
|
|
|
558
|
+
{/* Shipment conversation thread via wspace-conversations-svc (BOFF-3992) */}
|
|
559
|
+
<EntityConversationsCard
|
|
560
|
+
entityType="mtw_shipment"
|
|
561
|
+
entityId={order.id}
|
|
562
|
+
title="Shipment conversation"
|
|
563
|
+
/>
|
|
564
|
+
|
|
557
565
|
{/* Actions */}
|
|
558
566
|
<Card>
|
|
559
567
|
<CardContent className="p-4 space-y-2">
|