@nerdjs/sales-kit 2.4.4 → 2.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/hooks/lep/lepActionBar.js +1 -1
  2. package/dist/hooks/lep/lepActionBar.js.map +1 -1
  3. package/dist/hooks/lep/loadEditPanel.js +1 -7
  4. package/dist/hooks/lep/loadEditPanel.js.map +1 -1
  5. package/dist/hooks/load/loadsSearchInput.d.ts +1 -0
  6. package/dist/hooks/load/loadsSearchInput.js +18 -1
  7. package/dist/hooks/load/loadsSearchInput.js.map +1 -1
  8. package/dist/hooks/quote/constants.js +1 -0
  9. package/dist/hooks/quote/constants.js.map +1 -1
  10. package/dist/hooks/quote/form.js +3 -3
  11. package/dist/hooks/quote/form.js.map +1 -1
  12. package/dist/hooks/quote/helpers.js +2 -1
  13. package/dist/hooks/quote/helpers.js.map +1 -1
  14. package/dist/hooks/quote/result.js +137 -89
  15. package/dist/hooks/quote/result.js.map +1 -1
  16. package/dist/locales/en/common.json +2 -1
  17. package/dist/locales/index.d.ts +1 -0
  18. package/dist/redux/quote/quoteAction.d.ts +1 -11
  19. package/dist/redux/quote/quoteAction.js +1 -19
  20. package/dist/redux/quote/quoteAction.js.map +1 -1
  21. package/dist/redux/quote/quoteCustomerPortalEndpoints.d.ts +4 -4
  22. package/dist/redux/quote/quoteCustomerPortalEndpoints.js +1 -1
  23. package/dist/redux/quote/quoteCustomerPortalEndpoints.js.map +1 -1
  24. package/dist/redux/quote/quoteReducer.d.ts +1 -3
  25. package/dist/redux/quote/quoteReducer.js +4 -14
  26. package/dist/redux/quote/quoteReducer.js.map +1 -1
  27. package/dist/redux/quote/quoteSalesEndpoints.d.ts +2 -2
  28. package/dist/redux/quote/quoteSelectors.d.ts +1 -11
  29. package/dist/redux/quote/quoteSelectors.js +2 -6
  30. package/dist/redux/quote/quoteSelectors.js.map +1 -1
  31. package/package.json +1 -1
@@ -1,14 +1,14 @@
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, FormControl, FormLabel, FormHelperText, } from "@mui/joy";
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, FormControl, FormLabel, } from "@mui/joy";
3
3
  import { alpha, styled } from "@mui/system";
4
4
  import { LocalizationProvider, PickersDay, StaticDatePicker, } from "@mui/x-date-pickers";
5
5
  import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
6
6
  import salesKitI18n from "../../i18n";
7
7
  import { useTranslation } from "react-i18next";
8
8
  import { useDispatch, useSelector } from "react-redux";
9
- import { restartQuote, setCostBreakdownOpen, setEconomyCargoLiability, setFormOpen, setGuaranteedCargoLiability, setMarketCostOpen, setPremiumCargoLiability, setQuoteResult, setSelectedDate, setSelectedServiceLevel, useCalculateLoadLiabilityCostMutation, } from "../../redux/quote";
10
- import { useLazyGetCostBreakdownQuery, useGetMarketCostQuery, useLazyGetMarketCostQuery, } from "../../redux/quote/quoteCustomerPortalEndpoints";
11
- import { costBreakdownOpenSelector, economyCargoLiabilitySelector, formOpenSelector, guaranteedCargoLiabilitySelector, premiumCargoLiabilitySelector, quoteResultSelector, selectedDateSelector, selectedServiceLevelSelector, } from "../../redux/quote/quoteSelectors";
9
+ import { restartQuote, setCostBreakdownOpen, setCargoLiability, setFormOpen, setMarketCostOpen, setQuoteResult, setSelectedDate, setSelectedServiceLevel, } from "../../redux/quote";
10
+ import { useLazyGetCostBreakdownQuery, useGetMarketCostQuery, useLazyGetMarketCostQuery, useCalculateLoadLiabilityCostMutation, } from "../../redux/quote/quoteCustomerPortalEndpoints";
11
+ import { costBreakdownOpenSelector, cargoLiabilitySelector, formOpenSelector, quoteResultSelector, selectedDateSelector, selectedServiceLevelSelector, } from "../../redux/quote/quoteSelectors";
12
12
  import { SALES_QUOTE_EXPIRATION, CUSTOMER_PORTAL_QUOTE_EXPIRATION, LTL_DOC, TL_DOC, serviceLevelColors, serviceLevelIcons, usdFormatter, quoteResultToEmail, } from "./constants";
