@nerdjs/sales-kit 2.4.2 → 2.4.3

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 (74) hide show
  1. package/dist/entities/cargoConsolidation/cargoConsolidation.d.ts +2 -2
  2. package/dist/entities/quoteResponse/quoteResponse.d.ts +1 -0
  3. package/dist/entities/tenderRequest/tenderRequest.d.ts +1 -0
  4. package/dist/entities/tenderRequest/tenderRequest.js +1 -0
  5. package/dist/entities/tenderRequest/tenderRequest.js.map +1 -1
  6. package/dist/hooks/lep/index.d.ts +1 -1
  7. package/dist/hooks/lep/index.js +1 -1
  8. package/dist/hooks/lep/index.js.map +1 -1
  9. package/dist/hooks/lep/lepAppointmentArrivals.js +26 -12
  10. package/dist/hooks/lep/lepAppointmentArrivals.js.map +1 -1
  11. package/dist/hooks/lep/lepClaims.js +127 -90
  12. package/dist/hooks/lep/lepClaims.js.map +1 -1
  13. package/dist/hooks/lep/lepConsolidations.js +18 -2
  14. package/dist/hooks/lep/lepConsolidations.js.map +1 -1
  15. package/dist/hooks/lep/lepCustomerContacts.js +86 -56
  16. package/dist/hooks/lep/lepCustomerContacts.js.map +1 -1
  17. package/dist/hooks/lep/lepCustomerPeople.js +81 -51
  18. package/dist/hooks/lep/lepCustomerPeople.js.map +1 -1
  19. package/dist/hooks/lep/lepCustomerSalesNotes.js +45 -9
  20. package/dist/hooks/lep/lepCustomerSalesNotes.js.map +1 -1
  21. package/dist/hooks/lep/lepCustomersAccessorials.js +17 -4
  22. package/dist/hooks/lep/lepCustomersAccessorials.js.map +1 -1
  23. package/dist/hooks/lep/lepDispatches.js +26 -12
  24. package/dist/hooks/lep/lepDispatches.js.map +1 -1
  25. package/dist/hooks/lep/lepDocuments.js +25 -9
  26. package/dist/hooks/lep/lepDocuments.js.map +1 -1
  27. package/dist/hooks/lep/lepEDI.js +22 -6
  28. package/dist/hooks/lep/lepEDI.js.map +1 -1
  29. package/dist/hooks/lep/lepHosLogs.js +26 -12
  30. package/dist/hooks/lep/lepHosLogs.js.map +1 -1
  31. package/dist/hooks/lep/lepInvoiceLineItems.js +20 -3
  32. package/dist/hooks/lep/lepInvoiceLineItems.js.map +1 -1
  33. package/dist/hooks/lep/lepKickbacks.js +57 -12
  34. package/dist/hooks/lep/lepKickbacks.js.map +1 -1
  35. package/dist/hooks/lep/lepLoadChanges.js +19 -3
  36. package/dist/hooks/lep/lepLoadChanges.js.map +1 -1
  37. package/dist/hooks/lep/lepNotifications.js +68 -32
  38. package/dist/hooks/lep/lepNotifications.js.map +1 -1
  39. package/dist/hooks/lep/lepPossibleIssues.js +24 -8
  40. package/dist/hooks/lep/lepPossibleIssues.js.map +1 -1
  41. package/dist/hooks/lep/lepRateLogs.js +18 -2
  42. package/dist/hooks/lep/lepRateLogs.js.map +1 -1
  43. package/dist/hooks/lep/lepRateReviews.js +20 -4
  44. package/dist/hooks/lep/lepRateReviews.js.map +1 -1
  45. package/dist/hooks/lep/{lepTendersWidget.d.ts → lepTenders.d.ts} +1 -1
  46. package/dist/hooks/lep/{lepTendersWidget.js → lepTenders.js} +22 -5
  47. package/dist/hooks/lep/lepTenders.js.map +1 -0
  48. package/dist/hooks/lep/lepWorkflowEvents.js +26 -12
  49. package/dist/hooks/lep/lepWorkflowEvents.js.map +1 -1
  50. package/dist/hooks/lep/loadEditPanel.js +2 -2
  51. package/dist/hooks/lep/loadEditPanel.js.map +1 -1
  52. package/dist/hooks/quote/result.d.ts +2 -2
  53. package/dist/hooks/quote/result.js +161 -58
  54. package/dist/hooks/quote/result.js.map +1 -1
  55. package/dist/hooks/quote/template.d.ts +1 -1
  56. package/dist/hooks/quote/template.js.map +1 -1
  57. package/dist/hooks/tender/form.js +28 -22
  58. package/dist/hooks/tender/form.js.map +1 -1
  59. package/dist/locales/en/common.json +9 -1
  60. package/dist/locales/index.d.ts +8 -0
  61. package/dist/redux/quote/quoteAction.d.ts +15 -0
  62. package/dist/redux/quote/quoteAction.js +27 -0
  63. package/dist/redux/quote/quoteAction.js.map +1 -1
  64. package/dist/redux/quote/quoteCustomerPortalEndpoints.d.ts +16 -1
  65. package/dist/redux/quote/quoteCustomerPortalEndpoints.js +10 -1
  66. package/dist/redux/quote/quoteCustomerPortalEndpoints.js.map +1 -1
  67. package/dist/redux/quote/quoteReducer.d.ts +3 -0
  68. package/dist/redux/quote/quoteReducer.js +16 -1
  69. package/dist/redux/quote/quoteReducer.js.map +1 -1
  70. package/dist/redux/quote/quoteSelectors.d.ts +15 -0
  71. package/dist/redux/quote/quoteSelectors.js +6 -0
  72. package/dist/redux/quote/quoteSelectors.js.map +1 -1
  73. package/package.json +1 -1
  74. package/dist/hooks/lep/lepTendersWidget.js.map +0 -1
