@nerdjs/sales-kit 2.4.18 → 2.4.20
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/commodityPiece/commodityPiece.d.ts +4 -0
- package/dist/entities/commodityPiece/commodityPiece.js +4 -0
- package/dist/entities/commodityPiece/commodityPiece.js.map +1 -1
- package/dist/hooks/lep/lepCommodities.js +9 -4
- package/dist/hooks/lep/lepCommodities.js.map +1 -1
- package/dist/hooks/lep/lepEDI.js +1 -1
- package/dist/hooks/lep/lepHosLogs.js +2 -2
- package/dist/hooks/lep/lepHosLogs.js.map +1 -1
- package/dist/hooks/lep/lepShipcons.js +1 -0
- package/dist/hooks/lep/lepShipcons.js.map +1 -1
- package/dist/hooks/lep/lepTenders.js +133 -26
- package/dist/hooks/lep/lepTenders.js.map +1 -1
- package/dist/hooks/load/loadCommodityPieces.js +100 -64
- package/dist/hooks/load/loadCommodityPieces.js.map +1 -1
- package/dist/hooks/load/loadLastLocation.js +1 -1
- package/dist/hooks/load/loadLastLocation.js.map +1 -1
- package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.js +1 -1
- package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.js.map +1 -1
- package/dist/locales/en/components.json +3 -0
- package/dist/locales/index.d.ts +3 -0
- package/dist/redux/carrier/carrierEndpoints.d.ts +12 -1
- package/dist/redux/carrier/carrierEndpoints.js +19 -1
- package/dist/redux/carrier/carrierEndpoints.js.map +1 -1
- package/package.json +2 -2
- package/dist/hooks/locationsForm/locationsFormSales.d.ts +0 -27
- package/dist/hooks/locationsForm/locationsFormSales.js +0 -982
- package/dist/hooks/locationsForm/locationsFormSales.js.map +0 -1
|
@@ -1,982 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, FormControl, FormLabel, Input, Typography, Grid, Checkbox, CircularProgress, Select, Option, FormHelperText, Modal, ModalDialog, Textarea, Tabs, TabList, tabClasses, Tab, TabPanel, Box, Autocomplete, useTheme, Divider, } from "@mui/joy";
|
|
3
|
-
import { NerdClickToCopy, NerdCurrencyFieldDataGridAdapter, NerdDatePicker, NerdDraggableDialog, NerdFileUpload, NerdPhoneField, NerdTimePicker, showNotification, useNerdConfirm, } from "@nerdjs/nerd-ui";
|
|
4
|
-
import { useEffect, useMemo, useState, } from "react";
|
|
5
|
-
import salesKitI18n from "../../i18n";
|
|
6
|
-
import { useTranslation } from "react-i18next";
|
|
7
|
-
import { useDispatch } from "react-redux";
|
|
8
|
-
import { locationEntityTypeGuard, } from "../../entities/location/location";
|
|
9
|
-
import { useCreateLocationAccessorialV1Mutation, useCreateLocationV1Mutation, useDeleteLocationAccessorialsV1Mutation, useGetAccessorialsV1Query, useGetLocationAccessorialsV1Query, useGetLocationV1Query, useUpdateLocationAccessorialsV1Mutation, useUpdateLocationV1Mutation, } from "../../redux/locationV1";
|
|
10
|
-
import { DateTime } from "luxon";
|
|
11
|
-
import { DataGridPremium, GridActionsCellItem, GridRowEditStopReasons, GridRowModes, } from "@mui/x-data-grid-premium";
|
|
12
|
-
import { useDeleteArcherFileMutation, useShareArcherFileMutation, useUploadArcherFileMutation, } from "../../redux/archerFile";
|
|
13
|
-
import { Person } from "../../entities";
|
|
14
|
-
import { usdFormatter } from "../quote/constants";
|
|
15
|
-
import { useGetLocationFilesQuery, useGetPeopleQuery } from "../../redux";
|
|
16
|
-
import { useMediaQuery } from "@mui/system";
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {LocationFormSalesProps} props props
|
|
20
|
-
* @returns {ReactElement} LocationForm
|
|
21
|
-
*/
|
|
22
|
-
export function LocationFormSales({ onCreateLocation, onSaveLocation, open, place, onClose, }) {
|
|
23
|
-
const { t } = useTranslation("common", { i18n: salesKitI18n });
|
|
24
|
-
const [createLocation] = useCreateLocationV1Mutation();
|
|
25
|
-
const [updateLocation] = useUpdateLocationV1Mutation();
|
|
26
|
-
const [validationObject, setValidationObject] = useState(locationEntityTypeGuard(place)
|
|
27
|
-
? {
|
|
28
|
-
name: true,
|
|
29
|
-
address: true,
|
|
30
|
-
phone: true,
|
|
31
|
-
openTime: true,
|
|
32
|
-
closeTime: true,
|
|
33
|
-
FCFSIN: true,
|
|
34
|
-
FCFSOUT: true,
|
|
35
|
-
}
|
|
36
|
-
: {
|
|
37
|
-
name: false,
|
|
38
|
-
address: true,
|
|
39
|
-
phone: false,
|
|
40
|
-
openTime: true,
|
|
41
|
-
closeTime: true,
|
|
42
|
-
FCFSIN: true,
|
|
43
|
-
FCFSOUT: true,
|
|
44
|
-
});
|
|
45
|
-
const { data, isFetching } = useGetLocationV1Query(locationEntityTypeGuard(place) && place.id ? place.id : 0, { skip: locationEntityTypeGuard(place) && place.id ? false : true });
|
|
46
|
-
const [location, setLocation] = useState(data || {});
|
|
47
|
-
const [body, setBody] = useState({
|
|
48
|
-
verified: false,
|
|
49
|
-
});
|
|
50
|
-
const googleMapsAutocompleteService = new google.maps.places.AutocompleteService();
|
|
51
|
-
const googleMapsGeocoder = new google.maps.Geocoder();
|
|
52
|
-
const [googleMapsPredictions, setGoogleMapsPredictions] = useState(null);
|
|
53
|
-
const [value, setValue] = useState(null);
|
|
54
|
-
const [loadingMapsLocations, setLoadingMapsLocations] = useState(place ? true : false);
|
|
55
|
-
const isValid = useMemo(() => {
|
|
56
|
-
const obj = { ...validationObject };
|
|
57
|
-
delete obj.phone;
|
|
58
|
-
return Object.values(obj).every(Boolean) ? true : false;
|
|
59
|
-
}, [validationObject]);
|
|
60
|
-
const loading = loadingMapsLocations || isFetching;
|
|
61
|
-
const addressFormGeocoder = (place) => {
|
|
62
|
-
const address = {};
|
|
63
|
-
const _ref = place.address_components;
|
|
64
|
-
const _len = _ref.length;
|
|
65
|
-
for (let _i = 0; _i < _len; _i++) {
|
|
66
|
-
const i = _ref[_i];
|
|
67
|
-
const _ref1 = i.types;
|
|
68
|
-
const _len1 = _ref1.length;
|
|
69
|
-
for (let _j = 0; _j < _len1; _j++) {
|
|
70
|
-
const t = _ref1[_j];
|
|
71
|
-
address[t] = i.short_name;
|
|
72
|
-
address[`${t}_long`] = i.long_name;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const line1 = `${address.street_number ? `${address.street_number} ` : ""}${address.route}`.trim();
|
|
76
|
-
const city = address.locality_long ||
|
|
77
|
-
address.sublocality_long ||
|
|
78
|
-
address.sublocality_level_1_long ||
|
|
79
|
-
address.neighborhood_long;
|
|
80
|
-
const state = address.administrative_area_level_1;
|
|
81
|
-
const zip = address.postal_code;
|
|
82
|
-
const formatted_address = place.formatted_address;
|
|
83
|
-
return { line1, city, state, zip, formatted_address };
|
|
84
|
-
};
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
// If place is an Archer location v3 object, fetch the matching v1 object and populate the google maps autocomplete
|
|
87
|
-
if (locationEntityTypeGuard(place) &&
|
|
88
|
-
data?.id &&
|
|
89
|
-
place?.id &&
|
|
90
|
-
data.id === place.id) {
|
|
91
|
-
setLocation(data);
|
|
92
|
-
setValidationObject({
|
|
93
|
-
...validationObject,
|
|
94
|
-
address: data?.address_id ? true : false,
|
|
95
|
-
name: data?.name ? true : false,
|
|
96
|
-
phone: data?.phone ? true : false,
|
|
97
|
-
});
|
|
98
|
-
if (data.formatted_address) {
|
|
99
|
-
getGoogleAddresses(data.formatted_address, true);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
setLoadingMapsLocations(false);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else if (place && locationEntityTypeGuard(place)) {
|
|
106
|
-
setLocation({
|
|
107
|
-
line1: place.address.line1,
|
|
108
|
-
city: place.address.city,
|
|
109
|
-
state: place.address.state,
|
|
110
|
-
zip: place.address.zip,
|
|
111
|
-
formatted_address: place.address.formattedAddress,
|
|
112
|
-
place_id: place.address.placeId,
|
|
113
|
-
});
|
|
114
|
-
setBody({
|
|
115
|
-
...body,
|
|
116
|
-
line1: place.address.line1,
|
|
117
|
-
city: place.address.city,
|
|
118
|
-
state: place.address.state,
|
|
119
|
-
zip: place.address.zip,
|
|
120
|
-
formatted_address: place.address.formattedAddress,
|
|
121
|
-
id: place.id,
|
|
122
|
-
place_id: place.address.placeId,
|
|
123
|
-
});
|
|
124
|
-
setValidationObject({
|
|
125
|
-
...validationObject,
|
|
126
|
-
name: false,
|
|
127
|
-
});
|
|
128
|
-
if (place.address.formattedAddress) {
|
|
129
|
-
getGoogleAddresses(place.address.formattedAddress, true);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
setLoadingMapsLocations(false);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else if (place) {
|
|
136
|
-
const address = addressFormGeocoder(place);
|
|
137
|
-
setBody({ ...address });
|
|
138
|
-
setLocation({ ...address });
|
|
139
|
-
setLoadingMapsLocations(false);
|
|
140
|
-
getGoogleAddresses(place.formatted_address, true);
|
|
141
|
-
}
|
|
142
|
-
}, [data, open, place]);
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
if (!loadingMapsLocations) {
|
|
145
|
-
setValue(googleMapsPredictions?.find((l) => location.place_id === l.place_id) ||
|
|
146
|
-
googleMapsPredictions?.[0] ||
|
|
147
|
-
null);
|
|
148
|
-
}
|
|
149
|
-
}, [loadingMapsLocations]);
|
|
150
|
-
const handleSaveLocation = () => {
|
|
151
|
-
if (location.id) {
|
|
152
|
-
updateLocation({
|
|
153
|
-
id: location.id,
|
|
154
|
-
body: { location: { ...body } },
|
|
155
|
-
})
|
|
156
|
-
.unwrap()
|
|
157
|
-
.then(() => {
|
|
158
|
-
onSaveLocation?.(body);
|
|
159
|
-
})
|
|
160
|
-
.catch(() => {
|
|
161
|
-
return;
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
createLocation(body)
|
|
166
|
-
.unwrap()
|
|
167
|
-
.then((l) => {
|
|
168
|
-
onCreateLocation(l);
|
|
169
|
-
})
|
|
170
|
-
.catch(() => {
|
|
171
|
-
return;
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
const handleClose = () => {
|
|
176
|
-
setValue(null);
|
|
177
|
-
setBody({});
|
|
178
|
-
setLocation({});
|
|
179
|
-
onClose();
|
|
180
|
-
};
|
|
181
|
-
const getGoogleAddresses = (searchText, init) => {
|
|
182
|
-
if (init)
|
|
183
|
-
setLoadingMapsLocations(true);
|
|
184
|
-
googleMapsAutocompleteService.getPlacePredictions({
|
|
185
|
-
input: searchText,
|
|
186
|
-
componentRestrictions: { country: "us" },
|
|
187
|
-
types: ["address"],
|
|
188
|
-
language: "en",
|
|
189
|
-
}, (googleSuggestions) => {
|
|
190
|
-
setGoogleMapsPredictions(googleSuggestions);
|
|
191
|
-
if (init)
|
|
192
|
-
setLoadingMapsLocations(false);
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
return (_jsx(Wrapper, { handleClose: handleClose, open: open, children: loading ? (_jsx(Box, { sx: {
|
|
196
|
-
display: "flex",
|
|
197
|
-
justifyContent: "center",
|
|
198
|
-
alignItems: "center",
|
|
199
|
-
height: { xs: "100%", sm: "none" },
|
|
200
|
-
}, children: _jsx(CircularProgress, {}) })) : (_jsxs(Box, { display: "flex", flexDirection: "column", height: "100%", children: [_jsx(Typography, { id: "draggable-title", level: "h4", sx: {
|
|
201
|
-
cursor: "move",
|
|
202
|
-
}, children: location?.id ? t("Edit Location") : t("New Location") }), _jsx(Box, { id: "draggable-content", sx: {
|
|
203
|
-
overflow: "auto",
|
|
204
|
-
height: "100%",
|
|
205
|
-
}, children: _jsxs(Tabs, { defaultValue: 0, sx: {
|
|
206
|
-
bgcolor: "transparent",
|
|
207
|
-
overflowY: "auto",
|
|
208
|
-
overflowX: "hidden",
|
|
209
|
-
height: "100%",
|
|
210
|
-
}, size: "sm", children: [_jsxs(TabList, { size: "sm", sx: {
|
|
211
|
-
p: 0.5,
|
|
212
|
-
gap: 0.5,
|
|
213
|
-
borderRadius: "xl",
|
|
214
|
-
bgcolor: "background.level1",
|
|
215
|
-
[`& .${tabClasses.root}[aria-selected="true"]`]: {
|
|
216
|
-
boxShadow: "sm",
|
|
217
|
-
bgcolor: "background.surface",
|
|
218
|
-
},
|
|
219
|
-
}, children: [_jsx(Tab, { disableIndicator: true, children: "Main" }), location.id ? (_jsxs(_Fragment, { children: [_jsx(Tab, { disableIndicator: true, children: "Accessorials" }), _jsx(Tab, { disableIndicator: true, children: "Documents" })] })) : null] }), _jsx(TabPanel, { value: 0, sx: {
|
|
220
|
-
overflow: "auto",
|
|
221
|
-
}, children: _jsxs(Grid, { container: true, spacing: 0.5, children: [_jsx(Grid, { xs: 12, md: 5, children: _jsxs(FormControl, { required: true, children: [_jsx(FormLabel, { children: t("Name") }), _jsx(Input, { fullWidth: true, error: !validationObject.name, onChange: (e) => {
|
|
222
|
-
setValidationObject({
|
|
223
|
-
...validationObject,
|
|
224
|
-
name: e.target.value ? true : false,
|
|
225
|
-
});
|
|
226
|
-
setLocation((l) => ({
|
|
227
|
-
...l,
|
|
228
|
-
name: e.target.value,
|
|
229
|
-
}));
|
|
230
|
-
setBody((l) => ({
|
|
231
|
-
...l,
|
|
232
|
-
name: e.target.value,
|
|
233
|
-
}));
|
|
234
|
-
}, size: "sm", value: location?.name ?? "", placeholder: t("Facility's name") })] }) }), _jsx(Grid, { xs: 12, md: 7, children: _jsxs(FormControl, { required: true, children: [_jsx(FormLabel, { children: "Address" }), _jsx(Autocomplete, { size: "sm", value: value, error: !validationObject.address, options: googleMapsPredictions || [], onInputChange: (_e, v) => {
|
|
235
|
-
getGoogleAddresses(v, false);
|
|
236
|
-
}, onChange: (_e, v) => {
|
|
237
|
-
setValue(v);
|
|
238
|
-
if (v && v.place_id !== location.place_id) {
|
|
239
|
-
googleMapsGeocoder.geocode({ placeId: v.place_id }, (result) => {
|
|
240
|
-
const place = result?.[0];
|
|
241
|
-
if (place) {
|
|
242
|
-
const address = addressFormGeocoder(place);
|
|
243
|
-
setBody({
|
|
244
|
-
...body,
|
|
245
|
-
...address,
|
|
246
|
-
place_id: place.place_id,
|
|
247
|
-
});
|
|
248
|
-
setLocation({
|
|
249
|
-
...location,
|
|
250
|
-
...address,
|
|
251
|
-
place_id: place.place_id,
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
setValidationObject({
|
|
257
|
-
...validationObject,
|
|
258
|
-
address: !v ? false : true,
|
|
259
|
-
});
|
|
260
|
-
}, getOptionLabel: (option) => `${option.structured_formatting.main_text}, ${option.structured_formatting.secondary_text}`, isOptionEqualToValue: (o, v) => o.place_id === v.place_id })] }) }), _jsx(Grid, { xs: 8, md: 4.5, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Line 1" }), _jsx(Input, { fullWidth: true, readOnly: true, size: "sm", value: location?.line1 ?? "", placeholder: t("Line 1") })] }) }), _jsx(Grid, { xs: 4, md: 3.5, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "#" }), _jsx(Input, { fullWidth: true, size: "sm", value: location?.line2 ?? "", onChange: (e) => {
|
|
261
|
-
setLocation((l) => ({
|
|
262
|
-
...l,
|
|
263
|
-
line2: e.target.value,
|
|
264
|
-
}));
|
|
265
|
-
setBody((l) => ({
|
|
266
|
-
...l,
|
|
267
|
-
line2: e.target.value,
|
|
268
|
-
}));
|
|
269
|
-
} })] }) }), _jsx(Grid, { xs: 6, md: 2, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "City" }), _jsx(Input, { fullWidth: true, readOnly: true, size: "sm", value: location?.city ?? "", placeholder: t("City") })] }) }), _jsx(Grid, { xs: 3, md: 0.75, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "State" }), _jsx(Input, { fullWidth: true, readOnly: true, size: "sm", value: location?.state ?? "", placeholder: t("State") })] }) }), _jsx(Grid, { xs: 3, md: 1.25, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "ZIP" }), _jsx(Input, { fullWidth: true, readOnly: true, size: "sm", value: location?.zip ?? "", placeholder: t("ZIP") })] }) }), _jsx(Grid, { xs: 12, mt: 1, mb: 1, children: _jsx(Divider, {}) }), _jsx(Grid, { xs: 12, md: 4.5, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Emails" }), _jsx(Input, { fullWidth: true, onChange: (e) => {
|
|
270
|
-
setLocation((l) => ({
|
|
271
|
-
...l,
|
|
272
|
-
email_addresses: e.target.value,
|
|
273
|
-
}));
|
|
274
|
-
setBody((l) => ({
|
|
275
|
-
...l,
|
|
276
|
-
email_addresses: e.target.value,
|
|
277
|
-
}));
|
|
278
|
-
}, size: "sm", value: location?.email_addresses || "", placeholder: "one@email.com; two@email.com..." })] }) }), _jsx(Grid, { xs: 12, md: 2.5, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Contact" }), _jsx(Input, { fullWidth: true, onChange: (e) => {
|
|
279
|
-
setLocation((l) => ({
|
|
280
|
-
...l,
|
|
281
|
-
contact: e.target.value,
|
|
282
|
-
}));
|
|
283
|
-
setBody((l) => ({
|
|
284
|
-
...l,
|
|
285
|
-
contact: e.target.value,
|
|
286
|
-
}));
|
|
287
|
-
}, size: "sm", value: location.contact || "", placeholder: "Contact" }), _jsx(FormHelperText, { sx: {
|
|
288
|
-
display: { xs: "none", lg: "initial" },
|
|
289
|
-
}, children: " " })] }) }), _jsx(Grid, { xs: 12, md: 3.5, children: _jsx(NerdPhoneField, { value: location.phone, label: t("Phone"), inputProps: {
|
|
290
|
-
placeholder: t("Phone"),
|
|
291
|
-
size: "sm",
|
|
292
|
-
fullWidth: true,
|
|
293
|
-
error: !validationObject.phone,
|
|
294
|
-
}, onAccept: (value) => {
|
|
295
|
-
setValidationObject({
|
|
296
|
-
...validationObject,
|
|
297
|
-
phone: true,
|
|
298
|
-
});
|
|
299
|
-
setLocation((l) => ({
|
|
300
|
-
...l,
|
|
301
|
-
phone: value,
|
|
302
|
-
}));
|
|
303
|
-
setBody((l) => ({ ...l, phone: value }));
|
|
304
|
-
}, onError: () => {
|
|
305
|
-
setValidationObject({
|
|
306
|
-
...validationObject,
|
|
307
|
-
phone: false,
|
|
308
|
-
});
|
|
309
|
-
} }) }), _jsx(Grid, { xs: 12, md: 1.5, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Ext" }), _jsx(Input, { value: location.ext_number || "", placeholder: "Ext", size: "sm", fullWidth: true, onChange: (e) => {
|
|
310
|
-
setLocation((l) => ({
|
|
311
|
-
...l,
|
|
312
|
-
ext_number: e.target.value,
|
|
313
|
-
}));
|
|
314
|
-
setBody((l) => ({
|
|
315
|
-
...l,
|
|
316
|
-
ext_number: e.target.value,
|
|
317
|
-
}));
|
|
318
|
-
} })] }) }), _jsx(Grid, { xs: 12, mt: 1, mb: 1, children: _jsx(Divider, {}) }), _jsx(Grid, { xs: 6, md: 2, children: _jsx(FormControl, { children: _jsx(Checkbox, { label: "Need File", checked: location.needs_file || false, onChange: (e) => {
|
|
319
|
-
setLocation((l) => ({
|
|
320
|
-
...l,
|
|
321
|
-
needs_file: e.target.checked,
|
|
322
|
-
}));
|
|
323
|
-
setBody((l) => ({
|
|
324
|
-
...l,
|
|
325
|
-
needs_file: e.target.checked,
|
|
326
|
-
}));
|
|
327
|
-
} }) }) }), _jsx(Grid, { xs: 6, md: 3, children: _jsx(FormControl, { children: _jsx(Checkbox, { label: "Need Liquor Permit", checked: location.needs_liquor_permit || false, onChange: (e) => {
|
|
328
|
-
setLocation((l) => ({
|
|
329
|
-
...l,
|
|
330
|
-
needs_liquor_permit: e.target.checked,
|
|
331
|
-
}));
|
|
332
|
-
setBody((l) => ({
|
|
333
|
-
...l,
|
|
334
|
-
needs_liquor_permit: e.target.checked,
|
|
335
|
-
}));
|
|
336
|
-
} }) }) }), _jsx(Grid, { xs: 6, md: 4, children: _jsx(Checkbox, { label: "First come first serve(FCFS)", checked: location.first_come_first_serve || false, onChange: (e) => {
|
|
337
|
-
setLocation((l) => ({
|
|
338
|
-
...l,
|
|
339
|
-
first_come_first_serve: e.target.checked,
|
|
340
|
-
}));
|
|
341
|
-
setBody((l) => ({
|
|
342
|
-
...l,
|
|
343
|
-
first_come_first_serve: e.target.checked,
|
|
344
|
-
}));
|
|
345
|
-
} }) }), _jsx(Grid, { xs: 6, md: 3, children: _jsx(Checkbox, { label: "Strict Scheduling", checked: location.strict_scheduling || false, onChange: (e) => {
|
|
346
|
-
setLocation((l) => ({
|
|
347
|
-
...l,
|
|
348
|
-
strict_scheduling: e.target.checked,
|
|
349
|
-
}));
|
|
350
|
-
setBody((l) => ({
|
|
351
|
-
...l,
|
|
352
|
-
strict_scheduling: e.target.checked,
|
|
353
|
-
}));
|
|
354
|
-
} }) }), _jsx(Grid, { xs: 3, children: _jsx(NerdDatePicker, { inputProps: {
|
|
355
|
-
size: "sm",
|
|
356
|
-
}, value: location.first_come_date
|
|
357
|
-
? DateTime.fromISO(location.first_come_date)
|
|
358
|
-
: null, onChange: (newDate) => {
|
|
359
|
-
setLocation((l) => ({
|
|
360
|
-
...l,
|
|
361
|
-
first_come_date: newDate?.toISO() || "",
|
|
362
|
-
}));
|
|
363
|
-
setBody((l) => ({
|
|
364
|
-
...l,
|
|
365
|
-
first_come_date: newDate?.toISO() || "",
|
|
366
|
-
}));
|
|
367
|
-
} }) }), _jsx(Grid, { xs: "auto", children: _jsx(NerdTimePicker, { label: "FCFS IN", inputProps: {
|
|
368
|
-
sx: {
|
|
369
|
-
width: 100,
|
|
370
|
-
},
|
|
371
|
-
size: "sm",
|
|
372
|
-
slotProps: {
|
|
373
|
-
input: {
|
|
374
|
-
sx: {
|
|
375
|
-
p: 0.5,
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
}, value: location.first_come_in
|
|
380
|
-
? DateTime.fromISO(location.first_come_in)
|
|
381
|
-
.toUTC()
|
|
382
|
-
.toFormat("HH:mm")
|
|
383
|
-
: null, onChange: (time) => {
|
|
384
|
-
if (!time.isValid) {
|
|
385
|
-
setValidationObject({
|
|
386
|
-
...validationObject,
|
|
387
|
-
FCFSIN: false,
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
setValidationObject({
|
|
392
|
-
...validationObject,
|
|
393
|
-
FCFSIN: true,
|
|
394
|
-
});
|
|
395
|
-
const newTime = time.duration
|
|
396
|
-
? DateTime.now()
|
|
397
|
-
.toUTC()
|
|
398
|
-
.set({
|
|
399
|
-
hour: time.duration.hours,
|
|
400
|
-
minute: time.duration.minutes,
|
|
401
|
-
second: 0,
|
|
402
|
-
})
|
|
403
|
-
.toISO() || ""
|
|
404
|
-
: "";
|
|
405
|
-
setLocation((l) => ({
|
|
406
|
-
...l,
|
|
407
|
-
first_come_in: newTime,
|
|
408
|
-
}));
|
|
409
|
-
setBody((l) => ({
|
|
410
|
-
...l,
|
|
411
|
-
first_come_in: newTime,
|
|
412
|
-
}));
|
|
413
|
-
}
|
|
414
|
-
} }) }), _jsx(Grid, { xs: "auto", children: _jsx(NerdTimePicker, { label: "FCFS OUT", inputProps: {
|
|
415
|
-
sx: {
|
|
416
|
-
width: 100,
|
|
417
|
-
},
|
|
418
|
-
size: "sm",
|
|
419
|
-
slotProps: {
|
|
420
|
-
input: {
|
|
421
|
-
sx: {
|
|
422
|
-
p: 0.5,
|
|
423
|
-
},
|
|
424
|
-
},
|
|
425
|
-
},
|
|
426
|
-
}, value: location.first_come_out
|
|
427
|
-
? DateTime.fromISO(location.first_come_out)
|
|
428
|
-
.toUTC()
|
|
429
|
-
.toFormat("HH:mm")
|
|
430
|
-
: null, onChange: (time) => {
|
|
431
|
-
if (!time.isValid) {
|
|
432
|
-
setValidationObject({
|
|
433
|
-
...validationObject,
|
|
434
|
-
FCFSOUT: false,
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
else {
|
|
438
|
-
setValidationObject({
|
|
439
|
-
...validationObject,
|
|
440
|
-
FCFSOUT: true,
|
|
441
|
-
});
|
|
442
|
-
const newTime = time.duration
|
|
443
|
-
? DateTime.now()
|
|
444
|
-
.toUTC()
|
|
445
|
-
.set({
|
|
446
|
-
hour: time.duration.hours,
|
|
447
|
-
minute: time.duration.minutes,
|
|
448
|
-
second: 0,
|
|
449
|
-
})
|
|
450
|
-
.toISO() || ""
|
|
451
|
-
: "";
|
|
452
|
-
setLocation((l) => ({
|
|
453
|
-
...l,
|
|
454
|
-
first_come_out: newTime,
|
|
455
|
-
}));
|
|
456
|
-
setBody((l) => ({
|
|
457
|
-
...l,
|
|
458
|
-
first_come_out: newTime,
|
|
459
|
-
}));
|
|
460
|
-
}
|
|
461
|
-
} }) }), _jsx(Grid, { xs: 12, md: "auto", ml: { sx: "none", md: "auto" }, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "PSR Days" }), _jsxs(Select, { size: "sm", defaultValue: location.preschedule_days || 0, onChange: (_e, value) => {
|
|
462
|
-
setLocation((l) => ({
|
|
463
|
-
...l,
|
|
464
|
-
preschedule_days: value || 0,
|
|
465
|
-
}));
|
|
466
|
-
setBody((l) => ({
|
|
467
|
-
...l,
|
|
468
|
-
preschedule_days: value || 0,
|
|
469
|
-
}));
|
|
470
|
-
}, slotProps: {
|
|
471
|
-
listbox: {
|
|
472
|
-
sx: {
|
|
473
|
-
zIndex: (theme) => theme.zIndex.modal,
|
|
474
|
-
},
|
|
475
|
-
},
|
|
476
|
-
}, children: [_jsx(Option, { value: 0, children: "None" }, 0), [1, 2, 3, 4, 5].map((v) => (_jsx(Option, { value: v, children: v }, v))), _jsx(Option, { value: 14, children: "ASAP" }, 14)] })] }) }), _jsx(Grid, { lg: "auto", children: _jsx(NerdTimePicker, { inputProps: {
|
|
477
|
-
sx: {
|
|
478
|
-
width: 100,
|
|
479
|
-
},
|
|
480
|
-
size: "sm",
|
|
481
|
-
}, label: "Open Time", value: location.time_from
|
|
482
|
-
? DateTime.fromISO(location.time_from)
|
|
483
|
-
.toUTC()
|
|
484
|
-
.toFormat("HH:mm")
|
|
485
|
-
: null, onChange: (time) => {
|
|
486
|
-
if (!time.isValid) {
|
|
487
|
-
setValidationObject({
|
|
488
|
-
...validationObject,
|
|
489
|
-
openTime: false,
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
setValidationObject({
|
|
494
|
-
...validationObject,
|
|
495
|
-
openTime: true,
|
|
496
|
-
});
|
|
497
|
-
const newTime = time.duration
|
|
498
|
-
? DateTime.now()
|
|
499
|
-
.toUTC()
|
|
500
|
-
.set({
|
|
501
|
-
hour: time.duration.hours,
|
|
502
|
-
minute: time.duration.minutes,
|
|
503
|
-
second: 0,
|
|
504
|
-
})
|
|
505
|
-
.toISO() || ""
|
|
506
|
-
: "";
|
|
507
|
-
setLocation((l) => ({
|
|
508
|
-
...l,
|
|
509
|
-
time_from: newTime,
|
|
510
|
-
}));
|
|
511
|
-
setBody((l) => ({
|
|
512
|
-
...l,
|
|
513
|
-
time_from: newTime,
|
|
514
|
-
}));
|
|
515
|
-
}
|
|
516
|
-
} }) }), _jsx(Grid, { lg: "auto", children: _jsx(NerdTimePicker, { inputProps: {
|
|
517
|
-
sx: {
|
|
518
|
-
width: 100,
|
|
519
|
-
},
|
|
520
|
-
size: "sm",
|
|
521
|
-
}, label: "Close Time", value: location.time_to
|
|
522
|
-
? DateTime.fromISO(location.time_to)
|
|
523
|
-
.toUTC()
|
|
524
|
-
.toFormat("HH:mm")
|
|
525
|
-
: null, onChange: (time) => {
|
|
526
|
-
if (!time.isValid) {
|
|
527
|
-
setValidationObject({
|
|
528
|
-
...validationObject,
|
|
529
|
-
closeTime: false,
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
setValidationObject({
|
|
534
|
-
...validationObject,
|
|
535
|
-
closeTime: true,
|
|
536
|
-
});
|
|
537
|
-
const newTime = time.duration
|
|
538
|
-
? DateTime.now()
|
|
539
|
-
.toUTC()
|
|
540
|
-
.set({
|
|
541
|
-
hour: time.duration.hours,
|
|
542
|
-
minute: time.duration.minutes,
|
|
543
|
-
second: 0,
|
|
544
|
-
})
|
|
545
|
-
.toISO() || ""
|
|
546
|
-
: "";
|
|
547
|
-
setLocation((l) => ({
|
|
548
|
-
...l,
|
|
549
|
-
time_to: newTime,
|
|
550
|
-
}));
|
|
551
|
-
setBody((l) => ({
|
|
552
|
-
...l,
|
|
553
|
-
time_to: newTime,
|
|
554
|
-
}));
|
|
555
|
-
}
|
|
556
|
-
} }) }), _jsx(Grid, { xs: 6, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "TMS Link" }), _jsx(Input, { fullWidth: true, onChange: (e) => {
|
|
557
|
-
setLocation((l) => ({
|
|
558
|
-
...l,
|
|
559
|
-
tms_link: e.target.value,
|
|
560
|
-
}));
|
|
561
|
-
setBody((l) => ({
|
|
562
|
-
...l,
|
|
563
|
-
tms_link: e.target.value,
|
|
564
|
-
}));
|
|
565
|
-
}, size: "sm", value: location.tms_link || "", placeholder: "TMS Link", endDecorator: _jsx(Button, { variant: "soft", size: "sm", component: location.tms_link ? "a" : "button", href: location.tms_link
|
|
566
|
-
? location.tms_link.match(/^https?:\/{2}/)
|
|
567
|
-
? location.tms_link
|
|
568
|
-
: `//${location.tms_link}`
|
|
569
|
-
: "", startDecorator: _jsx("i", { className: "fa-solid fa-arrow-up-right-from-square" }), target: "_blank", rel: "noopener noreferrer", sx: {
|
|
570
|
-
mr: -1,
|
|
571
|
-
height: "100%",
|
|
572
|
-
textDecoration: "none!important",
|
|
573
|
-
}, children: "GO" }) })] }) }), _jsx(Grid, { xs: 4, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Channel" }), _jsx(Select, { size: "sm", defaultValue: location.scheduling_channel, onChange: (_e, value) => {
|
|
574
|
-
setLocation((l) => ({
|
|
575
|
-
...l,
|
|
576
|
-
scheduling_channel: value || "",
|
|
577
|
-
}));
|
|
578
|
-
setBody((l) => ({
|
|
579
|
-
...l,
|
|
580
|
-
scheduling_channel: value || "",
|
|
581
|
-
}));
|
|
582
|
-
}, slotProps: {
|
|
583
|
-
listbox: {
|
|
584
|
-
sx: {
|
|
585
|
-
zIndex: (theme) => theme.zIndex.modal,
|
|
586
|
-
},
|
|
587
|
-
},
|
|
588
|
-
}, children: [
|
|
589
|
-
{ label: "None", value: "" },
|
|
590
|
-
{ label: "Email", value: "email" },
|
|
591
|
-
{ label: "Call", value: "call" },
|
|
592
|
-
{ label: "Portal", value: "portal" },
|
|
593
|
-
{ label: "Customer", value: "customer" },
|
|
594
|
-
].map((v) => (_jsx(Option, { value: v.value, children: v.label }, v.value))) }), _jsx(FormHelperText, { children: " " })] }) }), _jsx(Grid, { xs: 12, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Prev. Appts." }), _jsx(Textarea, { maxRows: 4, onChange: (e) => {
|
|
595
|
-
setLocation((l) => ({
|
|
596
|
-
...l,
|
|
597
|
-
prev_apts: e.target.value,
|
|
598
|
-
}));
|
|
599
|
-
setBody((l) => ({
|
|
600
|
-
...l,
|
|
601
|
-
prev_apts: e.target.value,
|
|
602
|
-
}));
|
|
603
|
-
}, size: "sm", value: location.prev_apts || "" })] }) }), _jsx(Grid, { xs: 12, md: 6, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Location Notes" }), _jsx(Textarea, { maxRows: 4, onChange: (e) => {
|
|
604
|
-
setLocation((l) => ({
|
|
605
|
-
...l,
|
|
606
|
-
notes: e.target.value,
|
|
607
|
-
}));
|
|
608
|
-
setBody((l) => ({
|
|
609
|
-
...l,
|
|
610
|
-
notes: e.target.value,
|
|
611
|
-
}));
|
|
612
|
-
}, size: "sm", value: location.notes || "" })] }) }), _jsx(Grid, { xs: 12, md: 6, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Location Scheduling Notes" }), _jsx(Textarea, { maxRows: 4, onChange: (e) => {
|
|
613
|
-
setLocation((l) => ({
|
|
614
|
-
...l,
|
|
615
|
-
scheduling_notes: e.target.value,
|
|
616
|
-
}));
|
|
617
|
-
setBody((l) => ({
|
|
618
|
-
...l,
|
|
619
|
-
scheduling_notes: e.target.value,
|
|
620
|
-
}));
|
|
621
|
-
}, size: "sm", value: location.scheduling_notes || "" })] }) }), _jsx(Grid, { xs: 12, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Driver Instructions" }), _jsx(Textarea, { maxRows: 4, onChange: (e) => {
|
|
622
|
-
setLocation((l) => ({
|
|
623
|
-
...l,
|
|
624
|
-
driver_instructions: e.target.value,
|
|
625
|
-
}));
|
|
626
|
-
setBody((l) => ({
|
|
627
|
-
...l,
|
|
628
|
-
driver_instructions: e.target.value,
|
|
629
|
-
}));
|
|
630
|
-
}, size: "sm", value: location.driver_instructions || "" })] }) })] }) }), location.id ? (_jsx(TabPanel, { value: 1, sx: {
|
|
631
|
-
overflow: "auto",
|
|
632
|
-
height: "100%",
|
|
633
|
-
}, children: _jsx(Box, { sx: {
|
|
634
|
-
height: "100%",
|
|
635
|
-
}, children: _jsx(LocationAccessoralsList, { locationID: location.id }) }) })) : null, location.id ? (_jsx(TabPanel, { value: 2, sx: {
|
|
636
|
-
overflow: "auto",
|
|
637
|
-
height: "100%",
|
|
638
|
-
}, children: _jsx(Box, { sx: {
|
|
639
|
-
height: "100%",
|
|
640
|
-
}, children: _jsx(DocumentsList, { locationID: location.id }) }) })) : null] }) }), _jsxs(Box, { sx: {
|
|
641
|
-
display: "flex",
|
|
642
|
-
pt: 2,
|
|
643
|
-
gap: 1,
|
|
644
|
-
justifyContent: "flex-end",
|
|
645
|
-
}, children: [_jsx(Button, { variant: "soft", color: "neutral", onClick: () => {
|
|
646
|
-
handleClose();
|
|
647
|
-
}, children: t("Cancel") }), _jsx(Button, { onClick: () => {
|
|
648
|
-
handleSaveLocation();
|
|
649
|
-
handleClose();
|
|
650
|
-
}, disabled: !isValid, children: location.id ? t("Save") : t("Create") })] })] })) }));
|
|
651
|
-
}
|
|
652
|
-
const Wrapper = ({ children, open, handleClose, }) => {
|
|
653
|
-
const theme = useTheme();
|
|
654
|
-
const matches = useMediaQuery(theme.breakpoints.down("md"));
|
|
655
|
-
if (matches)
|
|
656
|
-
return (_jsx(Modal, { open: open, onClose: handleClose, children: _jsx(ModalDialog, { layout: "fullscreen", children: children }) }));
|
|
657
|
-
else if (open)
|
|
658
|
-
return (_jsx(NerdDraggableDialog, { draggableProps: {
|
|
659
|
-
handle: "#draggable-title",
|
|
660
|
-
cancel: "#draggable-content",
|
|
661
|
-
}, resizable: true, initialHeight: 820, initialWidth: 820, resizableProps: {
|
|
662
|
-
minConstraints: [300, 300],
|
|
663
|
-
}, sheetProps: {
|
|
664
|
-
sx: {
|
|
665
|
-
p: 1,
|
|
666
|
-
},
|
|
667
|
-
}, children: children }));
|
|
668
|
-
else
|
|
669
|
-
return _jsx(_Fragment, {});
|
|
670
|
-
};
|
|
671
|
-
/**
|
|
672
|
-
*
|
|
673
|
-
* @param root0
|
|
674
|
-
* @param root0.locationID
|
|
675
|
-
*/
|
|
676
|
-
function LocationAccessoralsList({ locationID }) {
|
|
677
|
-
const { data: _accessorials } = useGetAccessorialsV1Query();
|
|
678
|
-
const { data, isFetching } = useGetLocationAccessorialsV1Query({
|
|
679
|
-
id: locationID,
|
|
680
|
-
});
|
|
681
|
-
const [createLocationAccessorial] = useCreateLocationAccessorialV1Mutation();
|
|
682
|
-
const [updateLocationAccessorial] = useUpdateLocationAccessorialsV1Mutation();
|
|
683
|
-
const [deleteLocationAccessorial] = useDeleteLocationAccessorialsV1Mutation();
|
|
684
|
-
const [rows, setRows] = useState(data || []);
|
|
685
|
-
const [rowModesModel, setRowModesModel] = useState({});
|
|
686
|
-
useEffect(() => {
|
|
687
|
-
setRows(data || []);
|
|
688
|
-
}, [data]);
|
|
689
|
-
const handleEditClick = (id) => () => {
|
|
690
|
-
setRowModesModel({ ...rowModesModel, [id]: { mode: GridRowModes.Edit } });
|
|
691
|
-
};
|
|
692
|
-
const handleSaveClick = (id) => () => {
|
|
693
|
-
setRowModesModel({ ...rowModesModel, [id]: { mode: GridRowModes.View } });
|
|
694
|
-
};
|
|
695
|
-
const handleDeleteClick = (id) => () => {
|
|
696
|
-
deleteLocationAccessorial(Number(id));
|
|
697
|
-
};
|
|
698
|
-
const handleCancelClick = (id) => () => {
|
|
699
|
-
setRowModesModel({
|
|
700
|
-
...rowModesModel,
|
|
701
|
-
[id]: { mode: GridRowModes.View, ignoreModifications: true },
|
|
702
|
-
});
|
|
703
|
-
const editedRow = rows.find((row) => row.id === id);
|
|
704
|
-
if (editedRow?.isNew) {
|
|
705
|
-
setRows(rows.filter((row) => row.id !== id));
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
const processRowUpdate = (newRow) => {
|
|
709
|
-
const { isNew, ...row } = newRow;
|
|
710
|
-
if (isNew) {
|
|
711
|
-
createLocationAccessorial({ locationaccessorial: row });
|
|
712
|
-
}
|
|
713
|
-
else {
|
|
714
|
-
updateLocationAccessorial({
|
|
715
|
-
id: row.id,
|
|
716
|
-
body: { locationaccessorial: row },
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
return row;
|
|
720
|
-
};
|
|
721
|
-
const handleRowEditStop = (params, event) => {
|
|
722
|
-
if (params.reason === GridRowEditStopReasons.rowFocusOut) {
|
|
723
|
-
event.defaultMuiPrevented = true;
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
const accessorials = useMemo(() => _accessorials?.map((a) => ({
|
|
727
|
-
value: a.id,
|
|
728
|
-
label: a.name,
|
|
729
|
-
})), [_accessorials]);
|
|
730
|
-
const columns = useMemo(() => [
|
|
731
|
-
{
|
|
732
|
-
field: "accessorial_id",
|
|
733
|
-
headerName: "Accessorial",
|
|
734
|
-
flex: 1,
|
|
735
|
-
editable: true,
|
|
736
|
-
type: "singleSelect",
|
|
737
|
-
valueOptions() {
|
|
738
|
-
return accessorials || [];
|
|
739
|
-
},
|
|
740
|
-
valueFormatter(params) {
|
|
741
|
-
return _accessorials?.find((a) => a.id == params.value)?.name || "";
|
|
742
|
-
},
|
|
743
|
-
},
|
|
744
|
-
{
|
|
745
|
-
field: "cost_amount",
|
|
746
|
-
headerName: "Amount",
|
|
747
|
-
type: "number",
|
|
748
|
-
flex: 1,
|
|
749
|
-
editable: true,
|
|
750
|
-
renderEditCell(params) {
|
|
751
|
-
return _jsx(NerdCurrencyFieldDataGridAdapter, { cellParams: params });
|
|
752
|
-
},
|
|
753
|
-
valueSetter(params) {
|
|
754
|
-
return {
|
|
755
|
-
...params.row,
|
|
756
|
-
cost_amount: params.value !== undefined ? params.value : 0,
|
|
757
|
-
};
|
|
758
|
-
},
|
|
759
|
-
renderCell(params) {
|
|
760
|
-
return usdFormatter.format(params.value);
|
|
761
|
-
},
|
|
762
|
-
},
|
|
763
|
-
{
|
|
764
|
-
field: "load_type",
|
|
765
|
-
headerName: "Load Type",
|
|
766
|
-
flex: 1,
|
|
767
|
-
editable: true,
|
|
768
|
-
type: "singleSelect",
|
|
769
|
-
valueOptions: [
|
|
770
|
-
{ value: "all", label: "All" },
|
|
771
|
-
{ value: "tl", label: "TL" },
|
|
772
|
-
{ value: "ltl", label: "LTL" },
|
|
773
|
-
],
|
|
774
|
-
valueFormatter(params) {
|
|
775
|
-
return (params.value.charAt(0).toUpperCase() + params.value.substring(1));
|
|
776
|
-
},
|
|
777
|
-
},
|
|
778
|
-
{
|
|
779
|
-
field: "contract",
|
|
780
|
-
headerName: "Contract",
|
|
781
|
-
type: "boolean",
|
|
782
|
-
flex: 1,
|
|
783
|
-
editable: true,
|
|
784
|
-
},
|
|
785
|
-
{
|
|
786
|
-
field: "actions",
|
|
787
|
-
type: "actions",
|
|
788
|
-
headerName: "Actions",
|
|
789
|
-
width: 100,
|
|
790
|
-
cellClassName: "actions",
|
|
791
|
-
getActions: ({ id }) => {
|
|
792
|
-
const isInEditMode = rowModesModel[id]?.mode === GridRowModes.Edit;
|
|
793
|
-
if (isInEditMode) {
|
|
794
|
-
return [
|
|
795
|
-
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-floppy-disk" }), label: "Save", sx: {
|
|
796
|
-
color: "primary.main",
|
|
797
|
-
}, onClick: handleSaveClick(id) }, "save"),
|
|
798
|
-
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-circle-xmark" }), label: "Cancel", className: "textPrimary", onClick: handleCancelClick(id), color: "inherit" }, "cancel"),
|
|
799
|
-
];
|
|
800
|
-
}
|
|
801
|
-
return [
|
|
802
|
-
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-pen-to-square" }), label: "Edit", className: "textPrimary", onClick: handleEditClick(id), color: "inherit" }, "edit"),
|
|
803
|
-
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-trash" }), label: "Delete", onClick: handleDeleteClick(id), color: "inherit" }, "delete"),
|
|
804
|
-
];
|
|
805
|
-
},
|
|
806
|
-
},
|
|
807
|
-
], [_accessorials, rowModesModel]);
|
|
808
|
-
return (_jsx(DataGridPremium, { editMode: "row", density: "compact", rowModesModel: rowModesModel, processRowUpdate: processRowUpdate, onRowEditStop: handleRowEditStop, onRowModesModelChange: (v) => setRowModesModel(v), hideFooter: true, slots: {
|
|
809
|
-
toolbar: CustomToolbar,
|
|
810
|
-
}, slotProps: {
|
|
811
|
-
toolbar: { setRows, setRowModesModel, locationID },
|
|
812
|
-
}, loading: isFetching, rows: rows || [], columns: columns }));
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
*
|
|
816
|
-
* @param props
|
|
817
|
-
* @returns {ReactElement} Custom toolbar for Datagrid
|
|
818
|
-
*/
|
|
819
|
-
function CustomToolbar(props) {
|
|
820
|
-
const { setRowModesModel, setRows, locationID } = props;
|
|
821
|
-
const handleClick = () => {
|
|
822
|
-
const id = DateTime.now().toMillis();
|
|
823
|
-
setRows((oldRows) => [
|
|
824
|
-
...oldRows,
|
|
825
|
-
{
|
|
826
|
-
id,
|
|
827
|
-
name: "",
|
|
828
|
-
accessorial_id: 0,
|
|
829
|
-
contract: false,
|
|
830
|
-
cost_amount: 0,
|
|
831
|
-
load_type: "all",
|
|
832
|
-
location_id: locationID,
|
|
833
|
-
isNew: true,
|
|
834
|
-
},
|
|
835
|
-
]);
|
|
836
|
-
setRowModesModel((oldModel) => ({
|
|
837
|
-
...oldModel,
|
|
838
|
-
[id]: { mode: GridRowModes.Edit, fieldToFocus: "accessorial_id" },
|
|
839
|
-
}));
|
|
840
|
-
};
|
|
841
|
-
return (_jsx(_Fragment, { children: _jsx(Box, { sx: { display: "flex", gap: 1, p: 1, position: "relative" }, children: _jsx(Button, { variant: "soft", size: "sm", onClick: handleClick, children: "+ Accessorial" }) }) }));
|
|
842
|
-
}
|
|
843
|
-
/**
|
|
844
|
-
*
|
|
845
|
-
* @param root0
|
|
846
|
-
* @param root0.locationID
|
|
847
|
-
*/
|
|
848
|
-
function DocumentsList({ locationID }) {
|
|
849
|
-
const confirm = useNerdConfirm();
|
|
850
|
-
const [shareFileAction, { isLoading }] = useShareArcherFileMutation();
|
|
851
|
-
const [deleteFile] = useDeleteArcherFileMutation();
|
|
852
|
-
const { data: rows, isLoading: loadingRows } = useGetLocationFilesQuery(locationID);
|
|
853
|
-
const [iframe, setIframe] = useState("");
|
|
854
|
-
const [iframeLoading, setIframeLoading] = useState(true);
|
|
855
|
-
const [shareFile, setShareFile] = useState(null);
|
|
856
|
-
const params = {
|
|
857
|
-
filters: JSON.stringify([
|
|
858
|
-
{ name: "people.company_id", comparison: "eq", value: 1 },
|
|
859
|
-
{ name: "people.active", comparison: "eq", value: true },
|
|
860
|
-
]),
|
|
861
|
-
};
|
|
862
|
-
const { data: _personNames } = useGetPeopleQuery(params);
|
|
863
|
-
const columns = useMemo(() => [
|
|
864
|
-
{ field: "name", headerName: "File", flex: 1 },
|
|
865
|
-
{
|
|
866
|
-
field: "description",
|
|
867
|
-
headerName: "Type",
|
|
868
|
-
flex: 1,
|
|
869
|
-
},
|
|
870
|
-
{
|
|
871
|
-
field: "person_id",
|
|
872
|
-
headerName: "Uploaded By",
|
|
873
|
-
flex: 1,
|
|
874
|
-
renderCell(params) {
|
|
875
|
-
return _personNames?.entities[params.value]
|
|
876
|
-
? new Person(_personNames?.entities[params.value]).name()
|
|
877
|
-
: "";
|
|
878
|
-
},
|
|
879
|
-
},
|
|
880
|
-
{
|
|
881
|
-
field: "actions",
|
|
882
|
-
type: "actions",
|
|
883
|
-
headerName: "Actions",
|
|
884
|
-
getActions: ({ row }) => [
|
|
885
|
-
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-eye" }), label: `View File`, onClick: () => {
|
|
886
|
-
setIframe(`${window._APP_CONFIG?.api?.endpoint}/v3/file-service/files/${row.id}?inline=1`);
|
|
887
|
-
} }, "view"),
|
|
888
|
-
_jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-download" }), label: `Download File`, onClick: () => {
|
|
889
|
-
const link = document.createElement("a");
|
|
890
|
-
link.href = `${window._APP_CONFIG?.api?.endpoint}/v3/file-service/files/${row.id}`;
|
|
891
|
-
link.click();
|
|
892
|
-
link.remove();
|
|
893
|
-
} }, "download"),
|
|
894
|
-
_jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-trash" }), label: `Delete File`, onClick: () => {
|
|
895
|
-
confirm.setOpen({
|
|
896
|
-
onConfirm() {
|
|
897
|
-
deleteFile(row.id);
|
|
898
|
-
},
|
|
899
|
-
});
|
|
900
|
-
} }, "delete"),
|
|
901
|
-
_jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-share" }), label: `Share File`, onClick: () => {
|
|
902
|
-
setShareFile(row);
|
|
903
|
-
} }, "share"),
|
|
904
|
-
],
|
|
905
|
-
},
|
|
906
|
-
], [_personNames]);
|
|
907
|
-
useEffect(() => {
|
|
908
|
-
if (rows && shareFile) {
|
|
909
|
-
setShareFile(rows.find((r) => r.id === shareFile.id) || null);
|
|
910
|
-
}
|
|
911
|
-
else
|
|
912
|
-
setShareFile(null);
|
|
913
|
-
}, [rows]);
|
|
914
|
-
const handleClose = () => {
|
|
915
|
-
setIframe("");
|
|
916
|
-
setIframeLoading(true);
|
|
917
|
-
};
|
|
918
|
-
return (_jsxs(_Fragment, { children: [_jsx(DataGridPremium, { hideFooter: true, loading: loadingRows, rows: rows || [], columns: columns, slots: {
|
|
919
|
-
toolbar: DocumentListCustomToolbar,
|
|
920
|
-
}, slotProps: {
|
|
921
|
-
toolbar: {
|
|
922
|
-
locationID,
|
|
923
|
-
},
|
|
924
|
-
} }), _jsx(Modal, { open: Boolean(iframe), onClose: handleClose, children: _jsxs(ModalDialog, { sx: {
|
|
925
|
-
width: { xs: "85vw", lg: "40vw" },
|
|
926
|
-
height: { xs: "55vh", lg: "70vh" },
|
|
927
|
-
}, children: [iframeLoading && (_jsx(Box, { sx: {
|
|
928
|
-
position: "absolute",
|
|
929
|
-
top: 0,
|
|
930
|
-
left: 0,
|
|
931
|
-
width: "100%",
|
|
932
|
-
height: "100%",
|
|
933
|
-
display: "flex",
|
|
934
|
-
alignItems: "center",
|
|
935
|
-
justifyContent: "center",
|
|
936
|
-
}, children: _jsx(CircularProgress, {}) })), _jsx("iframe", { style: {
|
|
937
|
-
opacity: iframeLoading ? 0 : 1,
|
|
938
|
-
border: "none",
|
|
939
|
-
height: "100%",
|
|
940
|
-
width: "100%",
|
|
941
|
-
}, src: iframe, onLoad: () => setIframeLoading(false) })] }) }), _jsx(Modal, { open: Boolean(shareFile), onClose: () => setShareFile(null), children: _jsx(ModalDialog, { sx: {
|
|
942
|
-
maxWidth: 400,
|
|
943
|
-
}, children: _jsx(Grid, { container: true, spacing: 1, children: shareFile?.token ? (_jsxs(_Fragment, { children: [_jsx(Grid, { xs: 12, children: _jsx(NerdClickToCopy, { typographyProps: {
|
|
944
|
-
sx: {
|
|
945
|
-
lineBreak: "anywhere",
|
|
946
|
-
},
|
|
947
|
-
}, children: `${window._APP_CONFIG?.api?.endpoint}${window._APP_CONFIG?.api?.routePrefix}/shared_files/${shareFile.id}?token=${shareFile.token}` }) }), _jsx(Grid, { xs: 12, children: _jsx(Button, { fullWidth: true, onClick: () => {
|
|
948
|
-
shareFileAction({ id: shareFile.id, share: false });
|
|
949
|
-
}, children: "Unshare" }) })] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, { xs: 12, children: _jsx(Typography, { children: "By sharing this file it will be publicly viewable to people outside of the White Arrow organization. Do you wish to continue?" }) }), _jsx(Grid, { xs: 12, children: _jsx(Button, { loading: isLoading, fullWidth: true, onClick: () => {
|
|
950
|
-
if (shareFile?.id)
|
|
951
|
-
shareFileAction({ id: shareFile.id, share: true });
|
|
952
|
-
}, children: "Share" }) })] })) }) }) })] }));
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
*
|
|
956
|
-
* @param root0
|
|
957
|
-
* @param root0.locationID
|
|
958
|
-
*/
|
|
959
|
-
function DocumentListCustomToolbar({ locationID, }) {
|
|
960
|
-
const dispatch = useDispatch();
|
|
961
|
-
const [uploadFile] = useUploadArcherFileMutation();
|
|
962
|
-
const handleUpload = (file) => {
|
|
963
|
-
uploadFile({
|
|
964
|
-
file,
|
|
965
|
-
description: "Location Form",
|
|
966
|
-
modelID: locationID,
|
|
967
|
-
modelType: "Location",
|
|
968
|
-
});
|
|
969
|
-
};
|
|
970
|
-
return (_jsx(_Fragment, { children: _jsx(Box, { sx: { display: "flex", gap: 1, p: 1, position: "relative" }, children: _jsx(NerdFileUpload, { uploadFile: handleUpload, slotProps: {
|
|
971
|
-
root: {
|
|
972
|
-
variant: "soft",
|
|
973
|
-
size: "sm",
|
|
974
|
-
},
|
|
975
|
-
}, maxSize: 30000000, onError: (error) => dispatch(showNotification({
|
|
976
|
-
severity: "danger",
|
|
977
|
-
title: error.message,
|
|
978
|
-
autohide: true,
|
|
979
|
-
variant: "non-intrusive",
|
|
980
|
-
})) }) }) }));
|
|
981
|
-
}
|
|
982
|
-
//# sourceMappingURL=locationsFormSales.js.map
|