13
13
  import { DateTime } from "luxon";
14
14
  import { Link as RouterLink } from "react-router-dom";
@@ -17,6 +17,7 @@ import { useGetCustomerCreditQuery } from "../../redux";
17
17
  import { nanoid } from "@reduxjs/toolkit";
18
18
  import { CustomAdapterLuxon, NerdCurrencyField } from "@nerdjs/nerd-ui";
19
19
  const DATE_FORMAT = "LLL d";
20
+ const FIXED_CACHE_KEY = "cargoLiability";
20
21
  /**
21
22
  * QuoteResponse. A drawer that displays the quote response
22
23
  *
@@ -198,9 +199,10 @@ function ServiceLevelsDetails({ quoteResponse, }) {
198
199
  const { serviceLevels } = quoteResponse;
199
200
  const dispatch = useDispatch();
200
201
  const { t } = useTranslation("common", { i18n: salesKitI18n });
201
- const [openEcoCargoLiabilityForm, setOpenEcoCargoLiabilityForm] = useState(false);
202
- const [openPreCargoLiabilityForm, setOpenPreCargoLiabilityForm] = useState(false);
203
- const [openGuaCargoLiabilityForm, setOpenGuaCargoLiabilityForm] = useState(false);
202
+ const [openCargoLiabilityForm, setOpenCargoLiabilityForm] = useState({
203
+ open: false,
204
+ initialValue: 0,
205
+ });
204
206
  const { economy, guaranteed, premium } = useMemo(() => {
205
207
  const economy = serviceLevels?.find((s) => s.serviceLevel == "economy");
206
208
  const premium = serviceLevels?.find((s) => s.serviceLevel == "premium");
@@ -210,21 +212,16 @@ function ServiceLevelsDetails({ quoteResponse, }) {
210
212
  const minEconomyLiabilityCoverage = useMemo(() => economy?.liabilityCoverage || 0, [economy?.liabilityCoverage]);
211
213
  const minPremiumLiabilityCoverage = useMemo(() => premium?.liabilityCoverage || 0, [premium?.liabilityCoverage]);
212
214
  const minGuaranteedLiabilityCoverage = useMemo(() => guaranteed?.liabilityCoverage || 0, [guaranteed?.liabilityCoverage]);
213
- const { data: economyCargoLiabilityCost } = useCalculateLoadLiabilityCostMutation({ fixedCacheKey: "economy" })[1];
214
- const { data: premiumCargoLiabilityCost } = useCalculateLoadLiabilityCostMutation({ fixedCacheKey: "premium" })[1];
215
- const { data: guaranteedCargoLiabilityCost } = useCalculateLoadLiabilityCostMutation({ fixedCacheKey: "guaranteed" })[1];
216
- const guaranteedCargoLiability = useSelector(guaranteedCargoLiabilitySelector);
217
- const premiumCargoLiability = useSelector(premiumCargoLiabilitySelector);
218
- const economyCargoLiability = useSelector(economyCargoLiabilitySelector);
215
+ const { data: cargoLiabilityCost, reset } = useCalculateLoadLiabilityCostMutation({
216
+ fixedCacheKey: FIXED_CACHE_KEY,
217
+ })[1];
218
+ const cargoLiability = useSelector(cargoLiabilitySelector);
219
219
  useEffect(() => {
220
- dispatch(setGuaranteedCargoLiability(minGuaranteedLiabilityCoverage));
221
- dispatch(setPremiumCargoLiability(minPremiumLiabilityCoverage));
222
- dispatch(setEconomyCargoLiability(minEconomyLiabilityCoverage));
223
- }, [
224
- minEconomyLiabilityCoverage,
225
- minPremiumLiabilityCoverage,
226
- minGuaranteedLiabilityCoverage,
227
- ]);
220
+ return () => {
221
+ dispatch(setCargoLiability(0));
222
+ reset();
223
+ };
224
+ }, []);
228
225
  return (_jsx(Sheet, { sx: {
229
226
  borderRadius: "sm",
230
227
  boxShadow: "md",
@@ -258,26 +255,57 @@ function ServiceLevelsDetails({ quoteResponse, }) {
258
255
  }, 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: {
259
256
  whiteSpace: "normal",
260
257
  wordBreak: "break-word",
261
- }, 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: {
262
- whiteSpace: "normal",
263
- wordBreak: "break-word",
264
- }, children: "Cargo Liability" }), guaranteed && (_jsxs("td", { children: [_jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", flexWrap: "wrap", children: [_jsx(Chip, { color: "primary", startDecorator: guaranteedCargoLiability !==
265
- minGuaranteedLiabilityCoverage ? (_jsx("i", { className: "fa-solid fa-circle-check" })) : null, children: usdFormatter.format(guaranteedCargoLiability) }), _jsx(Button, { sx: {
266
- mt: 0.5,
267
- }, size: "sm", variant: "plain", onClick: () => setOpenGuaCargoLiabilityForm(true), children: "Add More" })] }), _jsx(EditCargoLiabilityModal, { onClose: () => setOpenGuaCargoLiabilityForm(false), open: openGuaCargoLiabilityForm, value: guaranteedCargoLiability, setValue: (v) => dispatch(setGuaranteedCargoLiability(v)), minValue: minGuaranteedLiabilityCoverage, serviceLevel: "guaranteed" })] })), premium && (_jsxs("td", { children: [_jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", flexWrap: "wrap", children: [_jsx(Chip, { color: "primary", startDecorator: premiumCargoLiability !== minPremiumLiabilityCoverage ? (_jsx("i", { className: "fa-solid fa-circle-check" })) : null, children: usdFormatter.format(premiumCargoLiability) }), _jsx(Button, { sx: {
258
+ }, 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 })] }))] }), !quoteResponse.loadId && quoteResponse.type == "LTL" ? (_jsxs(_Fragment, { children: [_jsxs("tr", { children: [_jsx("th", {}), _jsxs("th", { style: {
259
+ whiteSpace: "normal",
260
+ wordBreak: "break-word",
261
+ }, children: ["Cargo Liability", _jsx(Button, { sx: {
268
262
  mt: 0.5,
269
- }, size: "sm", variant: "plain", onClick: () => setOpenPreCargoLiabilityForm(true), children: "Add More" })] }), _jsx(EditCargoLiabilityModal, { onClose: () => setOpenPreCargoLiabilityForm(false), open: openPreCargoLiabilityForm, value: premiumCargoLiability, setValue: (v) => dispatch(setPremiumCargoLiability(v)), minValue: minPremiumLiabilityCoverage, serviceLevel: "premium" })] })), economy && (_jsxs("td", { children: [_jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", flexWrap: "wrap", children: [_jsx(Chip, { color: "primary", startDecorator: economyCargoLiability !== minEconomyLiabilityCoverage ? (_jsx("i", { className: "fa-solid fa-circle-check" })) : null, children: usdFormatter.format(economyCargoLiability) }), _jsx(Button, { sx: {
270
- mt: 0.5,
271
- }, size: "sm", variant: "plain", onClick: () => setOpenEcoCargoLiabilityForm(true), children: "Add more" })] }), _jsx(EditCargoLiabilityModal, { onClose: () => setOpenEcoCargoLiabilityForm(false), open: openEcoCargoLiabilityForm, value: economyCargoLiability, setValue: (v) => dispatch(setEconomyCargoLiability(v)), minValue: minEconomyLiabilityCoverage, serviceLevel: "economy" })] }))] }), _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
272
- whiteSpace: "normal",
273
- wordBreak: "break-word",
274
- }, children: "Cargo Liability Cost" }), guaranteed && (_jsx("td", { children: _jsx(Chip, { size: "sm", color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: guaranteedCargoLiability === minGuaranteedLiabilityCoverage
275
- ? "Included"
276
- : usdFormatter.format(guaranteedCargoLiabilityCost?.guaranteed || 0) }) })), premium && (_jsx("td", { children: _jsx(Chip, { size: "sm", color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: premiumCargoLiability === minPremiumLiabilityCoverage
277
- ? "Included"
278
- : usdFormatter.format(premiumCargoLiabilityCost?.premium || 0) }) })), economy && (_jsx("td", { children: _jsx(Chip, { size: "sm", color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: economyCargoLiability === minEconomyLiabilityCoverage
279
- ? "Included"
280
- : usdFormatter.format(economyCargoLiabilityCost?.economy || 0) }) }))] }), _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
263
+ }, size: "sm", variant: "soft", onClick: () => setOpenCargoLiabilityForm({
264
+ open: true,
265
+ initialValue: minEconomyLiabilityCoverage,
266
+ }), 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
267
+ ? "neutral"
268
+ : "primary", startDecorator: cargoLiability >
269
+ minGuaranteedLiabilityCoverage ? null : (_jsx("i", { className: "fa-solid fa-circle-check" })), sx: {
270
+ textDecoration: cargoLiability > minGuaranteedLiabilityCoverage
271
+ ? "line-through"
272
+ : undefined,
273
+ }, size: cargoLiability > minGuaranteedLiabilityCoverage
274
+ ? "sm"
275
+ : "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
276
+ ? "neutral"
277
+ : "primary", startDecorator: cargoLiability >
278
+ minPremiumLiabilityCoverage ? null : (_jsx("i", { className: "fa-solid fa-circle-check" })), sx: {
279
+ textDecoration: cargoLiability > minPremiumLiabilityCoverage
280
+ ? "line-through"
281
+ : undefined,
282
+ }, size: cargoLiability > minPremiumLiabilityCoverage
283
+ ? "sm"
284
+ : "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
285
+ ? "neutral"
286
+ : "primary", startDecorator: cargoLiability >
287
+ minEconomyLiabilityCoverage ? null : (_jsx("i", { className: "fa-solid fa-circle-check" })), sx: {
288
+ textDecoration: cargoLiability > minEconomyLiabilityCoverage
289
+ ? "line-through"
290
+ : undefined,
291
+ }, size: cargoLiability > minEconomyLiabilityCoverage
292
+ ? "sm"
293
+ : "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: {
294
+ whiteSpace: "normal",
295
+ wordBreak: "break-word",
296
+ }, children: "Cargo Liability Cost" }), guaranteed && (_jsx("td", { children: _jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: [_jsx(Chip, { sx: {
297
+ textDecoration: cargoLiabilityCost?.guaranteed
298
+ ? "line-through"
299
+ : undefined,
300
+ }, 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: {
301
+ textDecoration: cargoLiabilityCost?.premium
302
+ ? "line-through"
303
+ : undefined,
304
+ }, 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: {
305
+ textDecoration: cargoLiabilityCost?.economy
306
+ ? "line-through"
307
+ : undefined,
308
+ }, 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: {
281
309
  whiteSpace: "normal",
282
310
  wordBreak: "break-word",
283
311
  }, 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: {
@@ -289,10 +317,19 @@ function ServiceLevelsDetails({ quoteResponse, }) {
289
317
  }, 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: {
290
318
  whiteSpace: "normal",
291
319
  wordBreak: "break-word",
292
- }, children: t("global.Total") }), guaranteed && (_jsx("td", { children: guaranteedCargoLiability !== minGuaranteedLiabilityCoverage ? (_jsx(Chip, { size: "sm", color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(guaranteed.totalRate +
293
- (guaranteedCargoLiabilityCost?.guaranteed || 0)) })) : (usdFormatter.format(guaranteed.totalRate)) })), premium && (_jsx("td", { children: premiumCargoLiability !== minPremiumLiabilityCoverage ? (_jsx(Chip, { size: "sm", color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(premium.totalRate +
294
- (premiumCargoLiabilityCost?.premium || 0)) })) : (usdFormatter.format(premium.totalRate)) })), economy && (_jsx("td", { children: economyCargoLiability !== minEconomyLiabilityCoverage ? (_jsx(Chip, { size: "sm", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), color: "primary", children: usdFormatter.format(economy.totalRate +
295
- (economyCargoLiabilityCost?.economy || 0)) })) : (usdFormatter.format(economy.totalRate)) }))] })] }), _jsx("tfoot", { style: {
320
+ }, children: t("global.Total") }), guaranteed && (_jsx("td", { children: _jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: [_jsx(Chip, { size: "sm", sx: {
321
+ textDecoration: cargoLiabilityCost?.guaranteed
322
+ ? "line-through"
323
+ : undefined,
324
+ }, color: !cargoLiabilityCost?.guaranteed ? "primary" : "neutral", startDecorator: !cargoLiabilityCost?.guaranteed ? (_jsx("i", { className: "fa-solid fa-circle-check" })) : null, children: usdFormatter.format(guaranteed.totalRate) }), cargoLiabilityCost?.guaranteed ? (_jsx(Chip, { size: "sm", color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(guaranteed.totalRate + cargoLiabilityCost.guaranteed) })) : null] }) })), premium && (_jsx("td", { children: _jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: [_jsx(Chip, { size: "sm", sx: {
325
+ textDecoration: cargoLiabilityCost?.premium
326
+ ? "line-through"
327
+ : undefined,
328
+ }, color: !cargoLiabilityCost?.premium ? "primary" : "neutral", startDecorator: !cargoLiabilityCost?.premium ? (_jsx("i", { className: "fa-solid fa-circle-check" })) : null, children: usdFormatter.format(premium.totalRate) }), cargoLiabilityCost?.premium ? (_jsx(Chip, { size: "sm", color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(premium.totalRate + cargoLiabilityCost.premium) })) : null] }) })), economy && (_jsx("td", { children: _jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 0.5, children: [_jsx(Chip, { size: "sm", sx: {
329
+ textDecoration: cargoLiabilityCost?.economy
330
+ ? "line-through"
331
+ : undefined,
332
+ }, color: !cargoLiabilityCost?.economy ? "primary" : "neutral", startDecorator: !cargoLiabilityCost?.economy ? (_jsx("i", { className: "fa-solid fa-circle-check" })) : null, children: usdFormatter.format(economy.totalRate) }), cargoLiabilityCost?.economy ? (_jsx(Chip, { size: "sm", color: "primary", startDecorator: _jsx("i", { className: "fa-solid fa-circle-check" }), children: usdFormatter.format(economy.totalRate + cargoLiabilityCost.economy) })) : null] }) }))] })] }), _jsx("tfoot", { style: {
296
333
  height: 70,
297
334
  }, children: _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
298
335
  borderBottomRightRadius: 0,
@@ -319,19 +356,22 @@ function ServiceLevelsDetails({ quoteResponse, }) {
319
356
  ? ` - ${DateTime.fromFormat(economy.to, "yyyy-L-d").toFormat(DATE_FORMAT)}`
320
357
  : []] })] }) }) }))] }) })] }) }));
321
358
  }
322
- const EditCargoLiabilityModal = ({ value, setValue, open, onClose, minValue, serviceLevel, }) => {
359
+ const EditCargoLiabilityModal = ({ value, setValue, open, onClose, initialValue, }) => {
323
360
  const { t } = useTranslation("common", { i18n: salesKitI18n });
324
- const [_value, _setValue] = useState(value);
325
- const [error, setError] = useState(false);
326
- const [calculateCost, { isLoading }] = useCalculateLoadLiabilityCostMutation({
327
- fixedCacheKey: serviceLevel,
361
+ const [_value, _setValue] = useState(value ? value : undefined);
362
+ const [calculateCost] = useCalculateLoadLiabilityCostMutation({
363
+ fixedCacheKey: FIXED_CACHE_KEY,
328
364
  });
329
365
  const result = useSelector(quoteResultSelector);
366
+ //Cannot use the isLoading attribute from the useCalculateLoadLiabilityCostMutation hook
367
+ const [isLoading, setIsLoading] = useState(false);
368
+ const [isLoading2, setIsLoading2] = useState(false);
330
369
  const handleSave = () => {
331
370
  if (result && _value !== undefined) {
371
+ setIsLoading(true);
332
372
  calculateCost({
333
- amount: _value,
334
- weight: result?.weight,
373
+ statedValue: _value,
374
+ quoteID: result.id,
335
375
  })
336
376
  .unwrap()
337
377
  .then(() => {
@@ -340,15 +380,34 @@ const EditCargoLiabilityModal = ({ value, setValue, open, onClose, minValue, ser
340
380
  })
341
381
  .catch(() => {
342
382
  return;
343
- });
383
+ })
384
+ .finally(() => setIsLoading(false));
385
+ }
386
+ };
387
+ const handleReset = () => {
388
+ if (result) {
389
+ setIsLoading2(true);
390
+ calculateCost({
391
+ statedValue: 0,
392
+ quoteID: result.id,
393
+ })
394
+ .unwrap()
395
+ .then(() => {
396
+ setValue(0);
397
+ handleClose();
398
+ })
399
+ .catch(() => {
400
+ return;
401
+ })
402
+ .finally(() => setIsLoading2(false));
344
403
  }
345
404
  };
346
405
  const handleClose = () => {
347
406
  onClose();
348
- _setValue(undefined);
407
+ _setValue(value ? value : undefined);
349
408
  };
350
409
  useEffect(() => {
351
- _setValue(value);
410
+ _setValue(value ? value : undefined);
352
411
  }, [open]);
353
412
  return (_jsx(Modal, { open: open, onClose: handleClose, children: _jsxs(ModalDialog, { layout: "center", sx: (theme) => ({
354
413
  width: 450,
@@ -364,19 +423,16 @@ const EditCargoLiabilityModal = ({ value, setValue, open, onClose, minValue, ser
364
423
  maxHeight: "initial",
365
424
  width: "initial",
366
425
  },
367
- }), children: [_jsx(DialogTitle, { children: "Cargo Liability" }), _jsxs(DialogContent, { children: [_jsxs(Typography, { level: "body-sm", children: ["The minimum and included cargo liability amount for the selected service level is", " ", _jsx(Typography, { level: "body-sm", color: "primary", fontWeight: "md", children: usdFormatter.format(minValue) }), ". Feel free to increase it; the cost will be calculated automatically."] }), _jsx(Box, { mt: 1, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Cargo Liability" }), _jsx(NerdCurrencyField, { value: _value, inputProps: {
368
- fullWidth: true,
369
- error,
370
- endDecorator: _value !== minValue ? (_jsx(Tooltip, { title: "Reset", size: "sm", children: _jsx(IconButton, { size: "sm", onClick: () => _setValue(minValue), children: _jsx("i", { className: "fa-solid fa-xmark" }) }) })) : null,
371
- }, onChange: (v) => {
372
- _setValue(v);
373
- if (!v || v < minValue)
374
- setError(true);
375
- else
376
- setError(false);
377
- } }), _jsx(FormHelperText, { children: error
378
- ? `The minimum amount is ${usdFormatter.format(minValue)}`
379
- : "" })] }) })] }), _jsxs(DialogActions, { children: [_jsx(Button, { loading: isLoading, color: "primary", onClick: handleSave, disabled: error, children: t("global.Confirm") }), _jsx(Button, { color: "neutral", variant: "soft", onClick: handleClose, children: t("global.Cancel") })] })] }) }));
426
+ }), children: [_jsx(DialogTitle, { children: "Cargo Liability" }), _jsx(DialogContent, { children: _jsxs("form", { onSubmit: (event) => {
427
+ event.preventDefault();
428
+ if (_value)
429
+ handleSave();
430
+ }, children: [_jsx(Typography, { level: "body-sm", children: "Feel free to increase the Cargo Liability; the cost will be calculated automatically." }), _jsx(Box, { mt: 1, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Cargo Liability" }), _jsx(NerdCurrencyField, { value: _value, inputProps: {
431
+ fullWidth: true,
432
+ placeholder: usdFormatter.format(initialValue).substring(1),
433
+ }, onChange: (v) => {
434
+ _setValue(v);
435
+ } })] }) })] }) }), _jsxs(DialogActions, { children: [_jsx(Button, { loading: isLoading, color: "primary", onClick: handleSave, disabled: !_value, children: t("global.Confirm") }), _jsx(Button, { color: "neutral", variant: "soft", onClick: handleClose, children: t("global.Cancel") }), _jsx(Button, { loading: isLoading2, color: "neutral", variant: "soft", onClick: handleReset, children: t("global.Reset") })] })] }) }));
380
436
  };
381
437
  /**
382
438
  * Quote toolbar. Contains actions like restart, run quote or find a quote.
@@ -679,7 +735,7 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
679
735
  : false;
680
736
  const { data: customerCredit } = useGetCustomerCreditQuery(response?.customerId || 0, { skip: !response?.customerId || customerPortal });
681
737
  const { data: _cargoLiabilityCost } = useCalculateLoadLiabilityCostMutation({
682
- fixedCacheKey: selectedServiceLevel?.serviceLevel,
738
+ fixedCacheKey: FIXED_CACHE_KEY,
683
739
  })[1];
684
740
  const cargoLiabilityCost = useMemo(() => {
685
741
  switch (selectedServiceLevel?.serviceLevel) {
@@ -692,10 +748,8 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
692
748
  default:
693
749
  return 0;
694
750
  }
695
- }, [_cargoLiabilityCost]);
696
- const guaranteedCargoLiability = useSelector(guaranteedCargoLiabilitySelector);
697
- const premiumCargoLiability = useSelector(premiumCargoLiabilitySelector);
698
- const economyCargoLiability = useSelector(economyCargoLiabilitySelector);
751
+ }, [_cargoLiabilityCost, selectedServiceLevel?.serviceLevel]);
752
+ const cargoLiability = useSelector(cargoLiabilitySelector);
699
753
  if (!selectedDate || !selectedServiceLevel)
700
754
  return null;
701
755
  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: {
@@ -706,25 +760,25 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
706
760
  ? DateTime.fromFormat(from.date, "yyyy-L-d").toFormat(DATE_FORMAT)
707
761
  : "" }) })] }), _jsxs(Grid, { xs: 4, container: true, children: [_jsxs(Grid, { xs: 12, children: [_jsx("i", { className: "fa-regular fa-arrow-down" }), _jsx(Typography, { ml: 1, display: "inline", level: "body-sm", children: t("global.To") })] }), _jsx(Grid, { xs: 12, children: _jsx(Typography, { children: to?.address.line1 || t("global.Unknown Location") }) }), _jsx(Grid, { xs: 12, children: _jsxs(Typography, { children: [to?.city, ", ", to?.state] }) }), _jsx(Grid, { xs: 12, children: _jsx(Typography, { children: to?.zip }) }), _jsx(Grid, { xs: 12, children: _jsx(Chip, { startDecorator: _jsx("i", { className: "fa-solid fa-calendar-days" }), variant: "soft", children: selectedServiceLevel.serviceLevel == "guaranteed"
708
762
  ? selectedDate?.toFormat(DATE_FORMAT)
709
- : `${DateTime.fromFormat(selectedServiceLevel.from, "yyyy-L-d").toFormat(DATE_FORMAT)} - ${DateTime.fromFormat(selectedServiceLevel.to, "yyyy-L-d").toFormat(DATE_FORMAT)}` }) })] })] }), _jsxs(Grid, { xs: 12, children: [_jsx(Typography, { level: "title-lg", children: t("global.Costs") }), _jsxs(Table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t("global.Service Level") }), _jsx("th", { children: t("global.Description") }), _jsx("th", { style: {
763
+ : `${DateTime.fromFormat(selectedServiceLevel.from, "yyyy-L-d").toFormat(DATE_FORMAT)} - ${DateTime.fromFormat(selectedServiceLevel.to, "yyyy-L-d").toFormat(DATE_FORMAT)}` }) })] })] }), _jsxs(Grid, { xs: 12, children: [_jsx(Typography, { level: "title-lg", children: t("global.Costs") }), _jsxs(Table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t("global.Service Level") }), _jsx("th", { children: t("global.Description") }), !response?.loadId && response?.type == "LTL" ? (_jsx("th", { style: {
710
764
  width: 150,
711
- }, children: "Cargo Liability Cost" }), _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"
765
+ }, 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"
712
766
  ? response?.getGuaranteedIcon()
713
767
  : selectedServiceLevel.serviceLevel === "premium"
714
768
  ? response?.getPremiumIcon()
715
- : response?.getEconomyIcon(), style: { height: 20 } }) }), _jsx("td", { children: selectedServiceLevel?.description }), _jsx("td", { children: _jsx(Chip, { size: "sm", color: cargoLiabilityCost ? "primary" : "neutral", sx: {
769
+ : response?.getEconomyIcon(), style: { height: 20 } }) }), _jsx("td", { children: selectedServiceLevel?.description }), !response?.loadId && response?.type == "LTL" ? (_jsx("td", { children: _jsx(Chip, { size: "sm", color: cargoLiabilityCost ? "primary" : "neutral", sx: {
716
770
  backgroundColor: cargoLiabilityCost
717
771
  ? undefined
718
772
  : "inherit",
719
773
  }, children: cargoLiabilityCost === 0
720
774
  ? "Included"
721
- : usdFormatter.format(cargoLiabilityCost) }) }), _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, { sx: {
722
- pr: 1,
723
- }, children: t("global.Total") }), _jsx(Chip, { color: cargoLiabilityCost !== 0 ? "primary" : "neutral", sx: {
724
- backgroundColor: cargoLiabilityCost !== 0 ? undefined : "inherit",
725
- }, children: _jsx(Typography, { level: "title-md", sx: {
726
- color: "inherit",
727
- }, children: usdFormatter.format(selectedServiceLevel.totalRate + cargoLiabilityCost) }) })] }), !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
775
+ : 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
776
+ // sx={{
777
+ // pr: 1,
778
+ // }}
779
+ , { children: t("global.Total") }), _jsx(Typography, { level: "title-md", sx: {
780
+ color: "inherit",
781
+ }, 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
728
782
  ? 'Quote is expired, click on "Run Quote" to create a new one.'
729
783
  : body?.loadId
730
784
  ? 'Quote has already been tendered, click on "Run Quote" to create a new one.'
@@ -745,13 +799,7 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
745
799
  selectedServiceLevel.totalRate
746
800
  ? customerCredit.availableCredit -
747
801
  selectedServiceLevel.totalRate
748
- : undefined, cargoLiabilityCost !== 0
749
- ? selectedServiceLevel.serviceLevel === "economy"
750
- ? economyCargoLiability
751
- : selectedServiceLevel.serviceLevel === "guaranteed"
752
- ? guaranteedCargoLiability
753
- : premiumCargoLiability
754
- : undefined);
802
+ : undefined, cargoLiabilityCost !== 0 ? cargoLiability : undefined);
755
803
  dispatch(restartQuote());
756
804
  dispatch(setQuoteResult(undefined));
757
805
  }