@nerdjs/sales-kit 3.1.0 → 3.1.2
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.
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Chip, Table, Typography, LinearProgress, Alert, Link, useColorScheme, Menu, MenuItem, Dropdown, MenuButton, Sheet, useTheme, Box, CircularProgress, Modal, ModalDialog, DialogActions, DialogContent, DialogTitle, Divider, Grid, Tooltip, Accordion, AccordionDetails, AccordionSummary, AccordionGroup, accordionClasses, IconButton,
|
|
2
|
+
import { Button, Chip, Table, Typography, LinearProgress, Alert, Link, useColorScheme, Menu, MenuItem, Dropdown, MenuButton, Sheet, useTheme, Box, CircularProgress, Modal, ModalDialog, DialogActions, DialogContent, DialogTitle, Divider, Grid, Tooltip, Accordion, AccordionDetails, AccordionSummary, AccordionGroup, accordionClasses, IconButton,
|
|
3
|
+
// FormControl,
|
|
4
|
+
// FormLabel,
|
|
5
|
+
} from "@mui/joy";
|
|
3
6
|
import { alpha, styled } from "@mui/system";
|
|
4
7
|
import { LocalizationProvider, PickersDay, StaticDatePicker, } from "@mui/x-date-pickers-pro";
|
|
5
8
|
import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
6
9
|
import salesKitI18n from "../../i18n";
|
|
7
10
|
import { useTranslation } from "react-i18next";
|
|
8
11
|
import { useDispatch, useSelector } from "react-redux";
|
|
9
|
-
import { restartQuote, setCostBreakdownOpen,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
import { restartQuote, setCostBreakdownOpen,
|
|
13
|
+
// setCargoLiability,
|
|
14
|
+
setFormOpen, setMarketCostOpen, setQuoteResult, setSelectedDate, setSelectedServiceLevel, } from "../../redux/quote";
|
|
15
|
+
import { useLazyGetCostBreakdownQuery, useGetMarketCostQuery, useLazyGetMarketCostQuery,
|
|
16
|
+
// useCalculateLoadLiabilityCostMutation,
|
|
17
|
+
} from "../../redux/quote/quoteCustomerPortalEndpoints";
|
|
18
|
+
import { costBreakdownOpenSelector,
|
|
19
|
+
// cargoLiabilitySelector,
|
|
20
|
+
formOpenSelector,
|
|
21
|
+
// quoteResultSelector,
|
|
22
|
+
selectedDateSelector, selectedServiceLevelSelector, } from "../../redux/quote/quoteSelectors";
|
|
12
23
|
import { SALES_QUOTE_EXPIRATION, CUSTOMER_PORTAL_QUOTE_EXPIRATION, LTL_DOC, TL_DOC, serviceLevelColors, serviceLevelIcons, quoteResultToEmail, } from "./constants";
|
|
13
24
|
import { DateTime } from "luxon";
|
|
14
25
|
import { Link as RouterLink } from "react-router-dom";
|
|
15
26
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
16
27
|
import { useGetCustomerCreditQuery } from "../../redux";
|
|
17
28
|
import { nanoid } from "@reduxjs/toolkit";
|
|
18
|
-
import { CustomAdapterLuxon,
|
|
29
|
+
import { CustomAdapterLuxon,
|
|
30
|
+
// NerdCurrencyField
|
|
31
|
+
} from "@nerdjs/nerd-ui";
|
|
19
32
|
const DATE_FORMAT = "LLL d";
|
|
20
|
-
const FIXED_CACHE_KEY = "cargoLiability";
|
|
33
|
+
// const FIXED_CACHE_KEY = "cargoLiability";
|
|
21
34
|
const usdFormatter = new Intl.NumberFormat("en-US", {
|
|
22
35
|
style: "currency",
|
|
23
36
|
currency: "USD",
|
|
@@ -214,29 +227,39 @@ function ServiceLevelsDetails({ quoteResponse, }) {
|
|
|
214
227
|
const { serviceLevels } = quoteResponse;
|
|
215
228
|
const dispatch = useDispatch();
|
|
216
229
|
const { t } = useTranslation("common", { i18n: salesKitI18n });
|
|
217
|
-
const [openCargoLiabilityForm, setOpenCargoLiabilityForm] = useState({
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
230
|
+
// const [openCargoLiabilityForm, setOpenCargoLiabilityForm] = useState({
|
|
231
|
+
// open: false,
|
|
232
|
+
// initialValue: 0,
|
|
233
|
+
// });
|
|
221
234
|
const { economy, guaranteed, premium } = useMemo(() => {
|
|
222
235
|
const economy = serviceLevels?.find((s) => s.serviceLevel == "economy");
|
|
223
236
|
const premium = serviceLevels?.find((s) => s.serviceLevel == "premium");
|
|
224
237
|
const guaranteed = serviceLevels?.find((s) => s.serviceLevel == "guaranteed");
|
|
225
238
|
return { economy, premium, guaranteed };
|
|
226
239
|
}, [serviceLevels]);
|
|
227
|
-
const minEconomyLiabilityCoverage = useMemo(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
+
// const minEconomyLiabilityCoverage = useMemo(
|
|
241
|
+
// () => economy?.liabilityCoverage || 0,
|
|
242
|
+
// [economy?.liabilityCoverage]
|
|
243
|
+
// );
|
|
244
|
+
// const minPremiumLiabilityCoverage = useMemo(
|
|
245
|
+
// () => premium?.liabilityCoverage || 0,
|
|
246
|
+
// [premium?.liabilityCoverage]
|
|
247
|
+
// );
|
|
248
|
+
// const minGuaranteedLiabilityCoverage = useMemo(
|
|
249
|
+
// () => guaranteed?.liabilityCoverage || 0,
|
|
250
|
+
// [guaranteed?.liabilityCoverage]
|
|
251
|
+
// );
|
|
252
|
+
// const { data: cargoLiabilityCost, reset } =
|
|
253
|
+
// useCalculateLoadLiabilityCostMutation({
|
|
254
|
+
// fixedCacheKey: FIXED_CACHE_KEY,
|
|
255
|
+
// })[1];
|
|
256
|
+
// const cargoLiability = useSelector(cargoLiabilitySelector);
|
|
257
|
+
// useEffect(() => {
|
|
258
|
+
// return () => {
|
|
259
|
+
// dispatch(setCargoLiability(0));
|
|
260
|
+
// reset();
|
|
261
|
+
// };
|
|
262
|
+
// }, []);
|
|
240
263
|
return (_jsx(Sheet, { sx: {
|
|
241
264
|
borderRadius: "sm",
|
|
242
265
|
boxShadow: "md",
|
|
@@ -270,57 +293,7 @@ function ServiceLevelsDetails({ quoteResponse, }) {
|
|
|
270
293
|
}, children: t("global.Same Day Pickup") }), guaranteed && (_jsxs("td", { children: [_jsx(Typography, { children: "99.9%" }), _jsx(LinearProgress, { value: 99.9, determinate: true, thickness: 5 })] })), premium && (_jsxs("td", { children: [_jsx(Typography, { children: "85%" }), _jsx(LinearProgress, { value: 85, determinate: true, thickness: 5 })] })), economy && (_jsxs("td", { children: [_jsx(Typography, { children: "50%" }), _jsx(LinearProgress, { value: 50, determinate: true, thickness: 5 })] }))] }), _jsxs("tr", { children: [_jsx("th", { children: _jsx("i", { className: "fa-solid fa-truck-front" }) }), _jsx("th", { style: {
|
|
271
294
|
whiteSpace: "normal",
|
|
272
295
|
wordBreak: "break-word",
|
|
273
|
-
}, children: t("global.Driver / Equipment Allocation") }), guaranteed && (_jsxs("td", { children: [_jsx(Typography, { children: "99.9%" }), _jsx(LinearProgress, { value: 99.9, determinate: true, thickness: 5 })] })), premium && (_jsxs("td", { children: [_jsx(Typography, { children: "85%" }), _jsx(LinearProgress, { value: 85, determinate: true, thickness: 5 })] })), economy && (_jsxs("td", { children: [_jsx(Typography, { children: "50%" }), _jsx(LinearProgress, { value: 50, determinate: true, thickness: 5 })] }))] }),
|
|
274
|
-
whiteSpace: "normal",
|
|
275
|
-
wordBreak: "break-word",
|
|
276
|
-
}, children: ["Cargo Liability", _jsx(Button, { sx: {
|
|
277
|
-
mt: 0.5,
|
|
278
|
-
}, size: "sm", variant: "soft", onClick: () => setOpenCargoLiabilityForm({
|
|
279
|
-
open: true,
|
|
280
|
-
initialValue: minEconomyLiabilityCoverage,
|
|
281
|
-
}), startDecorator: _jsx("i", { className: "fa-solid fa-plus" }), children: "Add More" })] }), guaranteed && (_jsx("td", { children: _jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", gap: 0.5, children: [_jsx(Chip, { color: cargoLiability > minGuaranteedLiabilityCoverage
|
|
282
|
-
? "neutral"
|
|
283
|
-
: "primary", startDecorator: cargoLiability >
|
|
284
|
-
minGuaranteedLiabilityCoverage ? null : (_jsx("i", { className: "fa-solid fa-circle-check" })), sx: {
|
|
285
|
-
textDecoration: cargoLiability > minGuaranteedLiabilityCoverage
|
|
286
|
-
? "line-through"
|
|
287
|
-
: undefined,
|
|
288
|
-
}, size: cargoLiability > minGuaranteedLiabilityCoverage
|
|
289
|
-
? "sm"
|
|
290
|
-
: "md", children: usdFormatter.format(minGuaranteedLiabilityCoverage) }), cargoLiability > minGuaranteedLiabilityCoverage ? (_jsx(Chip, { color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(cargoLiability) })) : null] }) })), premium && (_jsx("td", { children: _jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", gap: 0.5, children: [_jsx(Chip, { color: cargoLiability > minPremiumLiabilityCoverage
|
|
291
|
-
? "neutral"
|
|
292
|
-
: "primary", startDecorator: cargoLiability >
|
|
293
|
-
minPremiumLiabilityCoverage ? null : (_jsx("i", { className: "fa-solid fa-circle-check" })), sx: {
|
|
294
|
-
textDecoration: cargoLiability > minPremiumLiabilityCoverage
|
|
295
|
-
? "line-through"
|
|
296
|
-
: undefined,
|
|
297
|
-
}, size: cargoLiability > minPremiumLiabilityCoverage
|
|
298
|
-
? "sm"
|
|
299
|
-
: "md", children: usdFormatter.format(minPremiumLiabilityCoverage) }), cargoLiability > minPremiumLiabilityCoverage ? (_jsx(Chip, { color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(cargoLiability) })) : null] }) })), economy && (_jsx("td", { children: _jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", gap: 0.5, children: [_jsx(Chip, { color: cargoLiability > minEconomyLiabilityCoverage
|
|
300
|
-
? "neutral"
|
|
301
|
-
: "primary", startDecorator: cargoLiability >
|
|
302
|
-
minEconomyLiabilityCoverage ? null : (_jsx("i", { className: "fa-solid fa-circle-check" })), sx: {
|
|
303
|
-
textDecoration: cargoLiability > minEconomyLiabilityCoverage
|
|
304
|
-
? "line-through"
|
|
305
|
-
: undefined,
|
|
306
|
-
}, size: cargoLiability > minEconomyLiabilityCoverage
|
|
307
|
-
? "sm"
|
|
308
|
-
: "md", children: usdFormatter.format(minEconomyLiabilityCoverage) }), cargoLiability > minEconomyLiabilityCoverage ? (_jsx(Chip, { color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(cargoLiability) })) : null] }) })), _jsx(EditCargoLiabilityModal, { onClose: () => setOpenCargoLiabilityForm({ open: false, initialValue: 0 }), initialValue: openCargoLiabilityForm.initialValue, open: openCargoLiabilityForm.open, value: cargoLiability, setValue: (v) => dispatch(setCargoLiability(v)) })] }), _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
|
|
309
|
-
whiteSpace: "normal",
|
|
310
|
-
wordBreak: "break-word",
|
|
311
|
-
}, children: "Cargo Liability Cost" }), guaranteed && (_jsx("td", { children: _jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: [_jsx(Chip, { sx: {
|
|
312
|
-
textDecoration: cargoLiabilityCost?.guaranteed
|
|
313
|
-
? "line-through"
|
|
314
|
-
: undefined,
|
|
315
|
-
}, color: cargoLiabilityCost?.guaranteed ? "neutral" : "primary", size: "sm", startDecorator: cargoLiabilityCost?.guaranteed ? undefined : (_jsx("i", { className: "fa-solid fa-circle-check" })), children: "Included" }), cargoLiabilityCost?.guaranteed ? (_jsx(Chip, { color: "primary", size: "sm", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(cargoLiabilityCost.guaranteed || 0) })) : null] }) })), premium && (_jsx("td", { children: _jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: [_jsx(Chip, { sx: {
|
|
316
|
-
textDecoration: cargoLiabilityCost?.premium
|
|
317
|
-
? "line-through"
|
|
318
|
-
: undefined,
|
|
319
|
-
}, color: cargoLiabilityCost?.premium ? "neutral" : "primary", size: "sm", startDecorator: cargoLiabilityCost?.premium ? undefined : (_jsx("i", { className: "fa-solid fa-circle-check" })), children: "Included" }), cargoLiabilityCost?.premium ? (_jsx(Chip, { color: "primary", size: "sm", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(cargoLiabilityCost.premium || 0) })) : null] }) })), economy && (_jsx("td", { children: _jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: [_jsx(Chip, { sx: {
|
|
320
|
-
textDecoration: cargoLiabilityCost?.economy
|
|
321
|
-
? "line-through"
|
|
322
|
-
: undefined,
|
|
323
|
-
}, color: cargoLiabilityCost?.economy ? "neutral" : "primary", size: "sm", startDecorator: cargoLiabilityCost?.economy ? undefined : (_jsx("i", { className: "fa-solid fa-circle-check" })), children: "Included" }), cargoLiabilityCost?.economy ? (_jsx(Chip, { color: "primary", size: "sm", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(cargoLiabilityCost.economy || 0) })) : null] }) }))] })] })) : null, _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
|
|
296
|
+
}, children: t("global.Driver / Equipment Allocation") }), guaranteed && (_jsxs("td", { children: [_jsx(Typography, { children: "99.9%" }), _jsx(LinearProgress, { value: 99.9, determinate: true, thickness: 5 })] })), premium && (_jsxs("td", { children: [_jsx(Typography, { children: "85%" }), _jsx(LinearProgress, { value: 85, determinate: true, thickness: 5 })] })), economy && (_jsxs("td", { children: [_jsx(Typography, { children: "50%" }), _jsx(LinearProgress, { value: 50, determinate: true, thickness: 5 })] }))] }), _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
|
|
324
297
|
whiteSpace: "normal",
|
|
325
298
|
wordBreak: "break-word",
|
|
326
299
|
}, children: t("global.Base") }), guaranteed && _jsx("td", { children: usdFormatter.format(guaranteed.baseRate) }), premium && _jsx("td", { children: usdFormatter.format(premium.baseRate) }), economy && _jsx("td", { children: usdFormatter.format(economy.baseRate) })] }), _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
|
|
@@ -332,19 +305,43 @@ function ServiceLevelsDetails({ quoteResponse, }) {
|
|
|
332
305
|
}, children: t("global.Extra") }), guaranteed && _jsx("td", { children: usdFormatter.format(guaranteed.extra) }), premium && _jsx("td", { children: usdFormatter.format(premium.extra) }), economy && _jsx("td", { children: usdFormatter.format(economy.extra) })] }), _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
|
|
333
306
|
whiteSpace: "normal",
|
|
334
307
|
wordBreak: "break-word",
|
|
335
|
-
}, children: t("global.Total") }), guaranteed && (_jsx("td", { children:
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
308
|
+
}, children: t("global.Total") }), guaranteed && (_jsx("td", { children: _jsx(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: _jsx(Chip, { size: "sm",
|
|
309
|
+
// sx={{
|
|
310
|
+
// textDecoration: cargoLiabilityCost?.guaranteed
|
|
311
|
+
// ? "line-through"
|
|
312
|
+
// : undefined,
|
|
313
|
+
// }}
|
|
314
|
+
color:
|
|
315
|
+
// !cargoLiabilityCost?.guaranteed ? "primary" : "neutral"
|
|
316
|
+
"primary", startDecorator:
|
|
317
|
+
// !cargoLiabilityCost?.guaranteed ? (
|
|
318
|
+
// <i className="fa-solid fa-circle-check" />
|
|
319
|
+
// ) : null
|
|
320
|
+
_jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(guaranteed.totalRate) }) }) })), premium && (_jsx("td", { children: _jsx(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: _jsx(Chip, { size: "sm",
|
|
321
|
+
// sx={{
|
|
322
|
+
// textDecoration: cargoLiabilityCost?.premium
|
|
323
|
+
// ? "line-through"
|
|
324
|
+
// : undefined,
|
|
325
|
+
// }}
|
|
326
|
+
color:
|
|
327
|
+
// !cargoLiabilityCost?.premium ? "primary" : "neutral"
|
|
328
|
+
"primary", startDecorator:
|
|
329
|
+
// !cargoLiabilityCost?.premium ? (
|
|
330
|
+
// <i className="fa-solid fa-circle-check" />
|
|
331
|
+
// ) : null
|
|
332
|
+
_jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(premium.totalRate) }) }) })), economy && (_jsx("td", { children: _jsx(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: _jsx(Chip, { size: "sm",
|
|
333
|
+
// sx={{
|
|
334
|
+
// textDecoration: cargoLiabilityCost?.economy
|
|
335
|
+
// ? "line-through"
|
|
336
|
+
// : undefined,
|
|
337
|
+
// }}
|
|
338
|
+
color:
|
|
339
|
+
// !cargoLiabilityCost?.economy ? "primary" : "neutral"
|
|
340
|
+
"primary", startDecorator:
|
|
341
|
+
// !cargoLiabilityCost?.economy ? (
|
|
342
|
+
// <i className="fa-solid fa-circle-check" />
|
|
343
|
+
// ) : null
|
|
344
|
+
_jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(economy.totalRate) }) }) }))] })] }), _jsx("tfoot", { style: {
|
|
348
345
|
height: 70,
|
|
349
346
|
}, children: _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
|
|
350
347
|
borderBottomRightRadius: 0,
|
|
@@ -371,84 +368,147 @@ function ServiceLevelsDetails({ quoteResponse, }) {
|
|
|
371
368
|
? ` - ${DateTime.fromFormat(economy.to, "yyyy-L-d").toFormat(DATE_FORMAT)}`
|
|
372
369
|
: []] })] }) }) }))] }) })] }) }));
|
|
373
370
|
}
|
|
374
|
-
const EditCargoLiabilityModal = ({
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
371
|
+
// const EditCargoLiabilityModal = ({
|
|
372
|
+
// value,
|
|
373
|
+
// setValue,
|
|
374
|
+
// open,
|
|
375
|
+
// onClose,
|
|
376
|
+
// initialValue,
|
|
377
|
+
// }: {
|
|
378
|
+
// value: number;
|
|
379
|
+
// setValue: (value: number) => void;
|
|
380
|
+
// open: boolean;
|
|
381
|
+
// onClose: () => void;
|
|
382
|
+
// initialValue: number;
|
|
383
|
+
// }) => {
|
|
384
|
+
// const { t } = useTranslation("common", { i18n: salesKitI18n });
|
|
385
|
+
// const [_value, _setValue] = useState<number | undefined>(
|
|
386
|
+
// value ? value : undefined
|
|
387
|
+
// );
|
|
388
|
+
// const [calculateCost] = useCalculateLoadLiabilityCostMutation({
|
|
389
|
+
// fixedCacheKey: FIXED_CACHE_KEY,
|
|
390
|
+
// });
|
|
391
|
+
// const result = useSelector(quoteResultSelector);
|
|
392
|
+
// //Cannot use the isLoading attribute from the useCalculateLoadLiabilityCostMutation hook
|
|
393
|
+
// const [isLoading, setIsLoading] = useState(false);
|
|
394
|
+
// const [isLoading2, setIsLoading2] = useState(false);
|
|
395
|
+
// const handleSave = () => {
|
|
396
|
+
// if (result && _value !== undefined) {
|
|
397
|
+
// setIsLoading(true);
|
|
398
|
+
// calculateCost({
|
|
399
|
+
// statedValue: _value,
|
|
400
|
+
// quoteID: result.id,
|
|
401
|
+
// })
|
|
402
|
+
// .unwrap()
|
|
403
|
+
// .then(() => {
|
|
404
|
+
// setValue(_value);
|
|
405
|
+
// handleClose();
|
|
406
|
+
// })
|
|
407
|
+
// .catch(() => {
|
|
408
|
+
// return;
|
|
409
|
+
// })
|
|
410
|
+
// .finally(() => setIsLoading(false));
|
|
411
|
+
// }
|
|
412
|
+
// };
|
|
413
|
+
// const handleReset = () => {
|
|
414
|
+
// if (result) {
|
|
415
|
+
// setIsLoading2(true);
|
|
416
|
+
// calculateCost({
|
|
417
|
+
// statedValue: 0,
|
|
418
|
+
// quoteID: result.id,
|
|
419
|
+
// })
|
|
420
|
+
// .unwrap()
|
|
421
|
+
// .then(() => {
|
|
422
|
+
// setValue(0);
|
|
423
|
+
// handleClose();
|
|
424
|
+
// })
|
|
425
|
+
// .catch(() => {
|
|
426
|
+
// return;
|
|
427
|
+
// })
|
|
428
|
+
// .finally(() => setIsLoading2(false));
|
|
429
|
+
// }
|
|
430
|
+
// };
|
|
431
|
+
// const handleClose = () => {
|
|
432
|
+
// onClose();
|
|
433
|
+
// _setValue(value ? value : undefined);
|
|
434
|
+
// };
|
|
435
|
+
// useEffect(() => {
|
|
436
|
+
// _setValue(value ? value : undefined);
|
|
437
|
+
// }, [open]);
|
|
438
|
+
// return (
|
|
439
|
+
// <Modal open={open} onClose={handleClose}>
|
|
440
|
+
// <ModalDialog
|
|
441
|
+
// layout="center"
|
|
442
|
+
// sx={(theme) => ({
|
|
443
|
+
// width: 450,
|
|
444
|
+
// [theme.breakpoints.only("xs")]: {
|
|
445
|
+
// top: 0,
|
|
446
|
+
// left: 0,
|
|
447
|
+
// right: 0,
|
|
448
|
+
// bottom: 0,
|
|
449
|
+
// border: 0,
|
|
450
|
+
// borderRadius: 0,
|
|
451
|
+
// transform: "initial",
|
|
452
|
+
// maxWidth: "initial",
|
|
453
|
+
// maxHeight: "initial",
|
|
454
|
+
// width: "initial",
|
|
455
|
+
// },
|
|
456
|
+
// })}
|
|
457
|
+
// >
|
|
458
|
+
// <DialogTitle>Cargo Liability</DialogTitle>
|
|
459
|
+
// <DialogContent>
|
|
460
|
+
// <form
|
|
461
|
+
// onSubmit={(event) => {
|
|
462
|
+
// event.preventDefault();
|
|
463
|
+
// if (_value) handleSave();
|
|
464
|
+
// }}
|
|
465
|
+
// >
|
|
466
|
+
// <Typography level="body-sm">
|
|
467
|
+
// Feel free to increase the Cargo Liability; the cost will be
|
|
468
|
+
// calculated automatically.
|
|
469
|
+
// </Typography>
|
|
470
|
+
// <Box mt={1}>
|
|
471
|
+
// <FormControl>
|
|
472
|
+
// <FormLabel>Cargo Liability</FormLabel>
|
|
473
|
+
// <NerdCurrencyField
|
|
474
|
+
// value={_value}
|
|
475
|
+
// inputProps={{
|
|
476
|
+
// fullWidth: true,
|
|
477
|
+
// placeholder: usdFormatter.format(initialValue).substring(1),
|
|
478
|
+
// }}
|
|
479
|
+
// onChange={(v) => {
|
|
480
|
+
// _setValue(v);
|
|
481
|
+
// }}
|
|
482
|
+
// />
|
|
483
|
+
// </FormControl>
|
|
484
|
+
// </Box>
|
|
485
|
+
// </form>
|
|
486
|
+
// </DialogContent>
|
|
487
|
+
// <DialogActions>
|
|
488
|
+
// <Button
|
|
489
|
+
// loading={isLoading2}
|
|
490
|
+
// color="neutral"
|
|
491
|
+
// variant="soft"
|
|
492
|
+
// onClick={handleReset}
|
|
493
|
+
// >
|
|
494
|
+
// {t("global.Reset")}
|
|
495
|
+
// </Button>
|
|
496
|
+
// <Button color="neutral" variant="soft" onClick={handleClose}>
|
|
497
|
+
// {t("global.Cancel")}
|
|
498
|
+
// </Button>
|
|
499
|
+
// <Button
|
|
500
|
+
// loading={isLoading}
|
|
501
|
+
// color="primary"
|
|
502
|
+
// onClick={handleSave}
|
|
503
|
+
// disabled={!_value}
|
|
504
|
+
// >
|
|
505
|
+
// {t("global.Confirm")}
|
|
506
|
+
// </Button>
|
|
507
|
+
// </DialogActions>
|
|
508
|
+
// </ModalDialog>
|
|
509
|
+
// </Modal>
|
|
510
|
+
// );
|
|
511
|
+
// };
|
|
452
512
|
/**
|
|
453
513
|
* Quote toolbar. Contains actions like restart, run quote or find a quote.
|
|
454
514
|
*
|
|
@@ -766,22 +826,22 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
|
|
|
766
826
|
})
|
|
767
827
|
: false;
|
|
768
828
|
const { data: customerCredit } = useGetCustomerCreditQuery(response?.customerId || 0, { skip: !response?.customerId || customerPortal });
|
|
769
|
-
const { data: _cargoLiabilityCost } = useCalculateLoadLiabilityCostMutation({
|
|
770
|
-
|
|
771
|
-
})[1];
|
|
772
|
-
const cargoLiabilityCost = useMemo(() => {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
}, [_cargoLiabilityCost, selectedServiceLevel?.serviceLevel]);
|
|
784
|
-
const cargoLiability = useSelector(cargoLiabilitySelector);
|
|
829
|
+
// const { data: _cargoLiabilityCost } = useCalculateLoadLiabilityCostMutation({
|
|
830
|
+
// fixedCacheKey: FIXED_CACHE_KEY,
|
|
831
|
+
// })[1];
|
|
832
|
+
// const cargoLiabilityCost = useMemo(() => {
|
|
833
|
+
// switch (selectedServiceLevel?.serviceLevel) {
|
|
834
|
+
// case "economy":
|
|
835
|
+
// return _cargoLiabilityCost?.economy || 0;
|
|
836
|
+
// case "premium":
|
|
837
|
+
// return _cargoLiabilityCost?.premium || 0;
|
|
838
|
+
// case "guaranteed":
|
|
839
|
+
// return _cargoLiabilityCost?.guaranteed || 0;
|
|
840
|
+
// default:
|
|
841
|
+
// return 0;
|
|
842
|
+
// }
|
|
843
|
+
// }, [_cargoLiabilityCost, selectedServiceLevel?.serviceLevel]);
|
|
844
|
+
// const cargoLiability = useSelector(cargoLiabilitySelector);
|
|
785
845
|
if (!selectedDate || !selectedServiceLevel)
|
|
786
846
|
return null;
|
|
787
847
|
return (_jsxs(Sheet, { sx: { p: 2, borderRadius: "sm", boxShadow: "md" }, children: [_jsxs(Typography, { level: "title-lg", children: [_jsx("i", { className: "fa-duotone fa-truck pright" }), " ", t("global.Summary")] }), _jsxs(Grid, { container: true, spacing: 1, rowGap: 1.5, sx: {
|
|
@@ -798,19 +858,11 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
|
|
|
798
858
|
width: "60%",
|
|
799
859
|
}, children: t("components:lepShipcons.stop") }), _jsx("th", { style: {
|
|
800
860
|
width: "10%",
|
|
801
|
-
}, children: t("components:lepAdjustments.amount") })] }) }), _jsx("tbody", { children: response.accessorials.map((a, i) => (_jsxs("tr", { children: [_jsx("td", { children: a.name }), _jsx("td", { children: a.stopName }), _jsx("td", { children: usdFormatter.format(a.costAmount || 0) })] }, i))) })] })] })) : null, _jsxs(Grid, { xs: 12, children: [_jsx(Typography, { level: "title-lg", children: t("global.Costs") }), _jsxs(Table, { size: "sm", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t("global.Service Level") }), _jsx("th", { children: t("global.Description") }),
|
|
802
|
-
width: 150,
|
|
803
|
-
}, children: "Cargo Liability Cost" })) : null, _jsx("th", { children: t("global.Base Rate") }), _jsx("th", { children: t("global.Fuel Rate") }), _jsx("th", { children: t("global.Extra") })] }) }), _jsx("tbody", { children: _jsxs("tr", { children: [_jsx("td", { children: _jsx("img", { src: selectedServiceLevel.serviceLevel === "guaranteed"
|
|
861
|
+
}, children: t("components:lepAdjustments.amount") })] }) }), _jsx("tbody", { children: response.accessorials.map((a, i) => (_jsxs("tr", { children: [_jsx("td", { children: a.name }), _jsx("td", { children: a.stopName }), _jsx("td", { children: usdFormatter.format(a.costAmount || 0) })] }, i))) })] })] })) : null, _jsxs(Grid, { xs: 12, children: [_jsx(Typography, { level: "title-lg", children: t("global.Costs") }), _jsxs(Table, { size: "sm", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t("global.Service Level") }), _jsx("th", { children: t("global.Description") }), _jsx("th", { children: t("global.Base Rate") }), _jsx("th", { children: t("global.Fuel Rate") }), _jsx("th", { children: t("global.Extra") })] }) }), _jsx("tbody", { children: _jsxs("tr", { children: [_jsx("td", { children: _jsx("img", { src: selectedServiceLevel.serviceLevel === "guaranteed"
|
|
804
862
|
? response?.getGuaranteedIcon()
|
|
805
863
|
: selectedServiceLevel.serviceLevel === "premium"
|
|
806
864
|
? response?.getPremiumIcon()
|
|
807
|
-
: response?.getEconomyIcon(), style: { height: 20 } }) }), _jsx("td", { children: selectedServiceLevel?.description }),
|
|
808
|
-
backgroundColor: cargoLiabilityCost
|
|
809
|
-
? undefined
|
|
810
|
-
: "inherit",
|
|
811
|
-
}, children: cargoLiabilityCost === 0
|
|
812
|
-
? "Included"
|
|
813
|
-
: usdFormatter.format(cargoLiabilityCost) }) })) : null, _jsx("td", { children: usdFormatter.format(selectedServiceLevel.baseRate) }), _jsx("td", { children: usdFormatter.format(selectedServiceLevel.fuelRate) }), _jsx("td", { children: usdFormatter.format(selectedServiceLevel.extra) })] }) })] })] }), _jsxs(Grid, { xs: 12, textAlign: "right", justifyContent: "end", container: true, children: [_jsxs(Grid, { children: [_jsx(Typography, { children: t("global.Total") }), _jsx(Typography, { level: "title-md", sx: {
|
|
865
|
+
: response?.getEconomyIcon(), style: { height: 20 } }) }), _jsx("td", { children: selectedServiceLevel?.description }), _jsx("td", { children: usdFormatter.format(selectedServiceLevel.baseRate) }), _jsx("td", { children: usdFormatter.format(selectedServiceLevel.fuelRate) }), _jsx("td", { children: usdFormatter.format(selectedServiceLevel.extra) })] }) })] })] }), _jsxs(Grid, { xs: 12, textAlign: "right", justifyContent: "end", container: true, children: [_jsxs(Grid, { children: [_jsx(Typography, { children: t("global.Total") }), _jsx(Typography, { level: "title-md", sx: {
|
|
814
866
|
color: "inherit",
|
|
815
867
|
}, children: usdFormatter.format(selectedServiceLevel.totalRate) })] }), !customerPortal ? (_jsxs(_Fragment, { children: [_jsx(Grid, { children: _jsx(Divider, { orientation: "vertical" }) }), _jsxs(Grid, { children: [_jsx(Typography, { children: t("global.Customer Credit") }), _jsx(Typography, { level: "title-md", children: usdFormatter.format(customerCredit?.availableCredit || 0) })] })] })) : null] }), !hideTenderButton ? (_jsx(Grid, { xs: 12, textAlign: "right", children: _jsx(Tooltip, { title: expired && customerPortal
|
|
816
868
|
? 'Quote is expired, click on "Run Quote" to create a new one.'
|
|
@@ -835,7 +887,9 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
|
|
|
835
887
|
selectedServiceLevel.totalRate
|
|
836
888
|
? customerCredit.availableCredit -
|
|
837
889
|
selectedServiceLevel.totalRate
|
|
838
|
-
: undefined
|
|
890
|
+
: undefined
|
|
891
|
+
// cargoLiabilityCost !== 0 ? cargoLiability : undefined
|
|
892
|
+
);
|
|
839
893
|
dispatch(restartQuote());
|
|
840
894
|
dispatch(setQuoteResult(undefined));
|
|
841
895
|
}
|