@nerdjs/sales-kit 1.0.9 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/dist/entities/archerFile/archerFile.d.ts +11 -0
  2. package/dist/entities/archerFile/archerFile.js +48 -0
  3. package/dist/entities/archerFile/archerFile.js.map +1 -0
  4. package/dist/entities/archerFile/helper.d.ts +5 -0
  5. package/dist/entities/archerFile/helper.js +16 -0
  6. package/dist/entities/archerFile/helper.js.map +1 -0
  7. package/dist/entities/archerFile/index.d.ts +2 -0
  8. package/dist/entities/archerFile/index.js +3 -0
  9. package/dist/entities/archerFile/index.js.map +1 -0
  10. package/dist/entities/customer/index.d.ts +2 -1
  11. package/dist/entities/customer/index.js +2 -1
  12. package/dist/entities/customer/index.js.map +1 -1
  13. package/dist/entities/holiday/helper.d.ts +2 -0
  14. package/dist/entities/holiday/helper.js +4 -0
  15. package/dist/entities/holiday/helper.js.map +1 -1
  16. package/dist/entities/index.d.ts +3 -0
  17. package/dist/entities/index.js +3 -0
  18. package/dist/entities/index.js.map +1 -1
  19. package/dist/entities/location/helper.d.ts +3 -0
  20. package/dist/entities/location/helper.js +9 -0
  21. package/dist/entities/location/helper.js.map +1 -1
  22. package/dist/entities/location/index.d.ts +2 -2
  23. package/dist/entities/location/index.js +2 -2
  24. package/dist/entities/location/index.js.map +1 -1
  25. package/dist/entities/location/location.d.ts +5 -0
  26. package/dist/entities/location/location.js +7 -0
  27. package/dist/entities/location/location.js.map +1 -1
  28. package/dist/entities/path/helper.d.ts +5 -0
  29. package/dist/entities/path/helper.js +16 -0
  30. package/dist/entities/path/helper.js.map +1 -0
  31. package/dist/entities/path/index.d.ts +2 -0
  32. package/dist/entities/path/index.js +3 -0
  33. package/dist/entities/path/index.js.map +1 -0
  34. package/dist/entities/path/path.d.ts +20 -0
  35. package/dist/entities/path/path.js +35 -0
  36. package/dist/entities/path/path.js.map +1 -0
  37. package/dist/entities/quoteResponse/quoteResponse.d.ts +1 -0
  38. package/dist/entities/quoteResponse/quoteResponse.js +2 -0
  39. package/dist/entities/quoteResponse/quoteResponse.js.map +1 -1
  40. package/dist/entities/tenderCommodity/helper.d.ts +5 -0
  41. package/dist/entities/tenderCommodity/helper.js +16 -0
  42. package/dist/entities/tenderCommodity/helper.js.map +1 -0
  43. package/dist/entities/tenderCommodity/index.d.ts +2 -0
  44. package/dist/entities/tenderCommodity/index.js +3 -0
  45. package/dist/entities/tenderCommodity/index.js.map +1 -0
  46. package/dist/entities/tenderCommodity/tenderCommodity.d.ts +11 -0
  47. package/dist/entities/tenderCommodity/tenderCommodity.js +39 -0
  48. package/dist/entities/tenderCommodity/tenderCommodity.js.map +1 -0
  49. package/dist/entities/tenderRequest/helper.d.ts +5 -0
  50. package/dist/entities/tenderRequest/helper.js +16 -0
  51. package/dist/entities/tenderRequest/helper.js.map +1 -0
  52. package/dist/entities/tenderRequest/index.d.ts +2 -0
  53. package/dist/entities/tenderRequest/index.js +3 -0
  54. package/dist/entities/tenderRequest/index.js.map +1 -0
  55. package/dist/entities/tenderRequest/tenderRequest.d.ts +14 -0
  56. package/dist/entities/tenderRequest/tenderRequest.js +39 -0
  57. package/dist/entities/tenderRequest/tenderRequest.js.map +1 -0
  58. package/dist/entities/tenderResponse/helper.d.ts +5 -0
  59. package/dist/entities/tenderResponse/helper.js +16 -0
  60. package/dist/entities/tenderResponse/helper.js.map +1 -0
  61. package/dist/entities/tenderResponse/index.d.ts +2 -0
  62. package/dist/entities/tenderResponse/index.js +3 -0
  63. package/dist/entities/tenderResponse/index.js.map +1 -0
  64. package/dist/entities/tenderResponse/tenderResponse.d.ts +41 -0
  65. package/dist/entities/tenderResponse/tenderResponse.js +49 -0
  66. package/dist/entities/tenderResponse/tenderResponse.js.map +1 -0
  67. package/dist/entities/tenderStop/helper.d.ts +5 -0
  68. package/dist/entities/tenderStop/helper.js +16 -0
  69. package/dist/entities/tenderStop/helper.js.map +1 -0
  70. package/dist/entities/tenderStop/index.d.ts +2 -0
  71. package/dist/entities/tenderStop/index.js +3 -0
  72. package/dist/entities/tenderStop/index.js.map +1 -0
  73. package/dist/entities/tenderStop/tenderStop.d.ts +22 -0
  74. package/dist/entities/tenderStop/tenderStop.js +59 -0
  75. package/dist/entities/tenderStop/tenderStop.js.map +1 -0
  76. package/dist/hooks/customer/customerAutocomplete.d.ts +18 -0
  77. package/dist/hooks/customer/customerAutocomplete.js +36 -0
  78. package/dist/hooks/customer/customerAutocomplete.js.map +1 -0
  79. package/dist/hooks/index.d.ts +1 -0
  80. package/dist/hooks/index.js +1 -0
  81. package/dist/hooks/index.js.map +1 -1
  82. package/dist/hooks/locationsForm/locationsForm.d.ts +11 -2
  83. package/dist/hooks/locationsForm/locationsForm.js +117 -13
  84. package/dist/hooks/locationsForm/locationsForm.js.map +1 -1
  85. package/dist/hooks/quote/form.d.ts +2 -0
  86. package/dist/hooks/quote/form.js +59 -32
  87. package/dist/hooks/quote/form.js.map +1 -1
  88. package/dist/hooks/quote/helpers.d.ts +13 -8
  89. package/dist/hooks/quote/helpers.js +232 -92
  90. package/dist/hooks/quote/helpers.js.map +1 -1
  91. package/dist/hooks/quote/result.d.ts +8 -1
  92. package/dist/hooks/quote/result.js +269 -52
  93. package/dist/hooks/quote/result.js.map +1 -1
  94. package/dist/hooks/quote/template.d.ts +8 -1
  95. package/dist/hooks/quote/template.js +49 -41
  96. package/dist/hooks/quote/template.js.map +1 -1
  97. package/dist/hooks/tender/constants.d.ts +200 -0
  98. package/dist/hooks/tender/constants.js +77 -0
  99. package/dist/hooks/tender/constants.js.map +1 -0
  100. package/dist/hooks/tender/form.d.ts +10 -0
  101. package/dist/hooks/tender/form.js +669 -0
  102. package/dist/hooks/tender/form.js.map +1 -0
  103. package/dist/hooks/tender/helpers.d.ts +51 -0
  104. package/dist/hooks/tender/helpers.js +465 -0
  105. package/dist/hooks/tender/helpers.js.map +1 -0
  106. package/dist/hooks/tender/index.d.ts +1 -0
  107. package/dist/hooks/tender/index.js +2 -0
  108. package/dist/hooks/tender/index.js.map +1 -0
  109. package/dist/hooks/tender/template.d.ts +10 -0
  110. package/dist/hooks/tender/template.js +25 -0
  111. package/dist/hooks/tender/template.js.map +1 -0
  112. package/dist/locales/salesKitEn.d.ts +66 -0
  113. package/dist/locales/salesKitEn.js +66 -0
  114. package/dist/locales/salesKitEn.js.map +1 -1
  115. package/dist/redux/api/index.d.ts +1 -0
  116. package/dist/redux/api/index.js +2 -0
  117. package/dist/redux/api/index.js.map +1 -0
  118. package/dist/redux/api/salesApi.d.ts +1 -0
  119. package/dist/redux/api/salesApi.js +22 -0
  120. package/dist/redux/api/salesApi.js.map +1 -0
  121. package/dist/redux/customer/customerEndpoints.d.ts +28 -0
  122. package/dist/redux/customer/customerEndpoints.js +76 -0
  123. package/dist/redux/customer/customerEndpoints.js.map +1 -0
  124. package/dist/redux/customer/index.d.ts +1 -4
  125. package/dist/redux/customer/index.js +1 -4
  126. package/dist/redux/customer/index.js.map +1 -1
  127. package/dist/redux/holiday/holidayEndpoints.d.ts +26 -0
  128. package/dist/redux/holiday/holidayEndpoints.js +63 -0
  129. package/dist/redux/holiday/holidayEndpoints.js.map +1 -0
  130. package/dist/redux/holiday/index.d.ts +2 -0
  131. package/dist/redux/holiday/index.js +3 -0
  132. package/dist/redux/holiday/index.js.map +1 -0
  133. package/dist/redux/index.d.ts +2 -0
  134. package/dist/redux/index.js +2 -0
  135. package/dist/redux/index.js.map +1 -1
  136. package/dist/redux/load/index.d.ts +1 -4
  137. package/dist/redux/load/index.js +1 -4
  138. package/dist/redux/load/index.js.map +1 -1
  139. package/dist/redux/load/loadEndpoints.d.ts +26 -0
  140. package/dist/redux/load/loadEndpoints.js +63 -0
  141. package/dist/redux/load/loadEndpoints.js.map +1 -0
  142. package/dist/redux/loadAdjustment/index.d.ts +1 -4
  143. package/dist/redux/loadAdjustment/index.js +1 -4
  144. package/dist/redux/loadAdjustment/index.js.map +1 -1
  145. package/dist/redux/loadAdjustment/loadAdjustmentEndpoints.d.ts +26 -0
  146. package/dist/redux/loadAdjustment/loadAdjustmentEndpoints.js +63 -0
  147. package/dist/redux/loadAdjustment/loadAdjustmentEndpoints.js.map +1 -0
  148. package/dist/redux/location/index.d.ts +1 -4
  149. package/dist/redux/location/index.js +1 -4
  150. package/dist/redux/location/index.js.map +1 -1
  151. package/dist/redux/location/locationEndpoints.d.ts +37 -0
  152. package/dist/redux/location/locationEndpoints.js +107 -0
  153. package/dist/redux/location/locationEndpoints.js.map +1 -0
  154. package/dist/redux/quote/index.d.ts +0 -1
  155. package/dist/redux/quote/index.js +0 -1
  156. package/dist/redux/quote/index.js.map +1 -1
  157. package/dist/redux/quote/quoteAction.d.ts +12 -78
  158. package/dist/redux/quote/quoteAction.js +221 -165
  159. package/dist/redux/quote/quoteAction.js.map +1 -1
  160. package/dist/redux/quote/quoteEndpoints.d.ts +114 -0
  161. package/dist/redux/quote/quoteEndpoints.js +80 -0
  162. package/dist/redux/quote/quoteEndpoints.js.map +1 -0
  163. package/dist/redux/quote/quoteHooks.d.ts +171 -0
  164. package/dist/redux/quote/quoteHooks.js +51 -0
  165. package/dist/redux/quote/quoteHooks.js.map +1 -0
  166. package/dist/redux/quote/quoteReducer.d.ts +5 -1
  167. package/dist/redux/quote/quoteReducer.js +8 -39
  168. package/dist/redux/quote/quoteReducer.js.map +1 -1
  169. package/dist/redux/quote/quoteSelector.d.ts +8 -89
  170. package/dist/redux/quote/quoteSelector.js +27 -41
  171. package/dist/redux/quote/quoteSelector.js.map +1 -1
  172. package/dist/redux/quoteAccessorial/index.d.ts +1 -3
  173. package/dist/redux/quoteAccessorial/index.js +1 -3
  174. package/dist/redux/quoteAccessorial/index.js.map +1 -1
  175. package/dist/redux/quoteAccessorial/quoteAccessorialEndpoints.d.ts +18 -0
  176. package/dist/redux/quoteAccessorial/quoteAccessorialEndpoints.js +52 -0
  177. package/dist/redux/quoteAccessorial/quoteAccessorialEndpoints.js.map +1 -0
  178. package/dist/redux/salesKitReducer.d.ts +3 -18
  179. package/dist/redux/salesKitReducer.js +2 -12
  180. package/dist/redux/salesKitReducer.js.map +1 -1
  181. package/dist/redux/shipcon/index.d.ts +1 -4
  182. package/dist/redux/shipcon/index.js +1 -4
  183. package/dist/redux/shipcon/index.js.map +1 -1
  184. package/dist/redux/shipcon/shipconEndpoints.d.ts +26 -0
  185. package/dist/redux/shipcon/shipconEndpoints.js +63 -0
  186. package/dist/redux/shipcon/shipconEndpoints.js.map +1 -0
  187. package/dist/redux/tender/index.d.ts +0 -0
  188. package/dist/redux/tender/index.js +2 -0
  189. package/dist/redux/tender/index.js.map +1 -0
  190. package/dist/redux/tender/tenderEndpoints.d.ts +34 -0
  191. package/dist/redux/tender/tenderEndpoints.js +52 -0
  192. package/dist/redux/tender/tenderEndpoints.js.map +1 -0
  193. package/dist/redux/tender/tenderSelector.d.ts +53 -0
  194. package/dist/redux/tender/tenderSelector.js +34 -0
  195. package/dist/redux/tender/tenderSelector.js.map +1 -0
  196. package/dist/redux/tender/tenderSlice.d.ts +40 -0
  197. package/dist/redux/tender/tenderSlice.js +69 -0
  198. package/dist/redux/tender/tenderSlice.js.map +1 -0
  199. package/dist/redux/types.d.ts +15 -0
  200. package/dist/redux/types.js +10 -0
  201. package/dist/redux/types.js.map +1 -0
  202. package/package.json +4 -3
  203. package/dist/redux/customer/customerActions.d.ts +0 -97
  204. package/dist/redux/customer/customerActions.js +0 -210
  205. package/dist/redux/customer/customerActions.js.map +0 -1
  206. package/dist/redux/customer/customerReducer.d.ts +0 -2
  207. package/dist/redux/customer/customerReducer.js +0 -42
  208. package/dist/redux/customer/customerReducer.js.map +0 -1
  209. package/dist/redux/customer/customerSelector.d.ts +0 -27
  210. package/dist/redux/customer/customerSelector.js +0 -38
  211. package/dist/redux/customer/customerSelector.js.map +0 -1
  212. package/dist/redux/customer/customerState.d.ts +0 -11
  213. package/dist/redux/customer/customerState.js +0 -2
  214. package/dist/redux/customer/customerState.js.map +0 -1
  215. package/dist/redux/load/loadActions.d.ts +0 -80
  216. package/dist/redux/load/loadActions.js +0 -172
  217. package/dist/redux/load/loadActions.js.map +0 -1
  218. package/dist/redux/load/loadReducer.d.ts +0 -2
  219. package/dist/redux/load/loadReducer.js +0 -35
  220. package/dist/redux/load/loadReducer.js.map +0 -1
  221. package/dist/redux/load/loadSelector.d.ts +0 -27
  222. package/dist/redux/load/loadSelector.js +0 -19
  223. package/dist/redux/load/loadSelector.js.map +0 -1
  224. package/dist/redux/load/loadState.d.ts +0 -8
  225. package/dist/redux/load/loadState.js +0 -2
  226. package/dist/redux/load/loadState.js.map +0 -1
  227. package/dist/redux/loadAdjustment/loadAdjustmentActions.d.ts +0 -80
  228. package/dist/redux/loadAdjustment/loadAdjustmentActions.js +0 -172
  229. package/dist/redux/loadAdjustment/loadAdjustmentActions.js.map +0 -1
  230. package/dist/redux/loadAdjustment/loadAdjustmentReducer.d.ts +0 -2
  231. package/dist/redux/loadAdjustment/loadAdjustmentReducer.js +0 -35
  232. package/dist/redux/loadAdjustment/loadAdjustmentReducer.js.map +0 -1
  233. package/dist/redux/loadAdjustment/loadAdjustmentSelector.d.ts +0 -15
  234. package/dist/redux/loadAdjustment/loadAdjustmentSelector.js +0 -12
  235. package/dist/redux/loadAdjustment/loadAdjustmentSelector.js.map +0 -1
  236. package/dist/redux/loadAdjustment/loadAdjustmentState.d.ts +0 -8
  237. package/dist/redux/loadAdjustment/loadAdjustmentState.js +0 -2
  238. package/dist/redux/loadAdjustment/loadAdjustmentState.js.map +0 -1
  239. package/dist/redux/location/locationActions.d.ts +0 -101
  240. package/dist/redux/location/locationActions.js +0 -218
  241. package/dist/redux/location/locationActions.js.map +0 -1
  242. package/dist/redux/location/locationReducer.d.ts +0 -2
  243. package/dist/redux/location/locationReducer.js +0 -54
  244. package/dist/redux/location/locationReducer.js.map +0 -1
  245. package/dist/redux/location/locationSelector.d.ts +0 -53
  246. package/dist/redux/location/locationSelector.js +0 -32
  247. package/dist/redux/location/locationSelector.js.map +0 -1
  248. package/dist/redux/location/locationState.d.ts +0 -15
  249. package/dist/redux/location/locationState.js +0 -2
  250. package/dist/redux/location/locationState.js.map +0 -1
  251. package/dist/redux/quote/quoteMiddleware.d.ts +0 -2
  252. package/dist/redux/quote/quoteMiddleware.js +0 -31
  253. package/dist/redux/quote/quoteMiddleware.js.map +0 -1
  254. package/dist/redux/quoteAccessorial/quoteAccessorialActions.d.ts +0 -70
  255. package/dist/redux/quoteAccessorial/quoteAccessorialActions.js +0 -149
  256. package/dist/redux/quoteAccessorial/quoteAccessorialActions.js.map +0 -1
  257. package/dist/redux/quoteAccessorial/quoteAccessorialReducer.d.ts +0 -2
  258. package/dist/redux/quoteAccessorial/quoteAccessorialReducer.js +0 -29
  259. package/dist/redux/quoteAccessorial/quoteAccessorialReducer.js.map +0 -1
  260. package/dist/redux/quoteAccessorial/quoteAccessorialState.d.ts +0 -8
  261. package/dist/redux/quoteAccessorial/quoteAccessorialState.js +0 -2
  262. package/dist/redux/quoteAccessorial/quoteAccessorialState.js.map +0 -1
  263. package/dist/redux/shipcon/shipconActions.d.ts +0 -80
  264. package/dist/redux/shipcon/shipconActions.js +0 -172
  265. package/dist/redux/shipcon/shipconActions.js.map +0 -1
  266. package/dist/redux/shipcon/shipconReducer.d.ts +0 -2
  267. package/dist/redux/shipcon/shipconReducer.js +0 -35
  268. package/dist/redux/shipcon/shipconReducer.js.map +0 -1
  269. package/dist/redux/shipcon/shipconSelector.d.ts +0 -22
  270. package/dist/redux/shipcon/shipconSelector.js +0 -19
  271. package/dist/redux/shipcon/shipconSelector.js.map +0 -1
  272. package/dist/redux/shipcon/shipconState.d.ts +0 -8
  273. package/dist/redux/shipcon/shipconState.js +0 -2
  274. 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