@nerdjs/sales-kit 1.0.9 → 2.0.0
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/entities/archerFile/archerFile.d.ts +11 -0
- package/dist/entities/archerFile/archerFile.js +48 -0
- package/dist/entities/archerFile/archerFile.js.map +1 -0
- package/dist/entities/archerFile/helper.d.ts +5 -0
- package/dist/entities/archerFile/helper.js +16 -0
- package/dist/entities/archerFile/helper.js.map +1 -0
- package/dist/entities/archerFile/index.d.ts +2 -0
- package/dist/entities/archerFile/index.js +3 -0
- package/dist/entities/archerFile/index.js.map +1 -0
- package/dist/entities/customer/index.d.ts +2 -1
- package/dist/entities/customer/index.js +2 -1
- package/dist/entities/customer/index.js.map +1 -1
- package/dist/entities/holiday/helper.d.ts +2 -0
- package/dist/entities/holiday/helper.js +4 -0
- package/dist/entities/holiday/helper.js.map +1 -1
- package/dist/entities/index.d.ts +3 -0
- package/dist/entities/index.js +3 -0
- package/dist/entities/index.js.map +1 -1
- package/dist/entities/location/helper.d.ts +3 -0
- package/dist/entities/location/helper.js +9 -0
- package/dist/entities/location/helper.js.map +1 -1
- package/dist/entities/location/index.d.ts +2 -2
- package/dist/entities/location/index.js +2 -2
- package/dist/entities/location/index.js.map +1 -1
- package/dist/entities/location/location.d.ts +5 -0
- package/dist/entities/location/location.js +7 -0
- package/dist/entities/location/location.js.map +1 -1
- package/dist/entities/path/helper.d.ts +5 -0
- package/dist/entities/path/helper.js +16 -0
- package/dist/entities/path/helper.js.map +1 -0
- package/dist/entities/path/index.d.ts +2 -0
- package/dist/entities/path/index.js +3 -0
- package/dist/entities/path/index.js.map +1 -0
- package/dist/entities/path/path.d.ts +20 -0
- package/dist/entities/path/path.js +35 -0
- package/dist/entities/path/path.js.map +1 -0
- package/dist/entities/quoteResponse/quoteResponse.d.ts +1 -0
- package/dist/entities/quoteResponse/quoteResponse.js +2 -0
- package/dist/entities/quoteResponse/quoteResponse.js.map +1 -1
- package/dist/entities/tenderCommodity/helper.d.ts +5 -0
- package/dist/entities/tenderCommodity/helper.js +16 -0
- package/dist/entities/tenderCommodity/helper.js.map +1 -0
- package/dist/entities/tenderCommodity/index.d.ts +2 -0
- package/dist/entities/tenderCommodity/index.js +3 -0
- package/dist/entities/tenderCommodity/index.js.map +1 -0
- package/dist/entities/tenderCommodity/tenderCommodity.d.ts +11 -0
- package/dist/entities/tenderCommodity/tenderCommodity.js +39 -0
- package/dist/entities/tenderCommodity/tenderCommodity.js.map +1 -0
- package/dist/entities/tenderRequest/helper.d.ts +5 -0
- package/dist/entities/tenderRequest/helper.js +16 -0
- package/dist/entities/tenderRequest/helper.js.map +1 -0
- package/dist/entities/tenderRequest/index.d.ts +2 -0
- package/dist/entities/tenderRequest/index.js +3 -0
- package/dist/entities/tenderRequest/index.js.map +1 -0
- package/dist/entities/tenderRequest/tenderRequest.d.ts +14 -0
- package/dist/entities/tenderRequest/tenderRequest.js +39 -0
- package/dist/entities/tenderRequest/tenderRequest.js.map +1 -0
- package/dist/entities/tenderResponse/helper.d.ts +5 -0
- package/dist/entities/tenderResponse/helper.js +16 -0
- package/dist/entities/tenderResponse/helper.js.map +1 -0
- package/dist/entities/tenderResponse/index.d.ts +2 -0
- package/dist/entities/tenderResponse/index.js +3 -0
- package/dist/entities/tenderResponse/index.js.map +1 -0
- package/dist/entities/tenderResponse/tenderResponse.d.ts +41 -0
- package/dist/entities/tenderResponse/tenderResponse.js +49 -0
- package/dist/entities/tenderResponse/tenderResponse.js.map +1 -0
- package/dist/entities/tenderStop/helper.d.ts +5 -0
- package/dist/entities/tenderStop/helper.js +16 -0
- package/dist/entities/tenderStop/helper.js.map +1 -0
- package/dist/entities/tenderStop/index.d.ts +2 -0
- package/dist/entities/tenderStop/index.js +3 -0
- package/dist/entities/tenderStop/index.js.map +1 -0
- package/dist/entities/tenderStop/tenderStop.d.ts +22 -0
- package/dist/entities/tenderStop/tenderStop.js +59 -0
- package/dist/entities/tenderStop/tenderStop.js.map +1 -0
- package/dist/hooks/customer/customerAutocomplete.d.ts +17 -0
- package/dist/hooks/customer/customerAutocomplete.js +35 -0
- package/dist/hooks/customer/customerAutocomplete.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/locationsForm/locationsForm.d.ts +9 -1
- package/dist/hooks/locationsForm/locationsForm.js +127 -13
- package/dist/hooks/locationsForm/locationsForm.js.map +1 -1
- package/dist/hooks/quote/form.d.ts +2 -0
- package/dist/hooks/quote/form.js +59 -32
- package/dist/hooks/quote/form.js.map +1 -1
- package/dist/hooks/quote/helpers.d.ts +13 -8
- package/dist/hooks/quote/helpers.js +232 -92
- package/dist/hooks/quote/helpers.js.map +1 -1
- package/dist/hooks/quote/result.d.ts +8 -1
- package/dist/hooks/quote/result.js +232 -45
- package/dist/hooks/quote/result.js.map +1 -1
- package/dist/hooks/quote/template.d.ts +8 -1
- package/dist/hooks/quote/template.js +49 -41
- package/dist/hooks/quote/template.js.map +1 -1
- package/dist/hooks/tender/constants.d.ts +200 -0
- package/dist/hooks/tender/constants.js +77 -0
- package/dist/hooks/tender/constants.js.map +1 -0
- package/dist/hooks/tender/form.d.ts +10 -0
- package/dist/hooks/tender/form.js +669 -0
- package/dist/hooks/tender/form.js.map +1 -0
- package/dist/hooks/tender/helpers.d.ts +51 -0
- package/dist/hooks/tender/helpers.js +465 -0
- package/dist/hooks/tender/helpers.js.map +1 -0
- package/dist/hooks/tender/index.d.ts +1 -0
- package/dist/hooks/tender/index.js +2 -0
- package/dist/hooks/tender/index.js.map +1 -0
- package/dist/hooks/tender/template.d.ts +10 -0
- package/dist/hooks/tender/template.js +25 -0
- package/dist/hooks/tender/template.js.map +1 -0
- package/dist/locales/salesKitEn.d.ts +57 -0
- package/dist/locales/salesKitEn.js +57 -0
- package/dist/locales/salesKitEn.js.map +1 -1
- package/dist/redux/api/index.d.ts +1 -0
- package/dist/redux/api/index.js +2 -0
- package/dist/redux/api/index.js.map +1 -0
- package/dist/redux/api/salesApi.d.ts +1 -0
- package/dist/redux/api/salesApi.js +22 -0
- package/dist/redux/api/salesApi.js.map +1 -0
- package/dist/redux/customer/customerEndpoints.d.ts +28 -0
- package/dist/redux/customer/customerEndpoints.js +76 -0
- package/dist/redux/customer/customerEndpoints.js.map +1 -0
- package/dist/redux/customer/index.d.ts +1 -4
- package/dist/redux/customer/index.js +1 -4
- package/dist/redux/customer/index.js.map +1 -1
- package/dist/redux/holiday/holidayEndpoints.d.ts +26 -0
- package/dist/redux/holiday/holidayEndpoints.js +63 -0
- package/dist/redux/holiday/holidayEndpoints.js.map +1 -0
- package/dist/redux/holiday/index.d.ts +2 -0
- package/dist/redux/holiday/index.js +3 -0
- package/dist/redux/holiday/index.js.map +1 -0
- package/dist/redux/index.d.ts +2 -0
- package/dist/redux/index.js +2 -0
- package/dist/redux/index.js.map +1 -1
- package/dist/redux/load/index.d.ts +1 -4
- package/dist/redux/load/index.js +1 -4
- package/dist/redux/load/index.js.map +1 -1
- package/dist/redux/load/loadEndpoints.d.ts +26 -0
- package/dist/redux/load/loadEndpoints.js +63 -0
- package/dist/redux/load/loadEndpoints.js.map +1 -0
- package/dist/redux/loadAdjustment/index.d.ts +1 -4
- package/dist/redux/loadAdjustment/index.js +1 -4
- package/dist/redux/loadAdjustment/index.js.map +1 -1
- package/dist/redux/loadAdjustment/loadAdjustmentEndpoints.d.ts +26 -0
- package/dist/redux/loadAdjustment/loadAdjustmentEndpoints.js +63 -0
- package/dist/redux/loadAdjustment/loadAdjustmentEndpoints.js.map +1 -0
- package/dist/redux/location/index.d.ts +1 -4
- package/dist/redux/location/index.js +1 -4
- package/dist/redux/location/index.js.map +1 -1
- package/dist/redux/location/locationEndpoints.d.ts +37 -0
- package/dist/redux/location/locationEndpoints.js +107 -0
- package/dist/redux/location/locationEndpoints.js.map +1 -0
- package/dist/redux/quote/index.d.ts +0 -1
- package/dist/redux/quote/index.js +0 -1
- package/dist/redux/quote/index.js.map +1 -1
- package/dist/redux/quote/quoteAction.d.ts +12 -78
- package/dist/redux/quote/quoteAction.js +221 -165
- package/dist/redux/quote/quoteAction.js.map +1 -1
- package/dist/redux/quote/quoteEndpoints.d.ts +114 -0
- package/dist/redux/quote/quoteEndpoints.js +80 -0
- package/dist/redux/quote/quoteEndpoints.js.map +1 -0
- package/dist/redux/quote/quoteHooks.d.ts +171 -0
- package/dist/redux/quote/quoteHooks.js +51 -0
- package/dist/redux/quote/quoteHooks.js.map +1 -0
- package/dist/redux/quote/quoteReducer.d.ts +5 -1
- package/dist/redux/quote/quoteReducer.js +8 -39
- package/dist/redux/quote/quoteReducer.js.map +1 -1
- package/dist/redux/quote/quoteSelector.d.ts +8 -89
- package/dist/redux/quote/quoteSelector.js +27 -41
- package/dist/redux/quote/quoteSelector.js.map +1 -1
- package/dist/redux/quoteAccessorial/index.d.ts +1 -3
- package/dist/redux/quoteAccessorial/index.js +1 -3
- package/dist/redux/quoteAccessorial/index.js.map +1 -1
- package/dist/redux/quoteAccessorial/quoteAccessorialEndpoints.d.ts +18 -0
- package/dist/redux/quoteAccessorial/quoteAccessorialEndpoints.js +52 -0
- package/dist/redux/quoteAccessorial/quoteAccessorialEndpoints.js.map +1 -0
- package/dist/redux/salesKitReducer.d.ts +3 -18
- package/dist/redux/salesKitReducer.js +2 -12
- package/dist/redux/salesKitReducer.js.map +1 -1
- package/dist/redux/shipcon/index.d.ts +1 -4
- package/dist/redux/shipcon/index.js +1 -4
- package/dist/redux/shipcon/index.js.map +1 -1
- package/dist/redux/shipcon/shipconEndpoints.d.ts +26 -0
- package/dist/redux/shipcon/shipconEndpoints.js +63 -0
- package/dist/redux/shipcon/shipconEndpoints.js.map +1 -0
- package/dist/redux/tender/index.d.ts +0 -0
- package/dist/redux/tender/index.js +2 -0
- package/dist/redux/tender/index.js.map +1 -0
- package/dist/redux/tender/tenderEndpoints.d.ts +34 -0
- package/dist/redux/tender/tenderEndpoints.js +52 -0
- package/dist/redux/tender/tenderEndpoints.js.map +1 -0
- package/dist/redux/tender/tenderSelector.d.ts +53 -0
- package/dist/redux/tender/tenderSelector.js +34 -0
- package/dist/redux/tender/tenderSelector.js.map +1 -0
- package/dist/redux/tender/tenderSlice.d.ts +40 -0
- package/dist/redux/tender/tenderSlice.js +69 -0
- package/dist/redux/tender/tenderSlice.js.map +1 -0
- package/dist/redux/types.d.ts +15 -0
- package/dist/redux/types.js +10 -0
- package/dist/redux/types.js.map +1 -0
- package/package.json +4 -3
- package/dist/redux/customer/customerActions.d.ts +0 -97
- package/dist/redux/customer/customerActions.js +0 -210
- package/dist/redux/customer/customerActions.js.map +0 -1
- package/dist/redux/customer/customerReducer.d.ts +0 -2
- package/dist/redux/customer/customerReducer.js +0 -42
- package/dist/redux/customer/customerReducer.js.map +0 -1
- package/dist/redux/customer/customerSelector.d.ts +0 -27
- package/dist/redux/customer/customerSelector.js +0 -38
- package/dist/redux/customer/customerSelector.js.map +0 -1
- package/dist/redux/customer/customerState.d.ts +0 -11
- package/dist/redux/customer/customerState.js +0 -2
- package/dist/redux/customer/customerState.js.map +0 -1
- package/dist/redux/load/loadActions.d.ts +0 -80
- package/dist/redux/load/loadActions.js +0 -172
- package/dist/redux/load/loadActions.js.map +0 -1
- package/dist/redux/load/loadReducer.d.ts +0 -2
- package/dist/redux/load/loadReducer.js +0 -35
- package/dist/redux/load/loadReducer.js.map +0 -1
- package/dist/redux/load/loadSelector.d.ts +0 -27
- package/dist/redux/load/loadSelector.js +0 -19
- package/dist/redux/load/loadSelector.js.map +0 -1
- package/dist/redux/load/loadState.d.ts +0 -8
- package/dist/redux/load/loadState.js +0 -2
- package/dist/redux/load/loadState.js.map +0 -1
- package/dist/redux/loadAdjustment/loadAdjustmentActions.d.ts +0 -80
- package/dist/redux/loadAdjustment/loadAdjustmentActions.js +0 -172
- package/dist/redux/loadAdjustment/loadAdjustmentActions.js.map +0 -1
- package/dist/redux/loadAdjustment/loadAdjustmentReducer.d.ts +0 -2
- package/dist/redux/loadAdjustment/loadAdjustmentReducer.js +0 -35
- package/dist/redux/loadAdjustment/loadAdjustmentReducer.js.map +0 -1
- package/dist/redux/loadAdjustment/loadAdjustmentSelector.d.ts +0 -15
- package/dist/redux/loadAdjustment/loadAdjustmentSelector.js +0 -12
- package/dist/redux/loadAdjustment/loadAdjustmentSelector.js.map +0 -1
- package/dist/redux/loadAdjustment/loadAdjustmentState.d.ts +0 -8
- package/dist/redux/loadAdjustment/loadAdjustmentState.js +0 -2
- package/dist/redux/loadAdjustment/loadAdjustmentState.js.map +0 -1
- package/dist/redux/location/locationActions.d.ts +0 -101
- package/dist/redux/location/locationActions.js +0 -218
- package/dist/redux/location/locationActions.js.map +0 -1
- package/dist/redux/location/locationReducer.d.ts +0 -2
- package/dist/redux/location/locationReducer.js +0 -54
- package/dist/redux/location/locationReducer.js.map +0 -1
- package/dist/redux/location/locationSelector.d.ts +0 -53
- package/dist/redux/location/locationSelector.js +0 -32
- package/dist/redux/location/locationSelector.js.map +0 -1
- package/dist/redux/location/locationState.d.ts +0 -15
- package/dist/redux/location/locationState.js +0 -2
- package/dist/redux/location/locationState.js.map +0 -1
- package/dist/redux/quote/quoteMiddleware.d.ts +0 -2
- package/dist/redux/quote/quoteMiddleware.js +0 -31
- package/dist/redux/quote/quoteMiddleware.js.map +0 -1
- package/dist/redux/quoteAccessorial/quoteAccessorialActions.d.ts +0 -70
- package/dist/redux/quoteAccessorial/quoteAccessorialActions.js +0 -149
- package/dist/redux/quoteAccessorial/quoteAccessorialActions.js.map +0 -1
- package/dist/redux/quoteAccessorial/quoteAccessorialReducer.d.ts +0 -2
- package/dist/redux/quoteAccessorial/quoteAccessorialReducer.js +0 -29
- package/dist/redux/quoteAccessorial/quoteAccessorialReducer.js.map +0 -1
- package/dist/redux/quoteAccessorial/quoteAccessorialState.d.ts +0 -8
- package/dist/redux/quoteAccessorial/quoteAccessorialState.js +0 -2
- package/dist/redux/quoteAccessorial/quoteAccessorialState.js.map +0 -1
- package/dist/redux/shipcon/shipconActions.d.ts +0 -80
- package/dist/redux/shipcon/shipconActions.js +0 -172
- package/dist/redux/shipcon/shipconActions.js.map +0 -1
- package/dist/redux/shipcon/shipconReducer.d.ts +0 -2
- package/dist/redux/shipcon/shipconReducer.js +0 -35
- package/dist/redux/shipcon/shipconReducer.js.map +0 -1
- package/dist/redux/shipcon/shipconSelector.d.ts +0 -22
- package/dist/redux/shipcon/shipconSelector.js +0 -19
- package/dist/redux/shipcon/shipconSelector.js.map +0 -1
- package/dist/redux/shipcon/shipconState.d.ts +0 -8
- package/dist/redux/shipcon/shipconState.js +0 -2
- package/dist/redux/shipcon/shipconState.js.map +0 -1
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Button, Chip, Grid, Typography } from "@mui/joy";
|
|
4
|
+
import { Box, useTheme, alpha, Paper, TextField, Alert, Divider, Dialog, DialogTitle, DialogContent, DialogContentText, Select, MenuItem, FormControl, InputLabel, DialogActions, } from "@mui/material";
|
|
5
|
+
import { DataGridPro, useGridApiRef, } from "@mui/x-data-grid-pro";
|
|
6
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useState, } from "react";
|
|
7
|
+
import { useTranslation } from "react-i18next";
|
|
8
|
+
import { useSelector } from "react-redux";
|
|
9
|
+
import { useDispatch } from "react-redux";
|
|
10
|
+
import { useParams, useSearchParams } from "react-router-dom";
|
|
11
|
+
import { useQuote } from "../../redux/quote/quoteHooks";
|
|
12
|
+
import { selectDropoffs, selectPickups, selectRemainingPallets, selectTenderBody, selectTenderErrors, selectTenderPaths, } from "../../redux/tender/tenderSelector";
|
|
13
|
+
import { setTenderErrors, updateBody, updateStop, } from "../../redux/tender/tenderSlice";
|
|
14
|
+
import { CustomerAutocomplete } from "../customer/customerAutocomplete";
|
|
15
|
+
import { serviceLevelIcons } from "../quote";
|
|
16
|
+
import { getTenderStopsColumns, ManagePallets } from "./helpers";
|
|
17
|
+
import { useLazyGetCustomerQuery } from "../../redux";
|
|
18
|
+
import { Description } from "@mui/icons-material";
|
|
19
|
+
import { documentDescriptions, tenderBodyStep1, tenderBodyStep2, tenderBodyStep3, } from "./constants";
|
|
20
|
+
import { ValidationError } from "yup";
|
|
21
|
+
import { useConfirmTenderMutation, useDeleteTenderMutation, useGetCommoditiesMutation, useGetFilesQuery, useUploadFileMutation, } from "../../redux/tender/tenderEndpoints";
|
|
22
|
+
import { NerdFileUpload, showNotification, useNerdConfirm, } from "@nerdjs/nerd-ui";
|
|
23
|
+
import { nanoid } from "@reduxjs/toolkit";
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {object} props Props
|
|
27
|
+
* @param {Function} props.newQuote New quote callback
|
|
28
|
+
* @returns {ReactElement} TenderForm
|
|
29
|
+
*/
|
|
30
|
+
export function TenderForm(props) {
|
|
31
|
+
const { id: quoteID } = useParams();
|
|
32
|
+
const { quote } = useQuote(quoteID);
|
|
33
|
+
const [params] = useSearchParams();
|
|
34
|
+
const selectedPlan = params.get("selected");
|
|
35
|
+
const selectedServiceLevel = quote?.serviceLevels.find((sl) => sl.id === selectedPlan);
|
|
36
|
+
const dispatch = useDispatch();
|
|
37
|
+
const [step, setStep] = useState(0);
|
|
38
|
+
const body = useSelector(selectTenderBody);
|
|
39
|
+
const errors = useSelector(selectTenderErrors);
|
|
40
|
+
const remainingPallets = quote
|
|
41
|
+
? useSelector(selectRemainingPallets(quote))
|
|
42
|
+
: [];
|
|
43
|
+
const [confirmTender, { data: tenderResponse, isLoading, isSuccess, reset }] = useConfirmTenderMutation();
|
|
44
|
+
const [getCommodities, { data: verifiedPalletCommodities }] = useGetCommoditiesMutation();
|
|
45
|
+
const [deleteTender] = useDeleteTenderMutation();
|
|
46
|
+
const confirm = useNerdConfirm();
|
|
47
|
+
const { t } = useTranslation("salesKit");
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
return () => {
|
|
50
|
+
restartTender();
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (quote) {
|
|
55
|
+
const body = {
|
|
56
|
+
customerId: quote.customerId,
|
|
57
|
+
notes: "",
|
|
58
|
+
quoteNumber: selectedPlan || "",
|
|
59
|
+
referenceNumber: "",
|
|
60
|
+
tenderCommodities: [],
|
|
61
|
+
tenderStops: [],
|
|
62
|
+
paths: [],
|
|
63
|
+
};
|
|
64
|
+
quote.stops.forEach((stop) => {
|
|
65
|
+
if (stop.type == "shipper")
|
|
66
|
+
body.tenderStops.push({
|
|
67
|
+
zip: stop.zip,
|
|
68
|
+
city: "",
|
|
69
|
+
confimationNumber: "",
|
|
70
|
+
contactName: "",
|
|
71
|
+
line1: stop.address.line1 || "",
|
|
72
|
+
locationId: stop.address.locationId || NaN,
|
|
73
|
+
name: stop.name,
|
|
74
|
+
notes: "",
|
|
75
|
+
phone: "",
|
|
76
|
+
referenceNumber: "",
|
|
77
|
+
shipConId: stop.id,
|
|
78
|
+
state: stop.state,
|
|
79
|
+
timeFrom: "",
|
|
80
|
+
timeTo: "",
|
|
81
|
+
type: stop.type,
|
|
82
|
+
date: stop.date || "",
|
|
83
|
+
});
|
|
84
|
+
else
|
|
85
|
+
body.tenderStops.push({
|
|
86
|
+
zip: stop.zip,
|
|
87
|
+
city: "",
|
|
88
|
+
confimationNumber: "",
|
|
89
|
+
contactName: "",
|
|
90
|
+
line1: stop.address.line1 || "",
|
|
91
|
+
locationId: stop.address.locationId || NaN,
|
|
92
|
+
name: stop.name,
|
|
93
|
+
notes: "",
|
|
94
|
+
phone: "",
|
|
95
|
+
referenceNumber: "",
|
|
96
|
+
shipConId: stop.id,
|
|
97
|
+
state: stop.state,
|
|
98
|
+
timeFrom: "",
|
|
99
|
+
timeTo: "",
|
|
100
|
+
type: stop.type,
|
|
101
|
+
...(!selectedServiceLevel?.flexible
|
|
102
|
+
? {
|
|
103
|
+
date: selectedServiceLevel?.from || "",
|
|
104
|
+
}
|
|
105
|
+
: {
|
|
106
|
+
dateFrom: selectedServiceLevel.from,
|
|
107
|
+
dateTo: selectedServiceLevel.to,
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const palletDimensions = Array.from(quote.units.palletDimensions);
|
|
112
|
+
const pickups = body.tenderStops.filter((s) => s.type === "shipper");
|
|
113
|
+
const dropoffs = body.tenderStops.filter((s) => s.type === "consignee");
|
|
114
|
+
pickups.forEach((from) => {
|
|
115
|
+
dropoffs.forEach((to) => {
|
|
116
|
+
body.paths.push({
|
|
117
|
+
from,
|
|
118
|
+
to,
|
|
119
|
+
notes: "",
|
|
120
|
+
pieces: "",
|
|
121
|
+
pallets: body.tenderStops.length === 2
|
|
122
|
+
? palletDimensions.map((pallet, i) => ({
|
|
123
|
+
...pallet,
|
|
124
|
+
id: i,
|
|
125
|
+
pieces: "",
|
|
126
|
+
}))
|
|
127
|
+
: palletDimensions.map((pallet, i) => ({
|
|
128
|
+
...pallet,
|
|
129
|
+
count: 0,
|
|
130
|
+
id: i,
|
|
131
|
+
pieces: "",
|
|
132
|
+
})),
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
dispatch(updateBody(body));
|
|
137
|
+
}
|
|
138
|
+
}, [quote]);
|
|
139
|
+
useLayoutEffect(() => {
|
|
140
|
+
setTimeout(() => {
|
|
141
|
+
window.scrollTo({
|
|
142
|
+
left: 0,
|
|
143
|
+
top: document.body.scrollHeight,
|
|
144
|
+
behavior: "smooth",
|
|
145
|
+
});
|
|
146
|
+
}, 60);
|
|
147
|
+
}, [step]);
|
|
148
|
+
const handleNextStep = useCallback(async () => {
|
|
149
|
+
let missingFields = false;
|
|
150
|
+
switch (step) {
|
|
151
|
+
case 0: {
|
|
152
|
+
try {
|
|
153
|
+
await tenderBodyStep1.validate(body, {
|
|
154
|
+
abortEarly: false,
|
|
155
|
+
});
|
|
156
|
+
dispatch(setTenderErrors(undefined));
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
if (error instanceof ValidationError)
|
|
160
|
+
dispatch(setTenderErrors(error.errors));
|
|
161
|
+
else
|
|
162
|
+
throw error;
|
|
163
|
+
missingFields = true;
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case 1: {
|
|
168
|
+
try {
|
|
169
|
+
await tenderBodyStep2.validate(body, {
|
|
170
|
+
abortEarly: false,
|
|
171
|
+
});
|
|
172
|
+
dispatch(setTenderErrors(undefined));
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
if (error instanceof ValidationError)
|
|
176
|
+
dispatch(setTenderErrors(error.errors));
|
|
177
|
+
else
|
|
178
|
+
throw error;
|
|
179
|
+
missingFields = true;
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
case 2: {
|
|
184
|
+
try {
|
|
185
|
+
await tenderBodyStep3.validate(body, {
|
|
186
|
+
abortEarly: false,
|
|
187
|
+
});
|
|
188
|
+
dispatch(setTenderErrors(undefined));
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
if (error instanceof ValidationError)
|
|
192
|
+
dispatch(setTenderErrors(error.errors));
|
|
193
|
+
else
|
|
194
|
+
throw error;
|
|
195
|
+
missingFields = true;
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
case 3: {
|
|
200
|
+
const errors = [];
|
|
201
|
+
try {
|
|
202
|
+
await tenderBodyStep3.validate(body, {
|
|
203
|
+
abortEarly: false,
|
|
204
|
+
});
|
|
205
|
+
dispatch(setTenderErrors(undefined));
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
if (error instanceof ValidationError)
|
|
209
|
+
errors.concat(error.errors);
|
|
210
|
+
else
|
|
211
|
+
throw error;
|
|
212
|
+
missingFields = true;
|
|
213
|
+
}
|
|
214
|
+
let remainingPalletCount = 0;
|
|
215
|
+
remainingPallets.forEach((p) => (remainingPalletCount += p.count));
|
|
216
|
+
if (remainingPalletCount > 0) {
|
|
217
|
+
errors.push("All pallets should be dispatched");
|
|
218
|
+
missingFields = true;
|
|
219
|
+
}
|
|
220
|
+
dispatch(setTenderErrors(errors));
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
default:
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
if (step == 3 && !errors?.length) {
|
|
227
|
+
const commoditiesCheckerBody = {
|
|
228
|
+
commoditySet: [],
|
|
229
|
+
total: {
|
|
230
|
+
feet: quote?.feet,
|
|
231
|
+
weight: Number(quote?.units.totalDimensions.totalWeight),
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
body.paths?.forEach((path) => {
|
|
235
|
+
commoditiesCheckerBody.commoditySet.push(path.pallets.filter((p) => p.count > 0));
|
|
236
|
+
});
|
|
237
|
+
getCommodities(commoditiesCheckerBody);
|
|
238
|
+
}
|
|
239
|
+
if (step < 3 && !missingFields) {
|
|
240
|
+
setStep(step + 1);
|
|
241
|
+
}
|
|
242
|
+
}, [step, body]);
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
if (verifiedPalletCommodities) {
|
|
245
|
+
const tenderCommodities = [];
|
|
246
|
+
body.paths?.forEach((path, i) => {
|
|
247
|
+
const verifiedPallet = verifiedPalletCommodities[i];
|
|
248
|
+
tenderCommodities.push({
|
|
249
|
+
shipperID: path.from.shipConId,
|
|
250
|
+
consigneeID: path.to.shipConId,
|
|
251
|
+
pallets: verifiedPallet.pallets,
|
|
252
|
+
feet: verifiedPallet.feet,
|
|
253
|
+
weight: verifiedPallet.weight && verifiedPallet.weight > 0
|
|
254
|
+
? verifiedPallet.weight
|
|
255
|
+
: undefined,
|
|
256
|
+
pieces: path.pieces,
|
|
257
|
+
notes: path.notes,
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
confirmTender({ ...body, tenderCommodities });
|
|
261
|
+
}
|
|
262
|
+
}, [verifiedPalletCommodities]);
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
if (isSuccess) {
|
|
265
|
+
setStep(step + 1);
|
|
266
|
+
}
|
|
267
|
+
}, [isSuccess]);
|
|
268
|
+
/**
|
|
269
|
+
*
|
|
270
|
+
*/
|
|
271
|
+
function restartTender() {
|
|
272
|
+
reset();
|
|
273
|
+
dispatch(updateBody({}));
|
|
274
|
+
dispatch(setTenderErrors(undefined));
|
|
275
|
+
}
|
|
276
|
+
return (_jsxs(Box, { sx: { flex: 1 }, children: [_jsx(Toolbar, {}), errors && errors.length > 0 ? (_jsx(Box, { sx: {
|
|
277
|
+
display: "flex",
|
|
278
|
+
justifyContent: "center",
|
|
279
|
+
marginTop: 1,
|
|
280
|
+
}, children: _jsx(Alert, { severity: "error", sx: { maxWidth: 900, width: "100%" }, children: _jsx("ul", { style: { margin: 0 }, children: [...errors].reverse().map((e, i) => (_jsx("li", { children: e }, i))) }) }) })) : null, _jsx(Box, { sx: {
|
|
281
|
+
display: "flex",
|
|
282
|
+
justifyContent: "center",
|
|
283
|
+
marginTop: 1,
|
|
284
|
+
p: 1,
|
|
285
|
+
}, children: _jsx(AboutTheLoad, {}) }), _jsx(Box, { sx: {
|
|
286
|
+
display: "flex",
|
|
287
|
+
justifyContent: "center",
|
|
288
|
+
marginTop: 1,
|
|
289
|
+
overflow: "hidden",
|
|
290
|
+
maxHeight: step > 0 ? "100%" : "0px",
|
|
291
|
+
visibility: step > 0 ? "visible" : "hidden",
|
|
292
|
+
p: step > 0 ? 1 : 0,
|
|
293
|
+
transition: "max-height 0.5s linear",
|
|
294
|
+
}, children: _jsx(PickUp, { step: step }) }), _jsx(Box, { sx: {
|
|
295
|
+
display: "flex",
|
|
296
|
+
justifyContent: "center",
|
|
297
|
+
marginTop: 1,
|
|
298
|
+
overflow: "hidden",
|
|
299
|
+
maxHeight: step > 1 ? "100%" : "0px",
|
|
300
|
+
visibility: step > 1 ? "visible" : "hidden",
|
|
301
|
+
p: step > 1 ? 1 : 0,
|
|
302
|
+
transition: "max-height 0.5s linear",
|
|
303
|
+
}, children: _jsx(Dropoff, { step: step }) }), _jsx(Box, { sx: {
|
|
304
|
+
display: "flex",
|
|
305
|
+
justifyContent: "center",
|
|
306
|
+
marginTop: 1,
|
|
307
|
+
overflow: "hidden",
|
|
308
|
+
maxHeight: step > 2 ? "100%" : "0px",
|
|
309
|
+
visibility: step > 2 ? "visible" : "hidden",
|
|
310
|
+
p: step > 2 ? 1 : 0,
|
|
311
|
+
transition: "max-height 0.5s linear",
|
|
312
|
+
}, children: _jsx(Commodities, { step: step }) }), _jsx(Box, { sx: {
|
|
313
|
+
display: "flex",
|
|
314
|
+
justifyContent: "center",
|
|
315
|
+
lineHeight: 0.6,
|
|
316
|
+
mt: 2,
|
|
317
|
+
}, children: _jsxs(Box, { sx: {
|
|
318
|
+
maxWidth: 650,
|
|
319
|
+
textAlign: "center",
|
|
320
|
+
}, children: [_jsx(Typography, { display: "inline", children: _jsx(Box, { className: "fa-duotone fa-circle-info pright", component: "i", sx: {
|
|
321
|
+
color: (theme) => theme.palette.warning.main,
|
|
322
|
+
} }) }), _jsx(Typography, { level: "body2", display: "inline", sx: { opacity: 0.5 }, children: t("inacurateTenderWarning") })] }) }), tenderResponse ? (_jsxs(_Fragment, { children: [_jsx(Box, { sx: {
|
|
323
|
+
display: "flex",
|
|
324
|
+
justifyContent: "center",
|
|
325
|
+
marginTop: 2,
|
|
326
|
+
marginBottom: 2,
|
|
327
|
+
}, children: _jsx(Result, { ...tenderResponse }) }), _jsxs(Box, { sx: {
|
|
328
|
+
display: "flex",
|
|
329
|
+
justifyContent: "center",
|
|
330
|
+
marginTop: 2,
|
|
331
|
+
marginBottom: 2,
|
|
332
|
+
}, children: [_jsx(Button, { variant: "plain", color: "danger", onClick: () => confirm.setOpen({
|
|
333
|
+
content: "Your load will be canceled. You won't be able to recover it.",
|
|
334
|
+
onConfirm() {
|
|
335
|
+
deleteTender(tenderResponse.id)
|
|
336
|
+
.unwrap()
|
|
337
|
+
.then(() => {
|
|
338
|
+
dispatch(showNotification({
|
|
339
|
+
notification: {
|
|
340
|
+
uuid: nanoid(),
|
|
341
|
+
title: `Load #${tenderResponse.loadId} (${tenderResponse.referenceNumber}) has been canceled.`,
|
|
342
|
+
severity: "success",
|
|
343
|
+
variant: "non-intrusive",
|
|
344
|
+
autohide: true,
|
|
345
|
+
autoHideDuration: 2000,
|
|
346
|
+
},
|
|
347
|
+
}));
|
|
348
|
+
});
|
|
349
|
+
props.newQuote();
|
|
350
|
+
},
|
|
351
|
+
}), children: t("Cancel Load") }), _jsx(Button, { variant: "soft", sx: {
|
|
352
|
+
ml: 1,
|
|
353
|
+
}, onClick: () => {
|
|
354
|
+
props.newQuote();
|
|
355
|
+
}, children: t("New Quote") })] })] })) : (_jsx(Box, { sx: {
|
|
356
|
+
display: "flex",
|
|
357
|
+
justifyContent: "center",
|
|
358
|
+
marginTop: 2,
|
|
359
|
+
marginBottom: 2,
|
|
360
|
+
}, children: _jsx(Button, { variant: "soft", onClick: handleNextStep, loading: isLoading, children: step > 2 ? t("Tender") : t("Next") }) }))] }));
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
*
|
|
364
|
+
* @param {object} props props
|
|
365
|
+
* @param {number} props.step step
|
|
366
|
+
* @returns {ReactElement} PickUp
|
|
367
|
+
*/
|
|
368
|
+
function PickUp(props) {
|
|
369
|
+
const { t } = useTranslation("salesKit");
|
|
370
|
+
const dispatch = useDispatch();
|
|
371
|
+
const apiRef = useGridApiRef();
|
|
372
|
+
const { id: quoteID } = useParams();
|
|
373
|
+
const [params] = useSearchParams();
|
|
374
|
+
const selectedPlan = params.get("selected");
|
|
375
|
+
const { quote } = useQuote(quoteID);
|
|
376
|
+
const errors = useSelector(selectTenderErrors);
|
|
377
|
+
const selectedServiceLevel = quote?.serviceLevels.find((sl) => sl.id === selectedPlan);
|
|
378
|
+
const rows = useSelector(selectPickups);
|
|
379
|
+
const columns = getTenderStopsColumns(errors, selectedServiceLevel);
|
|
380
|
+
useEffect(() => {
|
|
381
|
+
if (props.step == 1 && rows)
|
|
382
|
+
setTimeout(() => {
|
|
383
|
+
apiRef.current.setCellFocus(rows[0].shipConId, "zip");
|
|
384
|
+
}, 80);
|
|
385
|
+
}, [props.step]);
|
|
386
|
+
return (_jsx(Paper, { sx: { maxWidth: { xs: undefined, md: 900 }, p: 2, width: "100%" }, children: _jsxs(Grid, { container: true, spacing: 2, children: [_jsx(Grid, { xs: 12, children: _jsxs(Typography, { level: "h6", children: [_jsx("i", { className: "fa-sharp fa-solid fa-arrow-up pright" }), " ", t("Pick-ups")] }) }), _jsx(Grid, { xs: 12, children: _jsx(DataGridPro, { processRowUpdate: (newRow) => {
|
|
387
|
+
dispatch(updateStop({ id: newRow.shipConId, stop: newRow }));
|
|
388
|
+
return newRow;
|
|
389
|
+
}, onProcessRowUpdateError: (error) => {
|
|
390
|
+
throw error;
|
|
391
|
+
}, getRowId: (row) => row.shipConId, disableSelectionOnClick: true, density: "compact", apiRef: apiRef, onCellClick: (e) => {
|
|
392
|
+
if (apiRef.current?.getCellMode(e.id, e.field) == "view" &&
|
|
393
|
+
apiRef.current?.getCellParams(e.id, e.field).isEditable)
|
|
394
|
+
apiRef.current?.startCellEditMode({ id: e.id, field: e.field });
|
|
395
|
+
}, autoHeight: true, hideFooter: true, componentsProps: {
|
|
396
|
+
cell: { tabIndex: 0 },
|
|
397
|
+
}, experimentalFeatures: { newEditingApi: true }, rows: rows || [], columns: columns }) }), _jsx(Grid, { xs: 12, mt: 2, children: rows?.filter((row) => row.notes != "").length ? (_jsx(Alert, { severity: "warning", icon: _jsx(Description, {}), children: rows?.map((row) => {
|
|
398
|
+
const notes = row.notes;
|
|
399
|
+
if (notes != "") {
|
|
400
|
+
return (_jsxs(Box, { sx: { mb: 1 }, children: [_jsx(Typography, { display: "inline", level: "body2", children: `${row.zip}: ` }), _jsx(Typography, { display: "inline", level: "body3", children: notes })] }, row.shipConId));
|
|
401
|
+
}
|
|
402
|
+
else
|
|
403
|
+
return null;
|
|
404
|
+
}) })) : null })] }) }));
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
*
|
|
408
|
+
* @param {object} props props
|
|
409
|
+
* @param {number} props.step step
|
|
410
|
+
* @returns {ReactElement} Dropoff
|
|
411
|
+
*/
|
|
412
|
+
function Dropoff(props) {
|
|
413
|
+
const { t } = useTranslation("salesKit");
|
|
414
|
+
const dispatch = useDispatch();
|
|
415
|
+
const apiRef = useGridApiRef();
|
|
416
|
+
const { id: quoteID } = useParams();
|
|
417
|
+
const [params] = useSearchParams();
|
|
418
|
+
const selectedPlan = params.get("selected");
|
|
419
|
+
const { quote } = useQuote(quoteID);
|
|
420
|
+
const selectedServiceLevel = quote?.serviceLevels.find((sl) => sl.id === selectedPlan);
|
|
421
|
+
const errors = useSelector(selectTenderErrors);
|
|
422
|
+
const columns = getTenderStopsColumns(errors, selectedServiceLevel);
|
|
423
|
+
const rows = useSelector(selectDropoffs);
|
|
424
|
+
useEffect(() => {
|
|
425
|
+
if (props.step == 2 && rows)
|
|
426
|
+
setTimeout(() => {
|
|
427
|
+
apiRef.current.setCellFocus(rows[0].shipConId, "zip");
|
|
428
|
+
}, 80);
|
|
429
|
+
}, [props.step]);
|
|
430
|
+
return (_jsx(Paper, { sx: { maxWidth: { xs: undefined, md: 900 }, p: 2, width: "100%" }, children: _jsxs(Grid, { container: true, spacing: 2, children: [_jsx(Grid, { xs: 12, children: _jsxs(Typography, { level: "h6", children: [_jsx("i", { className: "fa-sharp fa-solid fa-arrow-down pright" }), " ", t("Drop-offs")] }) }), _jsx(Grid, { xs: 12, children: _jsx(DataGridPro, { processRowUpdate: (newRow) => {
|
|
431
|
+
dispatch(updateStop({ id: newRow.shipConId, stop: newRow }));
|
|
432
|
+
return newRow;
|
|
433
|
+
}, onProcessRowUpdateError: (error) => {
|
|
434
|
+
throw error;
|
|
435
|
+
}, getRowId: (row) => row.shipConId, disableSelectionOnClick: true, density: "compact", apiRef: apiRef, onCellClick: (e) => {
|
|
436
|
+
if (apiRef.current?.getCellMode(e.id, e.field) == "view" &&
|
|
437
|
+
apiRef.current?.getCellParams(e.id, e.field).isEditable)
|
|
438
|
+
apiRef.current?.startCellEditMode({ id: e.id, field: e.field });
|
|
439
|
+
}, autoHeight: true, hideFooter: true, componentsProps: {
|
|
440
|
+
cell: { tabIndex: 0 },
|
|
441
|
+
}, experimentalFeatures: { newEditingApi: true }, rows: rows || [], columns: columns }) }), _jsx(Grid, { xs: 12, mt: 2, children: rows?.filter((row) => row.notes != "").length ? (_jsx(Alert, { severity: "warning", icon: _jsx(Description, {}), children: _jsx(Grid, { container: true, spacing: 1, children: rows?.map((row) => {
|
|
442
|
+
const notes = row.notes;
|
|
443
|
+
if (notes != "") {
|
|
444
|
+
return (_jsxs(Grid, { xs: 12, children: [_jsx(Typography, { display: "inline", level: "body2", children: `${row.zip}: ` }), _jsx(Typography, { display: "inline", level: "body3", children: notes })] }, row.shipConId));
|
|
445
|
+
}
|
|
446
|
+
else
|
|
447
|
+
return null;
|
|
448
|
+
}) }) })) : null })] }) }));
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
*
|
|
452
|
+
* @returns {ReactElement} AboutTheLoad
|
|
453
|
+
*/
|
|
454
|
+
function AboutTheLoad() {
|
|
455
|
+
const { t } = useTranslation("salesKit");
|
|
456
|
+
const dispatch = useDispatch();
|
|
457
|
+
const body = useSelector(selectTenderBody);
|
|
458
|
+
const [getCustomer, { data: _customer, isFetching }] = useLazyGetCustomerQuery();
|
|
459
|
+
const [customer, setCustomer] = useState(_customer || null);
|
|
460
|
+
const errors = useSelector(selectTenderErrors);
|
|
461
|
+
useEffect(() => {
|
|
462
|
+
if (body.customerId) {
|
|
463
|
+
if (body.customerId != customer?.id)
|
|
464
|
+
getCustomer(body.customerId, true)
|
|
465
|
+
.unwrap()
|
|
466
|
+
.then((result) => setCustomer(result));
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
setCustomer(null);
|
|
470
|
+
}
|
|
471
|
+
}, [body.customerId]);
|
|
472
|
+
return (_jsx(Paper, { sx: { maxWidth: { xs: undefined, md: 900 }, p: 2, width: "100%" }, children: _jsxs(Grid, { container: true, spacing: 1, children: [_jsx(Grid, { xs: 12, children: _jsxs(Typography, { level: "h6", children: [_jsx("i", { className: "fa-duotone fa-truck-ramp-box pright" }), " ", t("aboutTheLoad")] }) }), _jsx(Grid, { xs: 8, children: _jsx(CustomerAutocomplete, { value: customer, isLoading: isFetching, onChange: (v) => {
|
|
473
|
+
setCustomer(v);
|
|
474
|
+
dispatch(updateBody({
|
|
475
|
+
...body,
|
|
476
|
+
customerId: v?.id,
|
|
477
|
+
}));
|
|
478
|
+
}, textfieldProps: {
|
|
479
|
+
variant: "outlined",
|
|
480
|
+
size: "small",
|
|
481
|
+
required: true,
|
|
482
|
+
error: errors && !customer,
|
|
483
|
+
} }) }), _jsx(Grid, { xs: 4, children: _jsx(TextField, { fullWidth: true, required: true, size: "small", label: t("Prop Number"), value: body.referenceNumber || "", onChange: (e) => dispatch(updateBody({ ...body, referenceNumber: e.target.value })), error: errors && !body.referenceNumber }) }), _jsx(Grid, { xs: 12, mt: 2, children: _jsx(TextField, { fullWidth: true, multiline: true, InputLabelProps: { shrink: true }, variant: "filled", label: t("Notes"), placeholder: t("Enter Somes Relevant Notes"), value: body.notes || "", onChange: (e) => dispatch(updateBody({ ...body, notes: e.target.value })), color: "warning" }) })] }) }));
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Tender toolbar.
|
|
487
|
+
*
|
|
488
|
+
* @returns {ReactElement} Quote toolbar
|
|
489
|
+
*/
|
|
490
|
+
function Toolbar() {
|
|
491
|
+
const [offsetTop, setOffsetTop] = useState(0);
|
|
492
|
+
const theme = useTheme();
|
|
493
|
+
const { id: quoteID } = useParams();
|
|
494
|
+
const [params] = useSearchParams();
|
|
495
|
+
const selectedPlan = params.get("selected");
|
|
496
|
+
const { quote } = useQuote(quoteID);
|
|
497
|
+
const selectedServiceLevel = quote?.serviceLevels.find((sl) => sl.id === selectedPlan);
|
|
498
|
+
const { t } = useTranslation("salesKit");
|
|
499
|
+
useLayoutEffect(() => {
|
|
500
|
+
const updatePosition = () => {
|
|
501
|
+
setOffsetTop(window.pageYOffset);
|
|
502
|
+
};
|
|
503
|
+
window.addEventListener("scroll", updatePosition);
|
|
504
|
+
updatePosition();
|
|
505
|
+
return () => window.removeEventListener("scroll", updatePosition);
|
|
506
|
+
}, []);
|
|
507
|
+
const shrink = offsetTop > 0;
|
|
508
|
+
return (_jsx(Box, { sx: {
|
|
509
|
+
display: "flex",
|
|
510
|
+
alignItems: "center",
|
|
511
|
+
justifyContent: "center",
|
|
512
|
+
position: "sticky",
|
|
513
|
+
backdropFilter: shrink ? "blur(10px)" : "none",
|
|
514
|
+
borderBottom: shrink ? "solid 1px rgba(155,155,155,0.3)" : "none",
|
|
515
|
+
background: shrink
|
|
516
|
+
? alpha(theme.palette.background.paper, 0.6)
|
|
517
|
+
: "none",
|
|
518
|
+
zIndex: 1000,
|
|
519
|
+
top: 48,
|
|
520
|
+
p: { xs: 1, md: 2 },
|
|
521
|
+
pt: shrink ? 1 : 2,
|
|
522
|
+
pb: shrink ? 1 : 2,
|
|
523
|
+
}, children: _jsxs(Grid, { container: true, sx: {
|
|
524
|
+
width: { xs: "100%", md: 900 },
|
|
525
|
+
}, children: [_jsxs(Grid, { children: [_jsx(Typography, { level: "h5", children: t("Tender Load") }), _jsx(Typography, { level: "body2", children: t("From Quote", { id: quote?.id }) })] }), selectedServiceLevel && (_jsx(Grid, { ml: "auto", children: _jsxs(Grid, { container: true, spacing: 1, children: [_jsx(Grid, { children: _jsx("img", { src: serviceLevelIcons[selectedServiceLevel?.serviceLevel], alt: t("Service Level"), height: 40 }) }), _jsxs(Grid, { children: [_jsx(Typography, { level: "h5", children: selectedServiceLevel.serviceLevel.charAt(0).toUpperCase() +
|
|
526
|
+
selectedServiceLevel.serviceLevel.substring(1) }), _jsx(Typography, { level: "body2", children: selectedServiceLevel.description })] })] }) }))] }) }));
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
*
|
|
530
|
+
* @param {object} props props
|
|
531
|
+
* @param {number} props.step step
|
|
532
|
+
* @returns {ReactElement} Commodities
|
|
533
|
+
*/
|
|
534
|
+
function Commodities(props) {
|
|
535
|
+
const { t } = useTranslation("salesKit");
|
|
536
|
+
const apiRef = useGridApiRef();
|
|
537
|
+
const { id: quoteID } = useParams();
|
|
538
|
+
const { quote } = useQuote(quoteID);
|
|
539
|
+
const rows = useSelector(selectTenderPaths);
|
|
540
|
+
const remainingPallets = quote
|
|
541
|
+
? useSelector(selectRemainingPallets(quote))
|
|
542
|
+
: [];
|
|
543
|
+
const remainingPalletsCount = useMemo(() => {
|
|
544
|
+
let remainingPalletCount = 0;
|
|
545
|
+
remainingPallets.forEach((p) => (remainingPalletCount += p.count));
|
|
546
|
+
return remainingPalletCount;
|
|
547
|
+
}, [remainingPallets]);
|
|
548
|
+
const columns = [
|
|
549
|
+
{
|
|
550
|
+
field: "from",
|
|
551
|
+
headerName: "From",
|
|
552
|
+
flex: 1,
|
|
553
|
+
minWidth: 180,
|
|
554
|
+
renderCell(params) {
|
|
555
|
+
return (_jsxs(Box, { p: 1, children: [_jsx(Typography, { level: "body2", children: params.value?.name }), params.value?.name != params.value?.zip ? (_jsx(Typography, { level: "body3", children: `${params.value?.zip} ${params.value?.city}` })) : null] }));
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
field: "to",
|
|
560
|
+
headerName: "To",
|
|
561
|
+
flex: 1,
|
|
562
|
+
minWidth: 180,
|
|
563
|
+
renderCell(params) {
|
|
564
|
+
return (_jsxs(Box, { p: 1, children: [_jsx(Typography, { level: "body2", children: params.value?.name }), params.value?.name != params.value?.zip ? (_jsx(Typography, { level: "body3", children: `${params.value?.zip} ${params.value?.city}` })) : null] }));
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
field: "pallets",
|
|
569
|
+
headerName: "Pallets",
|
|
570
|
+
flex: 2,
|
|
571
|
+
minWidth: 180,
|
|
572
|
+
renderCell(params) {
|
|
573
|
+
return (_jsx(Box, { sx: {
|
|
574
|
+
overflow: "scroll",
|
|
575
|
+
}, children: _jsx(Grid, { container: true, spacing: 1, children: params.value?.map((pallet, i) => {
|
|
576
|
+
const unitsSymbol = pallet.units == "inches" ? '"' : "'";
|
|
577
|
+
if (pallet.count > 0)
|
|
578
|
+
return (_jsx(Grid, { children: _jsx(Chip, { size: "sm", variant: "soft", startDecorator: _jsx(Box, { sx: {
|
|
579
|
+
borderRadius: 15,
|
|
580
|
+
width: 18,
|
|
581
|
+
height: 18,
|
|
582
|
+
backgroundColor: (theme) => theme.palette.primary.main,
|
|
583
|
+
color: "white",
|
|
584
|
+
display: "flex",
|
|
585
|
+
alignItems: "center",
|
|
586
|
+
justifyContent: "center",
|
|
587
|
+
margin: "var(--Chip-deleteMargin)",
|
|
588
|
+
}, children: pallet.count }), children: `${pallet.length}${unitsSymbol}x${pallet.width}${unitsSymbol}x${pallet.height}${unitsSymbol}` }) }, i));
|
|
589
|
+
else
|
|
590
|
+
return null;
|
|
591
|
+
}) }) }));
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
field: "actions",
|
|
596
|
+
type: "actions",
|
|
597
|
+
align: "center",
|
|
598
|
+
maxWidth: 50,
|
|
599
|
+
getActions: (params) => [
|
|
600
|
+
_createElement(ManagePallets, { ...params, key: "manage pallets", remainingPallets: remainingPallets }),
|
|
601
|
+
],
|
|
602
|
+
},
|
|
603
|
+
];
|
|
604
|
+
useEffect(() => {
|
|
605
|
+
if (props.step && rows) {
|
|
606
|
+
setTimeout(() => {
|
|
607
|
+
const row = rows[0];
|
|
608
|
+
apiRef.current.setCellFocus(`${row.from.shipConId} ${row.to.shipConId}`, "from");
|
|
609
|
+
}, 80);
|
|
610
|
+
}
|
|
611
|
+
}, [props.step]);
|
|
612
|
+
return (_jsx(Paper, { sx: { maxWidth: { xs: undefined, md: 900 }, p: 2, width: "100%" }, children: _jsxs(Grid, { container: true, spacing: 2, children: [_jsx(Grid, { xs: 12, children: _jsxs(Typography, { level: "h6", children: [_jsx("i", { className: "fa-sharp fa-solid fa-pallet-boxes pright" }), " ", t("Commodities")] }) }), _jsx(Grid, { xs: 12, children: _jsx(DataGridPro, { getRowId: (row) => `${row.from.shipConId} ${row.to.shipConId}`, disableSelectionOnClick: true, apiRef: apiRef, autoHeight: true, getRowHeight: () => "auto", hideFooter: true, componentsProps: {
|
|
613
|
+
cell: { tabIndex: 0 },
|
|
614
|
+
}, rows: rows || [], columns: columns }) }), remainingPalletsCount > 0 ? (_jsx(Grid, { xs: 12, children: _jsxs(Alert, { severity: "warning", children: [_jsx(Typography, { level: "body2", color: "warning", children: t("You need to dispatch these remaning pallets in a lane:") }), _jsx(Grid, { container: true, spacing: 1, children: remainingPallets.map((pallet, i) => {
|
|
615
|
+
const unitsSymbol = pallet.units == "inches" ? '"' : "'";
|
|
616
|
+
if (pallet.count > 0)
|
|
617
|
+
return (_jsx(Grid, { children: _jsx(Chip, { size: "sm", variant: "soft", startDecorator: _jsx(Box, { sx: {
|
|
618
|
+
borderRadius: 15,
|
|
619
|
+
width: 18,
|
|
620
|
+
height: 18,
|
|
621
|
+
backgroundColor: (theme) => theme.palette.primary.main,
|
|
622
|
+
color: "white",
|
|
623
|
+
display: "flex",
|
|
624
|
+
alignItems: "center",
|
|
625
|
+
justifyContent: "center",
|
|
626
|
+
margin: "var(--Chip-deleteMargin)",
|
|
627
|
+
}, children: pallet.count }), children: `${pallet.length}${unitsSymbol}x${pallet.width}${unitsSymbol}x${pallet.height}${unitsSymbol}` }) }, i));
|
|
628
|
+
else
|
|
629
|
+
return null;
|
|
630
|
+
}) })] }) })) : null] }) }));
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
*
|
|
634
|
+
* @param {TenderResponse_Entity} response response
|
|
635
|
+
* @returns {ReactElement} Result
|
|
636
|
+
*/
|
|
637
|
+
function Result(response) {
|
|
638
|
+
const { t } = useTranslation("salesKit");
|
|
639
|
+
const { id: quoteID } = useParams();
|
|
640
|
+
const { quote } = useQuote(quoteID);
|
|
641
|
+
const [params] = useSearchParams();
|
|
642
|
+
const selectedPlan = params.get("selected");
|
|
643
|
+
const selectedServiceLevel = quote?.serviceLevels.find((sl) => sl.id === selectedPlan);
|
|
644
|
+
const [files, setFiles] = useState([]);
|
|
645
|
+
const [types, setTypes] = useState({});
|
|
646
|
+
const [uploadFile] = useUploadFileMutation();
|
|
647
|
+
const { data: uploadedFiles } = useGetFilesQuery(response.loadId);
|
|
648
|
+
/**
|
|
649
|
+
*
|
|
650
|
+
*/
|
|
651
|
+
function handleClose() {
|
|
652
|
+
setFiles([]);
|
|
653
|
+
setTypes({});
|
|
654
|
+
}
|
|
655
|
+
const handleUpload = useCallback(() => {
|
|
656
|
+
files.forEach((file) => {
|
|
657
|
+
const description = types[file.name];
|
|
658
|
+
uploadFile({ id: response.loadId, description, file });
|
|
659
|
+
});
|
|
660
|
+
setFiles([]);
|
|
661
|
+
setTypes({});
|
|
662
|
+
}, [files, types]);
|
|
663
|
+
return (_jsxs(Box, { sx: { maxWidth: { xs: undefined, md: 900 }, p: 2, width: "100%" }, children: [_jsxs(Grid, { container: true, spacing: 2, children: [_jsxs(Grid, { xs: 12, children: [_jsx(Typography, { level: "h4", children: t("You are all set !") }), _jsx(Typography, { level: "body2", children: `Load #${response.loadId} (${response.referenceNumber}) has been created.` })] }), _jsx(Grid, { xs: 6, children: _jsxs(Paper, { sx: { p: 1 }, children: [_jsxs(Typography, { level: "h6", children: [_jsx("i", { className: "fa-sharp fa-solid fa-dollar-sign" }), "\u00A0\u00A0", t("Initial Quote")] }), _jsxs(Grid, { container: true, children: [_jsx(Grid, { xs: 6, children: _jsx(Typography, { children: t("Base Rate") }) }), _jsx(Grid, { xs: 6, textAlign: "right", children: _jsxs(Typography, { children: ["$", selectedServiceLevel?.baseRate] }) }), _jsx(Grid, { xs: 6, children: _jsx(Typography, { children: t("Fuel Rate") }) }), _jsx(Grid, { xs: 6, textAlign: "right", children: _jsxs(Typography, { children: ["$", selectedServiceLevel?.fuelRate] }) }), _jsx(Grid, { xs: 12, children: _jsx(Divider, {}) }), _jsx(Grid, { xs: 6, children: _jsx(Typography, { children: t("Total Rate") }) }), _jsx(Grid, { xs: 6, textAlign: "right", children: _jsxs(Typography, { children: ["$", selectedServiceLevel?.totalRate] }) })] })] }) }), _jsx(Grid, { xs: 6, children: _jsxs(Paper, { sx: { p: 1 }, children: [_jsxs(Typography, { level: "h6", children: [_jsx("i", { className: "fa-sharp fa-solid fa-receipt" }), "\u00A0\u00A0", t("Tender")] }), _jsxs(Grid, { container: true, children: [_jsx(Grid, { xs: 6, children: _jsx(Typography, { children: t("Base Rate") }) }), _jsx(Grid, { xs: 6, textAlign: "right", children: _jsxs(Typography, { children: ["$", response.baseRate] }) }), _jsx(Grid, { xs: 6, children: _jsx(Typography, { children: t("Fuel Rate") }) }), _jsx(Grid, { xs: 6, textAlign: "right", children: _jsxs(Typography, { children: ["$", response.fuelRate] }) }), _jsx(Grid, { xs: 12, children: _jsx(Divider, {}) }), _jsx(Grid, { xs: 6, children: _jsx(Typography, { children: t("Total Rate") }) }), _jsx(Grid, { xs: 6, textAlign: "right", children: _jsxs(Typography, { children: ["$", response.totalRate] }) })] })] }) }), uploadedFiles && uploadedFiles.length > 0 ? (_jsx(Grid, { xs: 12, children: _jsx(Paper, { sx: { p: 1 }, children: _jsxs(Grid, { container: true, children: [_jsxs(Typography, { level: "h6", children: [_jsx("i", { className: "fa-solid fa-paperclip-vertical" }), "\u00A0\u00A0", t("Uploaded Files")] }), _jsx(Grid, { xs: 12, children: _jsxs(Grid, { container: true, children: [_jsx(Grid, { xs: 6, children: _jsx(Typography, { children: t("Name") }) }), _jsx(Grid, { xs: 6, textAlign: "right", children: _jsx(Typography, { children: t("Description") }) })] }) }), uploadedFiles?.map((file) => (_jsx(Grid, { xs: 12, children: _jsxs(Grid, { container: true, children: [_jsx(Grid, { xs: 6, children: _jsx(Typography, { level: "body2", children: file.name }) }), _jsx(Grid, { xs: 6, textAlign: "right", children: _jsx(Typography, { level: "body2", children: file.description }) }), _jsx(Grid, { xs: 12, children: _jsx(Divider, {}) })] }) }, file.id)))] }) }) })) : null, _jsx(Grid, { ml: "auto", mr: "auto", children: _jsxs(Grid, { container: true, justifyContent: "center", alignItems: "center", p: 5, textAlign: "center", children: [_jsxs(Grid, { xs: 12, children: [_jsx(Typography, { level: "h5", children: t("Having files to send ?") }), _jsx(Typography, { level: "body2", children: t("Drag and drop them on the page.") })] }), _jsx(Grid, { children: _jsx(NerdFileUpload, { uploadFile: (files) => setFiles(files), multiple: true, hideFilesList: true }) })] }) })] }), _jsxs(Dialog, { open: files.length > 0, onClose: handleClose, children: [_jsx(DialogTitle, { children: t("uploading_file", {
|
|
664
|
+
count: files.length,
|
|
665
|
+
}) }), _jsxs(DialogContent, { children: [_jsx(DialogContentText, { mb: 1, children: t("For each file, please specify the document type:") }), files.map((file, i) => (_jsxs(Paper, { sx: { p: 2, mb: 1 }, variant: "outlined", children: [_jsx(Typography, { children: file.name }), _jsxs(FormControl, { variant: "standard", fullWidth: true, sx: {
|
|
666
|
+
mt: 2,
|
|
667
|
+
}, children: [_jsx(InputLabel, { id: "select-label", children: t("Document Type") }), _jsx(Select, { value: types[file.name] || "", onChange: (e) => setTypes({ ...types, [file.name]: e.target.value }), labelId: "select-label", label: t("Document Type"), placeholder: t("Choose one..."), children: documentDescriptions.map((d, i) => (_jsx(MenuItem, { value: d, children: d }, i))) })] })] }, i)))] }), _jsxs(DialogActions, { children: [_jsx(Button, { onClick: handleClose, color: "neutral", variant: "plain", children: t("Cancel") }), _jsx(Button, { variant: "soft", disabled: Object.entries(types).length != files.length ? true : false, onClick: handleUpload, children: t("Upload") })] })] })] }));
|
|
668
|
+
}
|
|
669
|
+
//# sourceMappingURL=form.js.map
|