@@ -1,21 +1,21 @@
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, } from "@mui/joy";
3
- import { alpha, darken, styled } from "@mui/system";
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";
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, setFormOpen, setMarketCostOpen, setQuoteResult, setSelectedDate, setSelectedServiceLevel, } from "../../redux/quote";
9
+ import { restartQuote, setCostBreakdownOpen, setEconomyCargoLiability, setFormOpen, setGuaranteedCargoLiability, setMarketCostOpen, setPremiumCargoLiability, setQuoteResult, setSelectedDate, setSelectedServiceLevel, useCalculateLoadLiabilityCostMutation, } from "../../redux/quote";
10
10
  import { useLazyGetCostBreakdownQuery, useGetMarketCostQuery, useLazyGetMarketCostQuery, } from "../../redux/quote/quoteCustomerPortalEndpoints";
11
- import { costBreakdownOpenSelector, formOpenSelector, selectedDateSelector, selectedServiceLevelSelector, } from "../../redux/quote/quoteSelectors";
11
+ import { costBreakdownOpenSelector, economyCargoLiabilitySelector, formOpenSelector, guaranteedCargoLiabilitySelector, premiumCargoLiabilitySelector, 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";
15
15
  import { useHotkeys } from "react-hotkeys-hook";
16
16
  import { useGetCustomerCreditQuery } from "../../redux";
17
17
  import { nanoid } from "@reduxjs/toolkit";
18
- import { CustomAdapterLuxon } from "@nerdjs/nerd-ui";
18
+ import { CustomAdapterLuxon, NerdCurrencyField } from "@nerdjs/nerd-ui";
19
19
  const DATE_FORMAT = "LLL d";
20
20
  /**
21
21
  * QuoteResponse. A drawer that displays the quote response
@@ -165,7 +165,7 @@ export function ServiceLevels({ customerPortal, response, }) {
165
165
  }, children: [_jsx(Typography, { level: "body-sm", children: t("global.Extra") }), _jsx(Typography, { level: "body-sm", children: usdFormatter.format(l.extra) })] })] }), _jsx(Divider, { sx: { mt: "auto" } }), _jsxs(Box, { sx: {
166
166
  display: "flex",
167
167
  justifyContent: "space-between",
168
- }, children: [_jsxs(Typography, { level: "body-md", children: [t("global.Total"), ":"] }), _jsx(Typography, { level: "body-md", children: usdFormatter.format(l.totalRate) })] }), _jsx(Button, { onClick: () => {
168
+ }, children: [_jsxs(Typography, { level: "body-md", children: [t("global.Total"), ":"] }), _jsx(Typography, { level: "body-md", children: usdFormatter.format(l.totalRate + 500) })] }), _jsx(Button, { onClick: () => {
169
169
  dispatch(setSelectedDate(null));
170
170
  dispatch(setSelectedServiceLevel(l));
171
171
  }, sx: {
@@ -198,28 +198,49 @@ function ServiceLevelsDetails({ quoteResponse, }) {
198
198
  const { serviceLevels } = quoteResponse;
199
199
  const dispatch = useDispatch();
200
200
  const { t } = useTranslation("common", { i18n: salesKitI18n });
201
+ const [openEcoCargoLiabilityForm, setOpenEcoCargoLiabilityForm] = useState(false);
202
+ const [openPreCargoLiabilityForm, setOpenPreCargoLiabilityForm] = useState(false);
203
+ const [openGuaCargoLiabilityForm, setOpenGuaCargoLiabilityForm] = useState(false);
201
204
  const { economy, guaranteed, premium } = useMemo(() => {
202
205
  const economy = serviceLevels?.find((s) => s.serviceLevel == "economy");
203
206
  const premium = serviceLevels?.find((s) => s.serviceLevel == "premium");
204
207
  const guaranteed = serviceLevels?.find((s) => s.serviceLevel == "guaranteed");
205
208
  return { economy, premium, guaranteed };
206
209
  }, [serviceLevels]);
210
+ const minEconomyLiabilityCoverage = useMemo(() => economy?.liabilityCoverage || 0, [economy?.liabilityCoverage]);
211
+ const minPremiumLiabilityCoverage = useMemo(() => premium?.liabilityCoverage || 0, [premium?.liabilityCoverage]);
212
+ 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);
219
+ useEffect(() => {
220
+ dispatch(setGuaranteedCargoLiability(minGuaranteedLiabilityCoverage));
221
+ dispatch(setPremiumCargoLiability(minPremiumLiabilityCoverage));
222
+ dispatch(setEconomyCargoLiability(minEconomyLiabilityCoverage));
223
+ }, [
224
+ minEconomyLiabilityCoverage,
225
+ minPremiumLiabilityCoverage,
226
+ minGuaranteedLiabilityCoverage,
227
+ ]);
207
228
  return (_jsx(Sheet, { sx: {
208
229
  borderRadius: "sm",
209
230
  boxShadow: "md",
210
231
  }, children: _jsxs(Table, { sx: {
211
232
  "& td": { textAlign: "center" },
212
- }, size: "lg", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: {
233
+ }, size: "md", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: {
213
234
  width: "50px",
214
235
  } }), _jsx("th", { style: {
215
236
  width: "125px",
216
237
  } }), guaranteed && (_jsxs("th", { style: {
217
238
  textAlign: "center",
218
- }, children: [_jsx("img", { width: 60, alt: "guaranteed", src: quoteResponse.getGuaranteedIcon() }), _jsx(Typography, { children: guaranteed.name })] })), premium && (_jsxs("th", { style: {
239
+ }, children: [_jsx("img", { width: 45, alt: "guaranteed", src: quoteResponse.getGuaranteedIcon() }), _jsx(Typography, { children: guaranteed.name })] })), premium && (_jsxs("th", { style: {
219
240
  textAlign: "center",
220
- }, children: [_jsx("img", { width: 60, alt: "premium", src: quoteResponse.getPremiumIcon() }), _jsx(Typography, { children: premium.name })] })), economy && (_jsxs("th", { style: {
241
+ }, children: [_jsx("img", { width: 45, alt: "premium", src: quoteResponse.getPremiumIcon() }), _jsx(Typography, { children: premium.name })] })), economy && (_jsxs("th", { style: {
221
242
  textAlign: "center",
222
- }, children: [_jsx("img", { width: 60, alt: "economy", src: quoteResponse.getEconomyIcon() }), _jsx(Typography, { children: economy.name })] }))] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("th", { children: _jsx("i", { className: "fa-solid fa-truck-clock" }) }), _jsx("th", { style: {
243
+ }, children: [_jsx("img", { width: 45, alt: "economy", src: quoteResponse.getEconomyIcon() }), _jsx(Typography, { children: economy.name })] }))] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("th", { children: _jsx("i", { className: "fa-solid fa-truck-clock" }) }), _jsx("th", { style: {
223
244
  whiteSpace: "normal",
224
245
  wordBreak: "break-word",
225
246
  }, children: t("global.Transit Time") }), guaranteed && _jsx("td", { children: guaranteed.description }), premium && _jsx("td", { children: premium.description }), economy && _jsx("td", { children: economy.description })] }), _jsxs("tr", { children: [_jsx("th", { children: _jsx("i", { className: "fa-solid fa-calendar-days" }) }), _jsx("th", { style: {
@@ -240,6 +261,25 @@ function ServiceLevelsDetails({ quoteResponse, }) {
240
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: {
241
262
  whiteSpace: "normal",
242
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: {
268
+ 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: {
281
+ whiteSpace: "normal",
282
+ wordBreak: "break-word",
243
283
  }, 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: {
244
284
  whiteSpace: "normal",
245
285
  wordBreak: "break-word",
@@ -249,7 +289,10 @@ function ServiceLevelsDetails({ quoteResponse, }) {
249
289
  }, 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: {
250
290
  whiteSpace: "normal",
251
291
  wordBreak: "break-word",
252
- }, children: t("global.Total") }), guaranteed && _jsx("td", { children: usdFormatter.format(guaranteed.totalRate) }), premium && _jsx("td", { children: usdFormatter.format(premium.totalRate) }), economy && _jsx("td", { children: usdFormatter.format(economy.totalRate) })] })] }), _jsx("tfoot", { style: {
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: {
253
296
  height: 70,
254
297
  }, children: _jsxs("tr", { children: [_jsx("th", {}), _jsx("th", { style: {
255
298
  borderBottomRightRadius: 0,
@@ -258,45 +301,83 @@ function ServiceLevelsDetails({ quoteResponse, }) {
258
301
  }, children: _jsx(Button, { onClick: () => {
259
302
  dispatch(setSelectedDate(null));
260
303
  dispatch(setSelectedServiceLevel(guaranteed));
261
- }, sx: {
262
- height: "100%",
263
- background: quoteResponse.getGuaranteedColor(),
264
- color: "white",
265
- "&:hover": {
266
- background: darken(quoteResponse.getGuaranteedColor(), 0.3),
267
- },
268
- }, children: _jsxs(Box, { children: [t("global.Select delivery date"), _jsx("br", {}), _jsxs(Typography, { level: "body-sm", display: "block", sx: { color: "inherit" }, children: [DateTime.fromFormat(guaranteed.from, "yyyy-L-d").toFormat(DATE_FORMAT), guaranteed.from != guaranteed.to
304
+ }, color: "danger", children: _jsxs(Box, { children: [t("global.Select delivery date"), _jsx("br", {}), _jsxs(Typography, { level: "body-sm", display: "block", sx: { color: "inherit" }, children: [DateTime.fromFormat(guaranteed.from, "yyyy-L-d").toFormat(DATE_FORMAT), guaranteed.from != guaranteed.to
269
305
  ? ` - ${DateTime.fromFormat(guaranteed.to, "yyyy-L-d").toFormat(DATE_FORMAT)}`
270
306
  : []] })] }) }) })), premium && (_jsx("td", { style: {
271
307
  borderBottomLeftRadius: 0,
272
308
  }, children: _jsx(Button, { onClick: () => {
273
309
  dispatch(setSelectedDate(null));
274
310
  dispatch(setSelectedServiceLevel(premium));
275
- }, sx: {
276
- height: "100%",
277
- background: quoteResponse.getPremiumColor(),
278
- color: "white",
279
- "&:hover": {
280
- background: darken(quoteResponse.getPremiumColor(), 0.3),
281
- },
282
- }, children: _jsxs(Box, { children: [t("global.Select delivery window"), _jsx("br", {}), _jsxs(Typography, { level: "body-sm", display: "block", sx: { color: "inherit" }, children: [DateTime.fromFormat(premium.from, "yyyy-L-d").toFormat(DATE_FORMAT), premium.from != premium.to
311
+ }, color: "warning", children: _jsxs(Box, { children: [t("global.Select delivery window"), _jsx("br", {}), _jsxs(Typography, { level: "body-sm", display: "block", sx: { color: "inherit" }, children: [DateTime.fromFormat(premium.from, "yyyy-L-d").toFormat(DATE_FORMAT), premium.from != premium.to
283
312
  ? ` - ${DateTime.fromFormat(premium.to, "yyyy-L-d").toFormat(DATE_FORMAT)}`
284
313
  : []] })] }) }) })), economy && (_jsx("td", { style: {
285
314
  borderBottomLeftRadius: 0,
286
315
  }, children: _jsx(Button, { onClick: () => {
287
316
  dispatch(setSelectedDate(null));
288
317
  dispatch(setSelectedServiceLevel(economy));
289
- }, sx: {
290
- height: "100%",
291
- background: quoteResponse.getEconomyColor(),
292
- color: "white",
293
- "&:hover": {
294
- background: darken(quoteResponse.getEconomyColor(), 0.3),
295
- },
296
- }, children: _jsxs(Box, { children: [t("global.Select delivery window"), _jsx("br", {}), _jsxs(Typography, { level: "body-sm", display: "block", sx: { color: "inherit" }, children: [DateTime.fromFormat(economy.from, "yyyy-L-d").toFormat(DATE_FORMAT), economy.from != economy.to
318
+ }, color: "success", children: _jsxs(Box, { children: [t("global.Select delivery window"), _jsx("br", {}), _jsxs(Typography, { level: "body-sm", display: "block", sx: { color: "inherit" }, children: [DateTime.fromFormat(economy.from, "yyyy-L-d").toFormat(DATE_FORMAT), economy.from != economy.to
297
319
  ? ` - ${DateTime.fromFormat(economy.to, "yyyy-L-d").toFormat(DATE_FORMAT)}`
298
320
  : []] })] }) }) }))] }) })] }) }));
299
321
  }
322
+ const EditCargoLiabilityModal = ({ value, setValue, open, onClose, minValue, serviceLevel, }) => {
323
+ 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,
328
+ });
329
+ const result = useSelector(quoteResultSelector);
330
+ const handleSave = () => {
331
+ if (result && _value !== undefined) {
332
+ calculateCost({
333
+ amount: _value,
334
+ weight: result?.weight,
335
+ })
336
+ .unwrap()
337
+ .then(() => {
338
+ setValue(_value);
339
+ handleClose();
340
+ })
341
+ .catch(() => {
342
+ return;
343
+ });
344
+ }
345
+ };
346
+ const handleClose = () => {
347
+ onClose();
348
+ _setValue(undefined);
349
+ };
350
+ useEffect(() => {
351
+ _setValue(value);
352
+ }, [open]);
353
+ return (_jsx(Modal, { open: open, onClose: handleClose, children: _jsxs(ModalDialog, { layout: "center", sx: (theme) => ({
354
+ width: 450,
355
+ [theme.breakpoints.only("xs")]: {
356
+ top: 0,
357
+ left: 0,
358
+ right: 0,
359
+ bottom: 0,
360
+ border: 0,
361
+ borderRadius: 0,
362
+ transform: "initial",
363
+ maxWidth: "initial",
364
+ maxHeight: "initial",
365
+ width: "initial",
366
+ },
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") })] })] }) }));
380
+ };
300
381
  /**
301
382
  * Quote toolbar. Contains actions like restart, run quote or find a quote.
302
383
  *
@@ -588,7 +669,6 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
588
669
  const dispatch = useDispatch();
589
670
  const { t } = useTranslation("common", { i18n: salesKitI18n });
590
671
  const DATE_FORMAT = "LLLL d yyyy";
591
- const theme = useTheme();
592
672
  const expired = response
593
673
  ? DateTime.now() >
594
674
  DateTime.fromISO(response.createdAt).plus({
@@ -598,9 +678,24 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
598
678
  })
599
679
  : false;
600
680
  const { data: customerCredit } = useGetCustomerCreditQuery(response?.customerId || 0, { skip: !response?.customerId || customerPortal });
601
- const swatch = response?.type === "LTL"
602
- ? serviceLevelColors(theme).LTL
603
- : serviceLevelColors(theme).TL;
681
+ const { data: _cargoLiabilityCost } = useCalculateLoadLiabilityCostMutation({
682
+ fixedCacheKey: selectedServiceLevel?.serviceLevel,
683
+ })[1];
684
+ const cargoLiabilityCost = useMemo(() => {
685
+ switch (selectedServiceLevel?.serviceLevel) {
686
+ case "economy":
687
+ return _cargoLiabilityCost?.economy || 0;
688
+ case "premium":
689
+ return _cargoLiabilityCost?.premium || 0;
690
+ case "guaranteed":
691
+ return _cargoLiabilityCost?.guaranteed || 0;
692
+ default:
693
+ return 0;
694
+ }
695
+ }, [_cargoLiabilityCost]);
696
+ const guaranteedCargoLiability = useSelector(guaranteedCargoLiabilitySelector);
697
+ const premiumCargoLiability = useSelector(premiumCargoLiabilitySelector);
698
+ const economyCargoLiability = useSelector(economyCargoLiabilitySelector);
604
699
  if (!selectedDate || !selectedServiceLevel)
605
700
  return null;
606
701
  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: {
@@ -611,11 +706,25 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
611
706
  ? DateTime.fromFormat(from.date, "yyyy-L-d").toFormat(DATE_FORMAT)
612
707
  : "" }) })] }), _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"
613
708
  ? selectedDate?.toFormat(DATE_FORMAT)
614
- : `${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", { 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"
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: {
710
+ 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"
615
712
  ? response?.getGuaranteedIcon()
616
713
  : selectedServiceLevel.serviceLevel === "premium"
617
714
  ? response?.getPremiumIcon()
618
- : 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", 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
715
+ : response?.getEconomyIcon(), style: { height: 20 } }) }), _jsx("td", { children: selectedServiceLevel?.description }), _jsx("td", { children: _jsx(Chip, { size: "sm", color: cargoLiabilityCost ? "primary" : "neutral", sx: {
716
+ backgroundColor: cargoLiabilityCost
717
+ ? undefined
718
+ : "inherit",
719
+ }, children: cargoLiabilityCost === 0
720
+ ? "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
619
728
  ? 'Quote is expired, click on "Run Quote" to create a new one.'
620
729
  : body?.loadId
621
730
  ? 'Quote has already been tendered, click on "Run Quote" to create a new one.'
@@ -623,23 +732,11 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
623
732
  ? "No customer selected"
624
733
  : undefined, children: _jsx("span", { children: _jsx(Button, { disabled: (expired && customerPortal) || body?.loadId
625
734
  ? true
626
- : false || (!customerPortal && !response?.customerId), sx: {
627
- color: "white",
628
- background: response
629
- ? swatch[selectedServiceLevel.serviceLevel][500]
630
- : undefined,
631
- "&:hover": {
632
- background: response
633
- ? swatch[selectedServiceLevel.serviceLevel][700]
634
- : undefined,
635
- },
636
- "&.Mui-disabled": {
637
- background: response
638
- ? swatch[selectedServiceLevel.serviceLevel][300]
639
- : undefined,
640
- color: "white",
641
- },
642
- }, onClick: () => {
735
+ : false || (!customerPortal && !response?.customerId), color: selectedServiceLevel.serviceLevel == "economy"
736
+ ? "success"
737
+ : selectedServiceLevel.serviceLevel == "premium"
738
+ ? "warning"
739
+ : "danger", onClick: () => {
643
740
  if (response && selectedServiceLevel) {
644
741
  handleOnTenderLoadClick?.(response.id, customerPortal
645
742
  ? selectedServiceLevel.id
@@ -648,6 +745,12 @@ export const Summary = ({ handleOnTenderLoadClick, customerPortal, response, bod
648
745
  selectedServiceLevel.totalRate
649
746
  ? customerCredit.availableCredit -
650
747
  selectedServiceLevel.totalRate
748
+ : undefined, cargoLiabilityCost !== 0
749
+ ? selectedServiceLevel.serviceLevel === "economy"
750
+ ? economyCargoLiability
751
+ : selectedServiceLevel.serviceLevel === "guaranteed"
752
+ ? guaranteedCargoLiability
753
+ : premiumCargoLiability
651
754
  : undefined);
652
755
  dispatch(restartQuote());
653
756
  dispatch(setQuoteResult(undefined));