@nerdjs/sales-kit 4.0.56 → 4.0.57
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/entities/quote/quote.d.ts +2 -1
- package/dist/helpers.d.ts +9 -0
- package/dist/helpers.js +54 -0
- package/dist/helpers.js.map +1 -1
- package/dist/hooks/lep/lepLoadLocation.d.ts +0 -6
- package/dist/hooks/lep/lepLoadLocation.js +207 -177
- package/dist/hooks/lep/lepLoadLocation.js.map +1 -1
- package/dist/hooks/lep/lepShipcons.js +25 -7
- package/dist/hooks/lep/lepShipcons.js.map +1 -1
- package/dist/hooks/lep/nerdMap/nerdMap.js +28 -40
- package/dist/hooks/lep/nerdMap/nerdMap.js.map +1 -1
- package/dist/hooks/locationsForm/locationFormSales/locationFormSales.d.ts +1 -1
- package/dist/hooks/locationsForm/locationFormSales/locationFormSales.js +4 -3
- package/dist/hooks/locationsForm/locationFormSales/locationFormSales.js.map +1 -1
- package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.d.ts +0 -5
- package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.js +173 -56
- package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.js.map +1 -1
- package/dist/hooks/quote/constants.d.ts +1 -1
- package/dist/hooks/quote/constants.js +2 -2
- package/dist/hooks/quote/constants.js.map +1 -1
- package/dist/hooks/quote/form.js +16 -5
- package/dist/hooks/quote/form.js.map +1 -1
- package/dist/hooks/quote/helpers.d.ts +1 -0
- package/dist/hooks/quote/helpers.js +304 -325
- package/dist/hooks/quote/helpers.js.map +1 -1
- package/dist/hooks/quote/template.js +2 -2
- package/dist/hooks/quote/template.js.map +1 -1
- package/dist/redux/commoditiesTasksSlice/commoditiesTasksSelectors.d.ts +2 -2
- package/dist/redux/customerV1/customerV1Endpoints.d.ts +2 -2
- package/dist/redux/lep/lepSelectors.d.ts +6 -6
- package/dist/redux/load/loadDrawerSlice.d.ts +1 -1
- package/dist/redux/loadInfoTasksSlice/loadInfoTasksSelectors.d.ts +10 -10
- package/dist/redux/locationV1/locationV1Endpoints.d.ts +12 -12
- package/dist/redux/quote/quoteAction.d.ts +2 -3
- package/dist/redux/quote/quoteAction.js +2 -3
- package/dist/redux/quote/quoteAction.js.map +1 -1
- package/dist/redux/quote/quoteCustomerPortalEndpoints.d.ts +1 -1
- package/dist/redux/quote/quoteReducer.js +5 -5
- package/dist/redux/quote/quoteReducer.js.map +1 -1
- package/dist/redux/quote/quoteSelectors.d.ts +23 -23
- package/dist/redux/shipconsTasksSlice/shipconsTasksSelectors.d.ts +2 -2
- package/dist/redux/tender/tenderSelector.d.ts +7 -7
- package/package.json +2 -2
package/dist/helpers.d.ts
CHANGED
|
@@ -16,3 +16,12 @@ export declare function mapToArray<T extends {
|
|
|
16
16
|
}>(elements: {
|
|
17
17
|
[key: number]: T;
|
|
18
18
|
}): Array<T>;
|
|
19
|
+
export declare function getCache(key: string): google.maps.places.AutocompleteSuggestion[] | null;
|
|
20
|
+
export declare function setCache(key: string, data: google.maps.places.AutocompleteSuggestion[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* NEW: canonical cache by placeId (recommended)
|
|
23
|
+
*/
|
|
24
|
+
export declare function getCacheByPlaceId(placeId?: string): google.maps.places.AutocompleteSuggestion[] | null;
|
|
25
|
+
export declare function useGoogleMapsAutocompleteCache(): {
|
|
26
|
+
getSuggestions: (request: google.maps.places.AutocompleteRequest) => Promise<google.maps.places.AutocompleteSuggestion[]>;
|
|
27
|
+
};
|
package/dist/helpers.js
CHANGED
|
@@ -26,4 +26,58 @@ export function mapToArray(elements) {
|
|
|
26
26
|
}
|
|
27
27
|
return ret;
|
|
28
28
|
}
|
|
29
|
+
import { useCallback } from "react";
|
|
30
|
+
const CACHE = new Map();
|
|
31
|
+
const TTL = 1000 * 60 * 60; // 1 hour
|
|
32
|
+
const normalize = (v) => v.trim().toLowerCase();
|
|
33
|
+
export function getCache(key) {
|
|
34
|
+
const k = normalize(key);
|
|
35
|
+
const entry = CACHE.get(k);
|
|
36
|
+
if (!entry)
|
|
37
|
+
return null;
|
|
38
|
+
if (Date.now() - entry.time > TTL) {
|
|
39
|
+
CACHE.delete(k);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return entry.data;
|
|
43
|
+
}
|
|
44
|
+
export function setCache(key, data) {
|
|
45
|
+
const k = normalize(key);
|
|
46
|
+
const primaryPlaceId = data?.[0]?.placePrediction?.placeId || undefined;
|
|
47
|
+
CACHE.set(k, {
|
|
48
|
+
data,
|
|
49
|
+
placeId: primaryPlaceId,
|
|
50
|
+
time: Date.now(),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* NEW: canonical cache by placeId (recommended)
|
|
55
|
+
*/
|
|
56
|
+
export function getCacheByPlaceId(placeId) {
|
|
57
|
+
if (!placeId)
|
|
58
|
+
return null;
|
|
59
|
+
for (const entry of CACHE.values()) {
|
|
60
|
+
if (entry.placeId === placeId) {
|
|
61
|
+
if (Date.now() - entry.time > TTL)
|
|
62
|
+
return null;
|
|
63
|
+
return entry.data;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
export function useGoogleMapsAutocompleteCache() {
|
|
69
|
+
const fetchAutocompleteSuggestions = google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions;
|
|
70
|
+
const getSuggestions = useCallback(async (request) => {
|
|
71
|
+
const input = request.input;
|
|
72
|
+
if (!input)
|
|
73
|
+
return [];
|
|
74
|
+
const cached = getCache(input);
|
|
75
|
+
if (cached)
|
|
76
|
+
return cached;
|
|
77
|
+
const { suggestions } = await fetchAutocompleteSuggestions(request);
|
|
78
|
+
setCache(input, suggestions);
|
|
79
|
+
return suggestions;
|
|
80
|
+
}, []);
|
|
81
|
+
return { getSuggestions };
|
|
82
|
+
}
|
|
29
83
|
//# sourceMappingURL=helpers.js.map
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,QAAkB;IAElB,MAAM,GAAG,GAAuB,EAAE,CAAC;IACnC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;YACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC9B,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAA2B,QAEpD;IACC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAK,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;YACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,QAAkB;IAElB,MAAM,GAAG,GAAuB,EAAE,CAAC;IACnC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;YACxD,MAAM,OAAO,GA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,CAAC,CAAC;QAEpE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAE7B,OAAO,WAAW,CAAC;IACrB,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -11,168 +11,201 @@ import { TripPanel } from "../load";
|
|
|
11
11
|
import { SOURCES } from "../load/loadLastLocation";
|
|
12
12
|
import { LoadIDContext } from "./index";
|
|
13
13
|
import { NerdMap } from "./nerdMap/nerdMap";
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param root0
|
|
17
|
-
* @param root0.mapID
|
|
18
|
-
* @param root0.refetchOnMountOrArgChange
|
|
19
|
-
*/
|
|
20
14
|
export function LepLoadLocation({ mapID, refetchOnMountOrArgChange, }) {
|
|
21
15
|
const mapRef = useRef(null);
|
|
16
|
+
const markersRef = useRef([]);
|
|
17
|
+
const polylinesRef = useRef([]);
|
|
18
|
+
const infoWindowRef = useRef(new window.google.maps.InfoWindow());
|
|
22
19
|
const [selectedTrip, setSelectedTrip] = useState(null);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
20
|
+
const zoomRef = useRef(5);
|
|
21
|
+
const centerRef = useRef(new google.maps.LatLng({
|
|
25
22
|
lat: 39.8097343,
|
|
26
23
|
lng: -98.5556199,
|
|
27
24
|
}));
|
|
28
25
|
const { id } = useContext(LoadIDContext);
|
|
29
|
-
const
|
|
26
|
+
const positionsParams = useMemo(() => ({
|
|
30
27
|
filters: JSON.stringify([
|
|
31
|
-
{
|
|
28
|
+
{
|
|
29
|
+
name: "positions.loadID",
|
|
30
|
+
comparison: "eq",
|
|
31
|
+
value: id,
|
|
32
|
+
},
|
|
32
33
|
]),
|
|
33
34
|
sorter: JSON.stringify([
|
|
34
|
-
{
|
|
35
|
+
{
|
|
36
|
+
name: "positions.transactionTimeUTC",
|
|
37
|
+
asc: false,
|
|
38
|
+
},
|
|
35
39
|
]),
|
|
36
40
|
}), [id]);
|
|
37
|
-
useGetPositionsQuery(
|
|
38
|
-
const selectAllPositions = useMemo(() => getPositionsSelectors(
|
|
41
|
+
const { isLoading: positionsLoading } = useGetPositionsQuery(positionsParams);
|
|
42
|
+
const selectAllPositions = useMemo(() => getPositionsSelectors(positionsParams).selectAll, [positionsParams]);
|
|
39
43
|
const positions = useSelector(selectAllPositions);
|
|
40
|
-
const
|
|
44
|
+
const shipconsParams = useMemo(() => ({
|
|
41
45
|
filters: JSON.stringify([
|
|
42
|
-
{
|
|
46
|
+
{
|
|
47
|
+
name: "ship_cons.load_id",
|
|
48
|
+
comparison: "eq",
|
|
49
|
+
value: id,
|
|
50
|
+
},
|
|
51
|
+
]),
|
|
52
|
+
sorter: JSON.stringify([
|
|
53
|
+
{
|
|
54
|
+
name: "ship_cons.stop_number",
|
|
55
|
+
asc: true,
|
|
56
|
+
},
|
|
43
57
|
]),
|
|
44
|
-
sorter: JSON.stringify([{ name: "ship_cons.stop_number", asc: true }]),
|
|
45
58
|
}), [id]);
|
|
46
|
-
useGetShipconsQuery(
|
|
59
|
+
useGetShipconsQuery(shipconsParams, {
|
|
47
60
|
skip: Number.isNaN(Number(id)),
|
|
48
61
|
refetchOnMountOrArgChange,
|
|
49
62
|
});
|
|
50
|
-
const selectAllShipcons = useMemo(() => getShipconsSelectors(
|
|
63
|
+
const selectAllShipcons = useMemo(() => getShipconsSelectors(shipconsParams).selectAll, [shipconsParams]);
|
|
51
64
|
const shipcons = useSelector(selectAllShipcons);
|
|
52
|
-
const tripIDs = useMemo(() => [
|
|
65
|
+
const tripIDs = useMemo(() => [
|
|
66
|
+
...new Set(shipcons.map((s) => s.appointmentTripID).filter(Boolean)),
|
|
67
|
+
], [shipcons]);
|
|
53
68
|
const [getAppointmentTrip] = useLazyGetAppointmentTripQuery();
|
|
54
69
|
const [appointmentTrips, setAppointmentTrips] = useState([]);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
setAppointmentTrips(trips);
|
|
70
|
+
const latestTripsRequestRef = useRef(0);
|
|
71
|
+
const clearMapObjects = () => {
|
|
72
|
+
markersRef.current.forEach((marker) => {
|
|
73
|
+
marker.map = null;
|
|
74
|
+
});
|
|
75
|
+
polylinesRef.current.forEach((polyline) => {
|
|
76
|
+
polyline.setMap(null);
|
|
77
|
+
});
|
|
78
|
+
markersRef.current = [];
|
|
79
|
+
polylinesRef.current = [];
|
|
68
80
|
};
|
|
69
81
|
useEffect(() => {
|
|
70
|
-
|
|
82
|
+
const loadTrips = async () => {
|
|
83
|
+
if (tripIDs.length === 0) {
|
|
84
|
+
setAppointmentTrips([]);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const requestId = Date.now();
|
|
88
|
+
latestTripsRequestRef.current = requestId;
|
|
89
|
+
const results = await Promise.all(tripIDs.map((tripID) => getAppointmentTrip(Number(tripID))
|
|
90
|
+
.unwrap()
|
|
91
|
+
.catch(() => null)));
|
|
92
|
+
if (latestTripsRequestRef.current !== requestId) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
setAppointmentTrips(results.filter(Boolean));
|
|
96
|
+
};
|
|
97
|
+
loadTrips();
|
|
71
98
|
}, [tripIDs]);
|
|
72
99
|
useEffect(() => {
|
|
100
|
+
if (!mapRef.current) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
clearMapObjects();
|
|
73
104
|
const loadpath = [];
|
|
74
|
-
positions
|
|
75
|
-
if (position.latitude
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
`<label style="text-align: center; margin-bottom: 5px" >${date}</label>` +
|
|
96
|
-
`<label style="text-align: center" >${position.reporter}</label>` +
|
|
97
|
-
`</div>`,
|
|
98
|
-
headerDisabled: true,
|
|
99
|
-
});
|
|
100
|
-
newLoadMarker.addListener("click", () => {
|
|
101
|
-
//Dummy function used to enable mouseEvent on markers
|
|
102
|
-
});
|
|
103
|
-
newLoadMarker.addEventListener("mouseenter", () => {
|
|
104
|
-
infoWindow.open({
|
|
105
|
-
anchor: newLoadMarker,
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
newLoadMarker.addEventListener("mouseleave", () => {
|
|
109
|
-
infoWindow.close();
|
|
110
|
-
});
|
|
105
|
+
positions.forEach((position, i) => {
|
|
106
|
+
if (!position.latitude || !position.longitude || i === 531) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const latLng = new google.maps.LatLng(Number(position.latitude), Number(position.longitude));
|
|
110
|
+
loadpath.push(latLng);
|
|
111
|
+
const pin = new google.maps.marker.PinElement({
|
|
112
|
+
background: "#00000000",
|
|
113
|
+
borderColor: "#00000000",
|
|
114
|
+
glyphColor: "#00000000",
|
|
115
|
+
glyphText: "",
|
|
116
|
+
});
|
|
117
|
+
const marker = new google.maps.marker.AdvancedMarkerElement({
|
|
118
|
+
position: latLng,
|
|
119
|
+
content: pin,
|
|
120
|
+
map: mapRef.current,
|
|
121
|
+
});
|
|
122
|
+
markersRef.current.push(marker);
|
|
123
|
+
let date = "Date missing";
|
|
124
|
+
if (position.transactionTimeUTC) {
|
|
125
|
+
date = DateTime.fromFormat(position.transactionTimeUTC, "yyyy-LL-dd HH:mm:ss").toFormat("LLL dd HH:mm:ss");
|
|
111
126
|
}
|
|
127
|
+
const content = `<div style="display:flex;flex-direction:column;color:black;">` +
|
|
128
|
+
`<label style="text-align:center;font-weight:bold;margin-bottom:5px">${position.city}, ${position.state}</label>` +
|
|
129
|
+
`<label style="text-align:center;margin-bottom:5px">${date}</label>` +
|
|
130
|
+
`<label style="text-align:center">${position.reporter}</label>` +
|
|
131
|
+
`</div>`;
|
|
132
|
+
marker.addEventListener("mouseenter", () => {
|
|
133
|
+
infoWindowRef.current.setContent(content);
|
|
134
|
+
infoWindowRef.current.open({
|
|
135
|
+
anchor: marker,
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
marker.addEventListener("mouseleave", () => {
|
|
139
|
+
infoWindowRef.current.close();
|
|
140
|
+
});
|
|
112
141
|
});
|
|
113
142
|
if (loadpath.length > 1) {
|
|
114
|
-
const
|
|
143
|
+
const polyline = new google.maps.Polyline({
|
|
115
144
|
path: loadpath,
|
|
116
145
|
strokeColor: "#b71c1c",
|
|
117
146
|
strokeWeight: 6,
|
|
118
147
|
visible: true,
|
|
119
148
|
});
|
|
120
|
-
|
|
149
|
+
polyline.setMap(mapRef.current);
|
|
150
|
+
polylinesRef.current.push(polyline);
|
|
121
151
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
marker.addListener("click", () => setSelectedTrip(v || null));
|
|
140
|
-
tripsShipcons.push(s.id);
|
|
141
|
-
}
|
|
152
|
+
const tripShipcons = new Set();
|
|
153
|
+
appointmentTrips.forEach((trip) => {
|
|
154
|
+
trip.ship_cons?.forEach((s) => {
|
|
155
|
+
if (s.id) {
|
|
156
|
+
tripShipcons.add(s.id);
|
|
157
|
+
}
|
|
158
|
+
if (!s.lat || !s.lng) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const pin = new google.maps.marker.PinElement({
|
|
162
|
+
glyphText: s.tripOrder?.toString(),
|
|
163
|
+
});
|
|
164
|
+
const marker = new google.maps.marker.AdvancedMarkerElement({
|
|
165
|
+
position: new google.maps.LatLng(Number(s.lat), Number(s.lng)),
|
|
166
|
+
map: mapRef.current,
|
|
167
|
+
content: pin,
|
|
168
|
+
title: s.tripOrder?.toString(),
|
|
142
169
|
});
|
|
170
|
+
marker.addListener("gmp-click", () => setSelectedTrip(trip));
|
|
171
|
+
markersRef.current.push(marker);
|
|
143
172
|
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
glyph: s.stopNumber?.toString(),
|
|
152
|
-
});
|
|
153
|
-
const marker = new google.maps.marker.AdvancedMarkerElement({
|
|
154
|
-
content: pin.element,
|
|
155
|
-
position: new google.maps.LatLng(Number(s.lat), Number(s.lng)),
|
|
156
|
-
title: s.stopNumber?.toString(),
|
|
157
|
-
map: mapRef.current,
|
|
158
|
-
});
|
|
159
|
-
marker.addListener("click", () => {
|
|
160
|
-
infoWindow.setContent(`<b>${s.name}</b><br/>No Trip Assigned`);
|
|
161
|
-
infoWindow.open({
|
|
162
|
-
anchor: marker,
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
}
|
|
173
|
+
});
|
|
174
|
+
shipcons.forEach((s) => {
|
|
175
|
+
if (tripShipcons.has(s.id) || !s.lat || !s.lng) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const pin = new google.maps.marker.PinElement({
|
|
179
|
+
glyphText: s.stopNumber?.toString(),
|
|
166
180
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
const marker = new google.maps.marker.AdvancedMarkerElement({
|
|
182
|
+
content: pin,
|
|
183
|
+
position: new google.maps.LatLng(Number(s.lat), Number(s.lng)),
|
|
184
|
+
title: s.stopNumber?.toString(),
|
|
185
|
+
map: mapRef.current,
|
|
186
|
+
});
|
|
187
|
+
marker.addListener("gmp-click", () => {
|
|
188
|
+
infoWindowRef.current.setContent(`<b>${s.name}</b><br/>No Trip Assigned`);
|
|
189
|
+
infoWindowRef.current.open({
|
|
190
|
+
anchor: marker,
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
markersRef.current.push(marker);
|
|
194
|
+
});
|
|
195
|
+
return () => {
|
|
196
|
+
clearMapObjects();
|
|
197
|
+
};
|
|
198
|
+
}, [positions, appointmentTrips, shipcons, mapID]);
|
|
199
|
+
return (_jsxs(Box, { height: "calc(100vh - 210px)", children: [_jsx(NerdMap, { onIdle: (z, c) => {
|
|
200
|
+
zoomRef.current = z;
|
|
201
|
+
if (c)
|
|
202
|
+
centerRef.current = c;
|
|
203
|
+
}, zoom: zoomRef.current, center: centerRef.current, ref: mapRef, mapId: mapID, disableDefaultUI: true }, id), selectedTrip ? (_jsx(Wrapper, { open: Boolean(selectedTrip), onClose: () => setSelectedTrip(null), children: _jsx(TripPanel, { appointmentTrip: selectedTrip, loadID: Number(id) }) })) : null, _jsx(PositionsPanel, { mapRef: mapRef, positions: positions, isLoading: positionsLoading })] }));
|
|
173
204
|
}
|
|
174
205
|
const Wrapper = ({ children, open, onClose, }) => {
|
|
175
|
-
const { t } = useTranslation("common", {
|
|
206
|
+
const { t } = useTranslation("common", {
|
|
207
|
+
i18n: salesKitI18n,
|
|
208
|
+
});
|
|
176
209
|
const theme = useTheme();
|
|
177
210
|
const matches = useMediaQuery(theme.breakpoints.down("sm"));
|
|
178
211
|
if (matches) {
|
|
@@ -183,48 +216,40 @@ const Wrapper = ({ children, open, onClose, }) => {
|
|
|
183
216
|
},
|
|
184
217
|
}, children: children }) }), _jsx(DialogActions, { children: _jsx(Button, { color: "neutral", variant: "soft", onClick: onClose, children: t("Close") }) })] }) }));
|
|
185
218
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
219
|
+
return (_jsxs(Sheet, { sx: {
|
|
220
|
+
p: 1,
|
|
221
|
+
position: "absolute",
|
|
222
|
+
bottom: 30,
|
|
223
|
+
right: 20,
|
|
224
|
+
boxShadow: "0px 8px 16px rgba(155,155,155,0.3)",
|
|
225
|
+
borderRadius: "md",
|
|
226
|
+
cursor: "default",
|
|
227
|
+
maxHeight: "90%",
|
|
228
|
+
}, children: [_jsx(IconButton, { onClick: onClose, variant: "soft", size: "sm", sx: {
|
|
229
|
+
zIndex: 1,
|
|
230
|
+
position: "absolute",
|
|
231
|
+
top: 0,
|
|
232
|
+
right: 0,
|
|
233
|
+
backgroundColor: "inherit",
|
|
234
|
+
borderRadius: "6px 6px 0px 0px",
|
|
235
|
+
":hover": {
|
|
201
236
|
backgroundColor: "inherit",
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
237
|
+
color: "var(--variant-plainHoverColor, var(--joy-palette-neutral-plainHoverColor, var(--joy-palette-neutral-900, #0B0D0E)))",
|
|
238
|
+
},
|
|
239
|
+
}, children: _jsx("i", { className: "fa-regular fa-xmark" }) }), _jsx(Box, { sx: {
|
|
240
|
+
width: 500,
|
|
241
|
+
overflow: "auto",
|
|
242
|
+
}, children: children })] }));
|
|
208
243
|
};
|
|
209
|
-
const PositionsPanel = ({ mapRef, }) => {
|
|
210
|
-
const { t } = useTranslation("common", {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
filters: JSON.stringify([
|
|
214
|
-
{ name: "positions.loadID", comparison: "eq", value: id },
|
|
215
|
-
]),
|
|
216
|
-
sorter: JSON.stringify([
|
|
217
|
-
{ name: "positions.transactionTimeUTC", asc: false },
|
|
218
|
-
]),
|
|
219
|
-
}), [id]);
|
|
220
|
-
const { isLoading } = useGetPositionsQuery(params);
|
|
221
|
-
const selectAllPositions = useMemo(() => getPositionsSelectors(params).selectAll, [params]);
|
|
222
|
-
const positions = useSelector(selectAllPositions);
|
|
244
|
+
const PositionsPanel = ({ mapRef, positions, isLoading, }) => {
|
|
245
|
+
const { t } = useTranslation("common", {
|
|
246
|
+
i18n: salesKitI18n,
|
|
247
|
+
});
|
|
223
248
|
const [stagedPosition, setStagedPosition] = useState();
|
|
224
249
|
const [stagedMarker, setStagedMarker] = useState();
|
|
225
250
|
const [railOnly, setRailOnly] = useState(false);
|
|
226
251
|
const handleClick = (p) => {
|
|
227
|
-
if (p.id
|
|
252
|
+
if (p.id === stagedPosition?.id && stagedMarker) {
|
|
228
253
|
stagedMarker.map = null;
|
|
229
254
|
mapRef.current?.setCenter(new google.maps.LatLng({
|
|
230
255
|
lat: 39.8097343,
|
|
@@ -233,24 +258,24 @@ const PositionsPanel = ({ mapRef, }) => {
|
|
|
233
258
|
mapRef.current?.setZoom(5);
|
|
234
259
|
setStagedMarker(undefined);
|
|
235
260
|
setStagedPosition(undefined);
|
|
261
|
+
return;
|
|
236
262
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
263
|
+
const marker = stagedMarker
|
|
264
|
+
? stagedMarker
|
|
265
|
+
: new google.maps.marker.AdvancedMarkerElement();
|
|
266
|
+
const pos = new google.maps.LatLng(Number(p.latitude), Number(p.longitude));
|
|
267
|
+
marker.position = pos;
|
|
268
|
+
marker.content = new google.maps.marker.PinElement({
|
|
269
|
+
background: "#1983ed",
|
|
270
|
+
borderColor: "#1983ed",
|
|
271
|
+
glyphColor: "#0b6bcb",
|
|
272
|
+
glyphText: "",
|
|
273
|
+
});
|
|
274
|
+
marker.map = mapRef.current;
|
|
275
|
+
mapRef.current?.setCenter(pos);
|
|
276
|
+
mapRef.current?.setZoom(8);
|
|
277
|
+
setStagedMarker(marker);
|
|
278
|
+
setStagedPosition(p);
|
|
254
279
|
};
|
|
255
280
|
return (_jsx(Sheet, { sx: {
|
|
256
281
|
position: "absolute",
|
|
@@ -259,12 +284,15 @@ const PositionsPanel = ({ mapRef, }) => {
|
|
|
259
284
|
boxShadow: "0px 8px 16px rgba(155,155,155,0.3)",
|
|
260
285
|
borderRadius: "md",
|
|
261
286
|
cursor: "default",
|
|
262
|
-
display: {
|
|
287
|
+
display: {
|
|
288
|
+
xs: "none",
|
|
289
|
+
md: "block",
|
|
290
|
+
},
|
|
263
291
|
}, children: _jsx(Box, { p: 0.5, children: _jsx(Grid, { container: true, gap: 0.5, sx: {
|
|
264
292
|
p: 0.5,
|
|
265
293
|
maxWidth: 310,
|
|
266
294
|
minWidth: 220,
|
|
267
|
-
}, justifyContent: "center", alignItems: "center", children: isLoading ? (_jsx(Grid, { xs: 12, height: "100%", children: _jsx(Skeleton, { variant: "rectangular", height:
|
|
295
|
+
}, justifyContent: "center", alignItems: "center", children: isLoading ? (_jsx(Grid, { xs: 12, height: "100%", children: _jsx(Skeleton, { variant: "rectangular", height: 30, width: 200 }) })) : positions.length === 0 ? (_jsx(Grid, { xs: 12, children: _jsx(Typography, { level: "h4", children: "No locations history" }) })) : (_jsxs(_Fragment, { children: [_jsx(Grid, { xs: 12, children: _jsx(Typography, { component: "label", endDecorator: _jsx(Switch, { sx: { ml: 1 }, checked: railOnly, onChange: (event) => setRailOnly(event.target.checked) }), children: "Rail Only" }) }), _jsx(Grid, { container: true, xs: 12, sx: {
|
|
268
296
|
overflowY: "auto",
|
|
269
297
|
width: "fit-content",
|
|
270
298
|
height: "calc(100vh - 300px)",
|
|
@@ -275,7 +303,9 @@ const PositionsPanel = ({ mapRef, }) => {
|
|
|
275
303
|
width: "100%",
|
|
276
304
|
justifyContent: "start",
|
|
277
305
|
}, onClick: () => handleClick(p), children: _jsxs(Box, { children: [_jsx(Typography, { children: `${p.city}, ${p.state}` }), p.transactionTimeLocal ? (_jsxs(Typography, { level: "body-sm", children: [DateTime.fromFormat(p.transactionTimeLocal, "yyyy-MM-dd HH:mm:ss")
|
|
278
|
-
.setZone("utc", {
|
|
306
|
+
.setZone("utc", {
|
|
307
|
+
keepLocalTime: true,
|
|
308
|
+
})
|
|
279
309
|
.toFormat("MM/dd/yy HH:mm"), " ", "(", t("Local Time"), ")"] })) : null, _jsx(Typography, { level: "body-xs", component: "i", children: `${SOURCES[p.sourceID]}${p.reporter ? ` (${p.reporter})` : ""}` }), p.status ? (_jsx(Chip, { color: "success", variant: "solid", size: "sm", children: p.status })) : null] }) }) }, i))) })] })) }) }) }));
|
|
280
310
|
};
|
|
281
311
|
//# sourceMappingURL=lepLoadLocation.js.map
|