@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.
- package/dist/hooks/lep/lepActionBar.js +1 -1
- package/dist/hooks/lep/lepActionBar.js.map +1 -1
- package/dist/hooks/lep/loadEditPanel.js +1 -7
- package/dist/hooks/lep/loadEditPanel.js.map +1 -1
- package/dist/hooks/load/loadsSearchInput.d.ts +1 -0
- package/dist/hooks/load/loadsSearchInput.js +18 -1
- package/dist/hooks/load/loadsSearchInput.js.map +1 -1
- package/dist/hooks/quote/constants.js +1 -0
- package/dist/hooks/quote/constants.js.map +1 -1
- package/dist/hooks/quote/form.js +3 -3
- package/dist/hooks/quote/form.js.map +1 -1
- package/dist/hooks/quote/helpers.js +2 -1
- package/dist/hooks/quote/helpers.js.map +1 -1
- package/dist/hooks/quote/result.js +137 -89
- package/dist/hooks/quote/result.js.map +1 -1
- package/dist/locales/en/common.json +2 -1
- package/dist/locales/index.d.ts +1 -0
- package/dist/redux/quote/quoteAction.d.ts +1 -11
- package/dist/redux/quote/quoteAction.js +1 -19
- package/dist/redux/quote/quoteAction.js.map +1 -1
- package/dist/redux/quote/quoteCustomerPortalEndpoints.d.ts +4 -4
- package/dist/redux/quote/quoteCustomerPortalEndpoints.js +1 -1
- package/dist/redux/quote/quoteCustomerPortalEndpoints.js.map +1 -1
- package/dist/redux/quote/quoteReducer.d.ts +1 -3
- package/dist/redux/quote/quoteReducer.js +4 -14
- package/dist/redux/quote/quoteReducer.js.map +1 -1
- package/dist/redux/quote/quoteSalesEndpoints.d.ts +2 -2
- package/dist/redux/quote/quoteSelectors.d.ts +1 -11
- package/dist/redux/quote/quoteSelectors.js +2 -6
- package/dist/redux/quote/quoteSelectors.js.map +1 -1
- 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,
|
|
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,
|
|
10
|
-
import { useLazyGetCostBreakdownQuery, useGetMarketCostQuery, useLazyGetMarketCostQuery, } from "../../redux/quote/quoteCustomerPortalEndpoints";
|
|
11
|
-
import { costBreakdownOpenSelector,
|
|
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 [
|
|
202
|
-
|
|
203
|
-
|
|
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:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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", {}),
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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: "
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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:
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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,
|
|
359
|
+
const EditCargoLiabilityModal = ({ value, setValue, open, onClose, initialValue, }) => {
|
|
323
360
|
const { t } = useTranslation("common", { i18n: salesKitI18n });
|
|
324
|
-
const [_value, _setValue] = useState(value);
|
|
325
|
-
const [
|
|
326
|
-
|
|
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
|
-
|
|
334
|
-
|
|
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" }),
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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:
|
|
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
|
|
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
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
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
|
}
|