@nerdjs/sales-kit 3.1.0 → 3.1.2

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