@nerdjs/sales-kit 4.0.11 → 4.0.13

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 (36) hide show
  1. package/dist/entities/customerContract/customerContract.d.ts +6 -1
  2. package/dist/entities/customerContract/customerContract.js +21 -4
  3. package/dist/entities/customerContract/customerContract.js.map +1 -1
  4. package/dist/hooks/archerFilesDataGrid/archerFilesDataGrid.d.ts +9 -0
  5. package/dist/hooks/archerFilesDataGrid/archerFilesDataGrid.js +257 -0
  6. package/dist/hooks/archerFilesDataGrid/archerFilesDataGrid.js.map +1 -0
  7. package/dist/hooks/archerFilesDataGrid/index.d.ts +1 -0
  8. package/dist/hooks/archerFilesDataGrid/index.js +2 -0
  9. package/dist/hooks/archerFilesDataGrid/index.js.map +1 -0
  10. package/dist/hooks/carrier/carrierDocuments.js +12 -209
  11. package/dist/hooks/carrier/carrierDocuments.js.map +1 -1
  12. package/dist/hooks/carrier/consts.d.ts +1 -1
  13. package/dist/hooks/carrier/consts.js +1 -1
  14. package/dist/hooks/carrier/consts.js.map +1 -1
  15. package/dist/hooks/carrierInvoicePanel/carrierInvoiceDocuments.js +14 -210
  16. package/dist/hooks/carrierInvoicePanel/carrierInvoiceDocuments.js.map +1 -1
  17. package/dist/hooks/carrierInvoicePanel/consts.d.ts +1 -1
  18. package/dist/hooks/carrierInvoicePanel/consts.js +1 -1
  19. package/dist/hooks/carrierInvoicePanel/consts.js.map +1 -1
  20. package/dist/hooks/carrierTenderPanel/carrierTenderDocuments.js +18 -240
  21. package/dist/hooks/carrierTenderPanel/carrierTenderDocuments.js.map +1 -1
  22. package/dist/hooks/carrierTenderPanel/carrierTenderLoadDocuments.js +8 -154
  23. package/dist/hooks/carrierTenderPanel/carrierTenderLoadDocuments.js.map +1 -1
  24. package/dist/hooks/carrierTenderPanel/consts.d.ts +1 -1
  25. package/dist/hooks/carrierTenderPanel/consts.js +1 -1
  26. package/dist/hooks/carrierTenderPanel/consts.js.map +1 -1
  27. package/dist/hooks/lep/constants.d.ts +1 -1
  28. package/dist/hooks/lep/constants.js +1 -1
  29. package/dist/hooks/lep/constants.js.map +1 -1
  30. package/dist/hooks/lep/lepDocuments.js +14 -237
  31. package/dist/hooks/lep/lepDocuments.js.map +1 -1
  32. package/dist/hooks/lep/lepLoadInfo.js +5 -8
  33. package/dist/hooks/lep/lepLoadInfo.js.map +1 -1
  34. package/dist/hooks/lep/lepLoadLocation.js +2 -2
  35. package/dist/hooks/lep/lepLoadLocation.js.map +1 -1
  36. package/package.json +1 -1
@@ -5,7 +5,12 @@ export default class CustomerContract_Entity {
5
5
  contractID: number;
6
6
  customerID: number;
7
7
  customerName: string;
8
+ startDate: string;
9
+ maxWeight: number;
10
+ contractualRates: boolean;
11
+ warp: boolean;
12
+ warw: boolean;
13
+ waij: boolean;
8
14
  createdAt: string;
9
15
  updatedAt: string;
10
- startDate?: string;
11
16
  }
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * CustomerContract_Entity type guard.
3
+ *
3
4
  * @param {any} customerContractJson CustomerContract object from API
4
5
  * @returns {boolean} Return true if type is CustomerContract_Entity
5
6
  */
@@ -8,7 +9,7 @@ function validator(customerContractJson) {
8
9
  customerContractJson != null) {
9
10
  CustomerContract_Entity.requiredFields.forEach((element) => {
10
11
  if (!Object.keys(customerContractJson).includes(element))
11
- throw new Error(`Field ${element} is null or undefined`);
12
+ throw new Error("Field ${element} is null or undefined");
12
13
  });
13
14
  }
14
15
  return true;
@@ -19,6 +20,12 @@ export default class CustomerContract_Entity {
19
20
  "contractID",
20
21
  "customerID",
21
22
  "customerName",
23
+ "startDate",
24
+ "maxWeight",
25
+ "contractualRates",
26
+ "warp",
27
+ "warw",
28
+ "waij",
22
29
  "createdAt",
23
30
  "updatedAt",
24
31
  ];
@@ -28,20 +35,30 @@ export default class CustomerContract_Entity {
28
35
  this.contractID = customerContractJson.contractID;
29
36
  this.customerID = customerContractJson.customerID;
30
37
  this.customerName = customerContractJson.customerName;
38
+ this.startDate = customerContractJson.startDate;
39
+ this.maxWeight = customerContractJson.maxWeight;
40
+ this.contractualRates = customerContractJson.contractualRates;
41
+ this.warp = customerContractJson.warp;
42
+ this.warw = customerContractJson.warw;
43
+ this.waij = customerContractJson.waij;
31
44
  this.createdAt = customerContractJson.createdAt;
32
45
  this.updatedAt = customerContractJson.updatedAt;
33
- this.startDate = customerContractJson.startDate;
34
46
  }
35
47
  else {
36
- throw new Error(`Failed to create new instance of ${CustomerContract_Entity.name}`);
48
+ throw new Error("Failed to create new instance of ${ CustomerContract_Entity.name }: ${e}");
37
49
  }
38
50
  }
39
51
  id;
40
52
  contractID;
41
53
  customerID;
42
54
  customerName;
55
+ startDate;
56
+ maxWeight;
57
+ contractualRates;
58
+ warp;
59
+ warw;
60
+ waij;
43
61
  createdAt;
44
62
  updatedAt;
45
- startDate;
46
63
  }
47
64
  //# sourceMappingURL=customerContract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customerContract.js","sourceRoot":"","sources":["../../../src/entities/customerContract/customerContract.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,SAAS,SAAS,CAChB,oBAA6B;IAE7B,IACE,OAAO,oBAAoB,KAAK,QAAQ;QACxC,oBAAoB,IAAI,IAAI,EAC5B,CAAC;QACD,uBAAuB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACzD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;gBACtD,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,uBAAuB,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC1C,MAAM,CAAC,cAAc,GAAG;QACtB,IAAI;QACJ,YAAY;QACZ,YAAY;QACZ,cAAc;QACd,WAAW;QACX,WAAW;KACZ,CAAC;IAEF,YAAY,oBAA6B;QACvC,IAAI,SAAS,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC,EAAE,GAAG,oBAAoB,CAAC,EAAE,CAAC;YAClC,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,UAAU,CAAC;YAClD,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,UAAU,CAAC;YAClD,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAC,YAAY,CAAC;YACtD,IAAI,CAAC,SAAS,GAAG,oBAAoB,CAAC,SAAS,CAAC;YAChD,IAAI,CAAC,SAAS,GAAG,oBAAoB,CAAC,SAAS,CAAC;YAChD,IAAI,CAAC,SAAS,GAAG,oBAAoB,CAAC,SAAS,CAAC;QAClD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CACb,oCAAoC,uBAAuB,CAAC,IAAI,EAAE,CACnE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,EAAE,CAAS;IACX,UAAU,CAAS;IACnB,UAAU,CAAS;IACnB,YAAY,CAAS;IACrB,SAAS,CAAS;IAClB,SAAS,CAAS;IAClB,SAAS,CAAU"}
1
+ {"version":3,"file":"customerContract.js","sourceRoot":"","sources":["../../../src/entities/customerContract/customerContract.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,SAAS,SAAS,CAChB,oBAA6B;IAE7B,IACE,OAAO,oBAAoB,KAAK,QAAQ;QACxC,oBAAoB,IAAI,IAAI,EAC5B,CAAC;QACD,uBAAuB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACzD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;gBACtD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,OAAO,OAAO,uBA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S;IAClB,SAAS,CAAS"}
@@ -0,0 +1,9 @@
1
+ import { ArcherFile_Entity } from "../../entities";
2
+ export declare const ArcherFilesDataGrid: ({ localStorageKey, files, onAddFileDialogClose, openAddFileDialog, fileTypes, onUploadFile, }: {
3
+ localStorageKey: string;
4
+ files: ArcherFile_Entity[];
5
+ openAddFileDialog?: boolean;
6
+ onAddFileDialogClose?: () => void;
7
+ fileTypes: string[];
8
+ onUploadFile?: (file: File, fileType: string | null) => Promise<object> | undefined;
9
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,257 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { GridActionsCellItem, useGridApiRef, } from "@mui/x-data-grid-premium";
3
+ import { useEffect, useMemo, useState } from "react";
4
+ import { getPeopleSelectors, useDeleteArcherFileMutation, useGetPeopleQuery, useShareArcherFileMutation, useUpdateArcherFileMutation, } from "../../redux";
5
+ import { Button, FormControl, FormLabel, Grid, Modal, ModalDialog, Select, Typography, Option, IconButton, Sheet, FormHelperText, Tooltip, DialogActions, DialogTitle, DialogContent, useTheme, } from "@mui/joy";
6
+ import { DateTime } from "luxon";
7
+ import { NerdClickToCopy, NerdFileUpload, showNotification, useNerdConfirm, useNerdSaveDataGridState, useNerdWindow, } from "@nerdjs/nerd-ui";
8
+ import salesKitI18n from "../../i18n";
9
+ import { useTranslation } from "react-i18next";
10
+ import { useDispatch, useSelector } from "react-redux";
11
+ import { Person } from "../../entities";
12
+ import { LepStyledDataGrid } from "../lep/lepStyledDataGrid";
13
+ import { CustomColumnMenu } from "../lep";
14
+ const KEYS_MAP = {
15
+ name: "file_name",
16
+ };
17
+ const INITIAL_STATE = {
18
+ sorting: { sortModel: [{ field: "description", sort: "asc" }] },
19
+ };
20
+ export const ArcherFilesDataGrid = ({ localStorageKey, files, onAddFileDialogClose, openAddFileDialog, fileTypes, onUploadFile, }) => {
21
+ const apiRef = useGridApiRef();
22
+ const params2 = useMemo(() => ({
23
+ filters: JSON.stringify([
24
+ { name: "people.company_id", comparison: "eq", value: 1 },
25
+ { name: "people.active", comparison: "eq", value: true },
26
+ ]),
27
+ }), []);
28
+ const { data: _personNames } = useGetPeopleQuery(params2);
29
+ const selectAllPersonNames = useMemo(() => getPeopleSelectors(params2).selectAll, [params2]);
30
+ const personNames = useSelector(selectAllPersonNames);
31
+ const [deleteFile] = useDeleteArcherFileMutation();
32
+ const confirm = useNerdConfirm();
33
+ const [filterModel, setFilterModel] = useState({
34
+ items: [],
35
+ });
36
+ const personOptions = useMemo(() => personNames?.map((p) => ({
37
+ label: new Person(p).name() || "",
38
+ value: p.id,
39
+ })), [personNames]);
40
+ const { open: openDocument } = useNerdWindow();
41
+ const [updateArcherFile] = useUpdateArcherFileMutation();
42
+ const [shareFile, setShareFile] = useState(null);
43
+ const theme = useTheme();
44
+ const columns = useMemo(() => [
45
+ {
46
+ field: "name",
47
+ headerName: "File",
48
+ flex: 1,
49
+ editable: true,
50
+ },
51
+ {
52
+ field: "description",
53
+ headerName: "Type",
54
+ flex: 1,
55
+ type: "singleSelect",
56
+ valueOptions: fileTypes,
57
+ editable: true,
58
+ },
59
+ {
60
+ field: "created_at",
61
+ headerName: "Uploaded At",
62
+ renderCell(params) {
63
+ return params.value
64
+ ? DateTime.fromISO(params.value).toUTC().toFormat("LL/dd/yyyy")
65
+ : "";
66
+ },
67
+ flex: 1,
68
+ },
69
+ {
70
+ field: "person_id",
71
+ headerName: "Uploaded By",
72
+ renderCell(params) {
73
+ return _personNames?.entities[params.value]
74
+ ? new Person(_personNames?.entities[params.value]).name()
75
+ : "";
76
+ },
77
+ flex: 1,
78
+ type: "singleSelect",
79
+ valueOptions: personOptions,
80
+ },
81
+ {
82
+ field: "actions",
83
+ type: "actions",
84
+ headerName: "Actions",
85
+ getActions: ({ row, }) => {
86
+ if (Object.keys(row).length > 0) {
87
+ const extension = row.name.split(".").pop();
88
+ const previwDisabled = !extension ||
89
+ !["gif", "jpeg", "jpg", "png", "tiff", "pdf"].includes(extension.trim().toLowerCase());
90
+ return [
91
+ _jsx(GridActionsCellItem, { icon: _jsx(Tooltip, { title: previwDisabled
92
+ ? "File preview is only available for the following file formats: gif, jpeg, jpg, png, tiff, pdf"
93
+ : "Preview", children: _jsx("span", { children: _jsx("i", { style: {
94
+ color: previwDisabled
95
+ ? theme.palette.neutral.plainDisabledColor
96
+ : undefined,
97
+ }, className: "fa-solid fa-eye" }) }) }), label: `View File`, material: {
98
+ disableRipple: previwDisabled,
99
+ }, onClick: () => {
100
+ if (!previwDisabled)
101
+ openDocument({
102
+ url: `${window._APP_CONFIG?.api?.endpoint}/v3/file-service/files/${row.id}?inline=1`,
103
+ name: row.name,
104
+ });
105
+ } }, "view"),
106
+ _jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-download" }), label: `Download File`, onClick: () => {
107
+ const link = document.createElement("a");
108
+ link.href = `${window._APP_CONFIG?.api?.endpoint}/v3/file-service/files/${row.id}`;
109
+ link.click();
110
+ link.remove();
111
+ } }, "download"),
112
+ _jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-trash" }), label: `Delete File`, disabled: row.description == "Rate Confirmation", onClick: () => {
113
+ confirm.setOpen({
114
+ onConfirm() {
115
+ deleteFile(row.id);
116
+ },
117
+ });
118
+ } }, "delete"),
119
+ _jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-share" }), label: `Share File`, onClick: () => {
120
+ setShareFile(row);
121
+ } }, "share"),
122
+ ];
123
+ }
124
+ else
125
+ return [];
126
+ },
127
+ },
128
+ ], [personOptions]);
129
+ const { state, key, restoreState } = useNerdSaveDataGridState(apiRef, localStorageKey, INITIAL_STATE, [columns]);
130
+ useEffect(() => {
131
+ if (files && shareFile) {
132
+ setShareFile(files.find((d) => d.id === shareFile.id) || null);
133
+ }
134
+ else
135
+ setShareFile(null);
136
+ }, [files]);
137
+ const onRowUpdate = (newRow, oldRow) => {
138
+ const body = {};
139
+ Object.keys(newRow).forEach((key) => {
140
+ const k = key;
141
+ if (oldRow[k] !== newRow[k])
142
+ body[KEYS_MAP[k] || k] = newRow[k];
143
+ });
144
+ if (Object.entries(body).length > 0 && newRow.id) {
145
+ return updateArcherFile({
146
+ id: newRow.id,
147
+ body: { archerfile: body },
148
+ })
149
+ .unwrap()
150
+ .then(() => {
151
+ return newRow;
152
+ })
153
+ .catch(() => {
154
+ return oldRow;
155
+ });
156
+ }
157
+ return oldRow;
158
+ };
159
+ return (_jsxs(_Fragment, { children: [_jsx(LepStyledDataGrid, { density: "compact", apiRef: apiRef, slotProps: {
160
+ columnMenu: {
161
+ myCustomHandler: () => {
162
+ restoreState();
163
+ },
164
+ },
165
+ }, slots: {
166
+ columnMenu: CustomColumnMenu,
167
+ }, initialState: state, hideFooter: true, rows: files, columns: columns, filterModel: filterModel, onFilterModelChange: (model) => setFilterModel(model), processRowUpdate: onRowUpdate, editMode: "row", onCellClick: (e) => {
168
+ if (apiRef.current?.isCellEditable(e) &&
169
+ apiRef.current?.getRowMode(e.id) === "view")
170
+ apiRef.current?.startRowEditMode({ id: e.id });
171
+ }, defaultGroupingExpansionDepth: -1 }, key), _jsx(ShareFileDialog, { onClose: () => setShareFile(null), shareFile: shareFile }), openAddFileDialog !== undefined &&
172
+ onAddFileDialogClose &&
173
+ onUploadFile ? (_jsx(AddDocumentDialog, { open: openAddFileDialog, onClose: onAddFileDialogClose, fileTypes: fileTypes, onUploadFile: onUploadFile })) : null] }));
174
+ };
175
+ const ShareFileDialog = ({ onClose, shareFile, }) => {
176
+ const [shareFileAction, { isLoading: shareFileLoading }] = useShareArcherFileMutation();
177
+ return (_jsx(Modal, { open: Boolean(shareFile), onClose: onClose, children: _jsx(ModalDialog, { sx: {
178
+ maxWidth: 400,
179
+ }, children: _jsx(Grid, { container: true, spacing: 1, overflow: "auto", children: shareFile?.token ? (_jsxs(_Fragment, { children: [_jsx(Grid, { xs: 12, children: _jsx(NerdClickToCopy, { typographyProps: {
180
+ sx: {
181
+ lineBreak: "anywhere",
182
+ },
183
+ }, children: `${window._APP_CONFIG?.api?.endpoint}${window._APP_CONFIG?.api?.routePrefix}/shared_files/${shareFile.id}?token=${shareFile.token}` }) }), _jsx(Grid, { xs: 12, children: _jsx(Button, { fullWidth: true, onClick: () => {
184
+ shareFileAction({ id: shareFile.id, share: false });
185
+ }, children: "Unshare" }) })] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, { xs: 12, children: _jsxs(Typography, { children: ["By sharing this file it will be publicly viewable to people outside of the ", window._APP_CONFIG?.client?.name, " ", "organization. Do you wish to continue?"] }) }), _jsx(Grid, { xs: 12, children: _jsx(Button, { loading: shareFileLoading, fullWidth: true, onClick: () => {
186
+ if (shareFile?.id)
187
+ shareFileAction({ id: shareFile.id, share: true });
188
+ }, children: "Share" }) })] })) }) }) }));
189
+ };
190
+ const AddDocumentDialog = ({ open, onClose, fileTypes, onUploadFile, }) => {
191
+ const dispatch = useDispatch();
192
+ const { t } = useTranslation("common", { i18n: salesKitI18n });
193
+ const [file, setFile] = useState(null);
194
+ const [fileType, setFileType] = useState(null);
195
+ const [isLoading, setIsLoading] = useState(false);
196
+ const handleClose = () => {
197
+ onClose();
198
+ setFile(null);
199
+ setFileType(null);
200
+ setIsLoading(false);
201
+ };
202
+ return (_jsx(Modal, { open: open, onClose: handleClose, children: _jsxs(ModalDialog, { layout: "center", sx: (theme) => ({
203
+ width: 500,
204
+ [theme.breakpoints.only("xs")]: {
205
+ top: 0,
206
+ left: 0,
207
+ right: 0,
208
+ bottom: 0,
209
+ border: 0,
210
+ borderRadius: 0,
211
+ transform: "initial",
212
+ maxWidth: "initial",
213
+ maxHeight: "initial",
214
+ width: "initial",
215
+ },
216
+ }), children: [_jsx(DialogTitle, { children: t("entities:archerFile.others.upload_document") }), _jsx(DialogContent, { sx: {
217
+ p: 1,
218
+ }, children: _jsxs(Grid, { container: true, spacing: 2, overflow: "auto", justifyContent: "center", children: [_jsx(Grid, { xs: 12, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: t("entities:archerFile.others.document_type") }), _jsx(Select, { value: fileType, onChange: (_e, v) => setFileType(v), children: fileTypes.map((d) => (_jsx(Option, { value: d, children: d }, d))) })] }) }), _jsx(Grid, { xs: 12, children: _jsxs(FormControl, { children: [_jsx(NerdFileUpload, { uploadFile: (file) => setFile(file), slotProps: {
219
+ root: {
220
+ variant: "soft",
221
+ size: "sm",
222
+ },
223
+ }, accept: [
224
+ "image/gif",
225
+ "image/jpeg",
226
+ "image/jpg",
227
+ "image/png",
228
+ "image/tiff",
229
+ "application/pdf",
230
+ "application/vnd.ms-excel",
231
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
232
+ ], maxSize: 30000000, onError: (error) => dispatch(showNotification({
233
+ severity: "danger",
234
+ title: error.message,
235
+ autohide: true,
236
+ variant: "non-intrusive",
237
+ })) }), _jsxs(FormHelperText, { children: ["Accepted formats: gif, jpeg, jpg, png, tiff, pdf, xls, xlsx", _jsx("br", {}), "Limit: 30 MB"] })] }) }), file ? (_jsx(Grid, { xs: 12, children: _jsx(Sheet, { sx: {
238
+ p: 0.5,
239
+ borderRadius: 5,
240
+ }, children: _jsxs(Grid, { container: true, gap: 2, alignItems: "center", children: [_jsx(Grid, { children: _jsx(Typography, { level: "h2", color: "primary", children: _jsx("i", { className: "fa-regular fa-file" }) }) }), _jsxs(Grid, { children: [_jsx(Typography, { textOverflow: "ellipsis", overflow: "hidden", whiteSpace: "nowrap", level: "body-md", display: "inline", children: file.name }), _jsx(Typography, { ml: 1, level: "body-xs", display: "inline", children: `(${(file.size / 1000000).toFixed(2)} MB)` })] }), _jsx(Grid, { marginLeft: "auto", children: _jsx(IconButton, { variant: "plain", color: "danger", onClick: () => setFile(null), size: "sm", children: _jsx("i", { className: "fa-solid fa-xmark" }) }) })] }) }) })) : null] }) }), _jsxs(DialogActions, { children: [_jsx(Button, { onClick: handleClose, color: "neutral", variant: "soft", children: t("global.Cancel") }), _jsx(Button, { loading: isLoading, onClick: () => {
241
+ if (!file)
242
+ return;
243
+ const _onUploadFile = onUploadFile(file, fileType);
244
+ if (!_onUploadFile)
245
+ return;
246
+ setIsLoading(true);
247
+ _onUploadFile
248
+ .then((result) => {
249
+ if (result !== null && "error" in result)
250
+ return;
251
+ else
252
+ handleClose();
253
+ })
254
+ .catch(() => undefined);
255
+ }, children: t("global.Upload") })] })] }) }));
256
+ };
257
+ //# sourceMappingURL=archerFilesDataGrid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archerFilesDataGrid.js","sourceRoot":"","sources":["../../../src/hooks/archerFilesDataGrid/archerFilesDataGrid.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,mBAAmB,EAEnB,aAAa,GAGd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,MAAM,EACN,WAAW,EACX,SAAS,EACT,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,UAAU,EACV,MAAM,EACN,UAAU,EACV,KAAK,EACL,cAAc,EACd,OAAO,EACP,aAAa,EACb,WAAW,EACX,aAAa,EACb,QAAQ,GACT,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,wBAAwB,EACxB,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAqB,MAAM,EAAE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UAAU,EAAE,MAAM,YACtB,KAAC,UAAU,IACT,OAAO,EAAC,OAAO,EACf,KAAK,EAAC,QAAQ,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAC5B,IAAI,EAAE,IAAI,YAEV,YAAG,SAAS,EAAC,mBAAmB,GAAG,GACxB,GACR,IACF,GACD,GACH,CACR,CAAC,CAAC,CAAC,IAAI,IACH,GACO,EAChB,MAAC,aAAa,eACZ,KAAC,MAAM,IAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAC,SAAS,EAAC,OAAO,EAAC,MAAM,YACzD,CAAC,CAAC,eAAe,CAAC,GACZ,EACT,KAAC,MAAM,IACL,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,GAAG,EAAE;gCACZ,IAAI,CAAC,IAAI;oCAAE,OAAO;gCAClB,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gCACnD,IAAI,CAAC,aAAa;oCAAE,OAAO;gCAC3B,YAAY,CAAC,IAAI,CAAC,CAAC;gCACnB,aAAa;qCACV,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;oCACf,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,IAAI,MAAM;wCAAE,OAAO;;wCAC5C,WAAW,EAAE,CAAC;gCACrB,CAAC,CAAC;qCACD,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;4BAC5B,CAAC,YAEA,CAAC,CAAC,eAAe,CAAC,GACZ,IACK,IACJ,GACR,CACT,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./archerFilesDataGrid";
@@ -0,0 +1,2 @@
1
+ export * from "./archerFilesDataGrid";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/archerFilesDataGrid/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -1,21 +1,11 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { GridActionsCellItem, useGridApiRef, DataGridPremium, } from "@mui/x-data-grid-premium";
3
- import { useCallback, useContext, useEffect, useMemo, useState, } from "react";
4
- import { Box, Button, FormControl, FormLabel, Grid, Modal, ModalDialog, Select, Skeleton, Typography, Option, IconButton, Sheet, FormHelperText, Tooltip, DialogActions, } from "@mui/joy";
5
- import { DateTime } from "luxon";
6
- import { NerdClickToCopy, NerdFileUpload, showNotification, useNerdConfirm, useNerdSaveDataGridState, useNerdWindow, } from "@nerdjs/nerd-ui";
7
- import salesKitI18n from "../../i18n";
8
- import { useTranslation } from "react-i18next";
9
- import { carrierDocumentTypes } from "./consts";
10
- import { useDispatch, useSelector } from "react-redux";
2
+ import { useContext, useMemo, useState } from "react";
3
+ import { Box, Button, Skeleton } from "@mui/joy";
4
+ import { CARRIER_DOCUMENT_TYPES } from "./consts";
11
5
  import { CarrierPanelContext } from "./carrierPanel";
12
- import { getPeopleSelectors, useDeleteArcherFileMutation, useGetCarrierFilesQuery, useGetPeopleQuery, useShareArcherFileMutation, useUploadArcherFileMutation, } from "../../redux";
13
- import { Person } from "../../entities";
14
- import { CustomColumnMenu } from "../lep";
6
+ import { useGetCarrierFilesQuery, useGetPeopleQuery, useUploadArcherFileMutation, } from "../../redux";
7
+ import { ArcherFilesDataGrid } from "../archerFilesDataGrid";
15
8
  const LOCAL_STORAGE_KEY = "CarrierDocumentsDataGridState";
16
- const INITIAL_STATE = {
17
- sorting: { sortModel: [{ field: "description", sort: "asc" }] },
18
- };
19
9
  /**
20
10
  *
21
11
  * @returns {ReactElement} CarrierDocuments
@@ -42,209 +32,22 @@ function Content() {
42
32
  const localStorageKey = useMemo(() => localStoragePrefix
43
33
  ? localStoragePrefix + LOCAL_STORAGE_KEY
44
34
  : LOCAL_STORAGE_KEY, [localStoragePrefix]);
45
- const apiRef = useGridApiRef();
46
35
  const [open, setOpen] = useState(false);
47
36
  const { data } = useGetCarrierFilesQuery(Number(carrierID), {
48
37
  skip: Number.isNaN(Number(carrierID)),
49
38
  });
50
- const params2 = useMemo(() => ({
51
- filters: JSON.stringify([
52
- { name: "people.company_id", comparison: "eq", value: 1 },
53
- { name: "people.active", comparison: "eq", value: true },
54
- ]),
55
- }), []);
56
- const { data: _personNames } = useGetPeopleQuery(params2);
57
- const selectAllPersonNames = useMemo(() => getPeopleSelectors(params2).selectAll, [params2]);
58
- const personNames = useSelector(selectAllPersonNames);
59
- const [shareFileAction, { isLoading: shareFileLoading }] = useShareArcherFileMutation();
60
- const [deleteFile] = useDeleteArcherFileMutation();
61
- const confirm = useNerdConfirm();
62
- const [shareFile, setShareFile] = useState(null);
63
- const [filterModel, setFilterModel] = useState({
64
- items: [],
65
- });
66
- const personOptions = useMemo(() => personNames?.map((p) => ({
67
- label: new Person(p).name() || "",
68
- value: p.id,
69
- })), [personNames]);
70
- const { open: openDocument } = useNerdWindow();
71
- const columns = useMemo(() => [
72
- {
73
- field: "name",
74
- headerName: "File",
75
- flex: 1,
76
- },
77
- {
78
- field: "description",
79
- headerName: "Type",
80
- flex: 1,
81
- type: "singleSelect",
82
- valueOptions: carrierDocumentTypes,
83
- },
84
- {
85
- field: "created_at",
86
- headerName: "Uploaded At",
87
- renderCell(params) {
88
- return params.value
89
- ? DateTime.fromISO(params.value).toUTC().toFormat("LL/dd/yyyy")
90
- : "";
91
- },
92
- flex: 1,
93
- },
94
- {
95
- field: "person_id",
96
- headerName: "Uploaded By",
97
- renderCell(params) {
98
- return _personNames?.entities[params.value]
99
- ? new Person(_personNames?.entities[params.value]).name()
100
- : "";
101
- },
102
- flex: 1,
103
- type: "singleSelect",
104
- valueOptions: personOptions,
105
- },
106
- {
107
- field: "actions",
108
- type: "actions",
109
- headerName: "Actions",
110
- getActions: ({ row, }) => {
111
- if (Object.keys(row).length > 0) {
112
- const extension = row.name.split(".").pop();
113
- const previwDisabled = !extension ||
114
- !["gif", "jpeg", "jpg", "png", "tiff", "pdf"].includes(extension);
115
- return [
116
- _jsx(GridActionsCellItem, { icon: _jsx(Tooltip, { title: previwDisabled
117
- ? "File preview is only available for the following file formats: gif, jpeg, jpg, png, tiff, pdf"
118
- : "Preview", children: _jsx("span", { children: _jsx("i", { style: {
119
- color: previwDisabled
120
- ? "var(--mui-palette-action-disabled)"
121
- : undefined,
122
- }, className: "fa-solid fa-eye" }) }) }), label: `View File`, disabled: previwDisabled, onClick: () => {
123
- if (!previwDisabled)
124
- openDocument({
125
- url: `${window._APP_CONFIG?.api?.endpoint}/v3/file-service/files/${row.id}?inline=1`,
126
- name: row.name,
127
- });
128
- } }, "view"),
129
- _jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-download" }), label: `Download File`, onClick: () => {
130
- const link = document.createElement("a");
131
- link.href = `${window._APP_CONFIG?.api?.endpoint}/v3/file-service/files/${row.id}`;
132
- link.click();
133
- link.remove();
134
- } }, "download"),
135
- _jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-trash" }), label: `Delete File`, disabled: row.description == "Rate Confirmation", onClick: () => {
136
- confirm.setOpen({
137
- onConfirm() {
138
- deleteFile(row.id);
139
- },
140
- });
141
- } }, "delete"),
142
- _jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-share" }), label: `Share File`, onClick: () => {
143
- setShareFile(row);
144
- } }, "share"),
145
- ];
146
- }
147
- else
148
- return [];
149
- },
150
- },
151
- ], [personOptions]);
152
- const { state, key, restoreState } = useNerdSaveDataGridState(apiRef, localStorageKey, INITIAL_STATE, [columns]);
153
- useEffect(() => {
154
- if (data && shareFile) {
155
- setShareFile(data.find((d) => d.id === shareFile.id) || null);
156
- }
157
- else
158
- setShareFile(null);
159
- }, [data]);
160
- const onRowClick = useCallback((params) => {
161
- const rowNode = apiRef.current?.getRowNode(params.id);
162
- if (rowNode && rowNode.type === "group") {
163
- apiRef.current?.setRowChildrenExpansion(params.id, !rowNode.childrenExpanded);
164
- }
165
- }, [apiRef]);
166
- return (_jsxs(Box, { display: "flex", gap: 0.5, width: "100%", height: "100%", children: [_jsx(Box, { height: "calc(100vh - 230px)", sx: { display: "grid", width: "100%" }, children: _jsx(DataGridPremium, { initialState: state, slotProps: {
167
- columnMenu: {
168
- myCustomHandler: () => {
169
- restoreState();
170
- },
171
- },
172
- }, slots: {
173
- columnMenu: CustomColumnMenu,
174
- }, density: "compact", apiRef: apiRef, hideFooter: true, rows: data || [], columns: columns, filterModel: filterModel, onFilterModelChange: (model) => setFilterModel(model), onRowClick: onRowClick, defaultGroupingExpansionDepth: -1 }, key) }), _jsx(Button, { size: "sm", variant: "soft", onClick: () => setOpen(true), disabled: Number.isNaN(Number(carrierID)), children: _jsx("i", { className: "fa-solid fa-plus" }) }), _jsx(Modal, { open: Boolean(shareFile), onClose: () => setShareFile(null), children: _jsx(ModalDialog, { sx: {
175
- maxWidth: 400,
176
- }, children: _jsx(Grid, { container: true, spacing: 1, overflow: "auto", children: shareFile?.token ? (_jsxs(_Fragment, { children: [_jsx(Grid, { xs: 12, children: _jsx(NerdClickToCopy, { typographyProps: {
177
- sx: {
178
- lineBreak: "anywhere",
179
- },
180
- }, children: `${window._APP_CONFIG?.api?.endpoint}${window._APP_CONFIG?.api?.routePrefix}/shared_files/${shareFile.id}?token=${shareFile.token}` }) }), _jsx(Grid, { xs: 12, children: _jsx(Button, { fullWidth: true, onClick: () => {
181
- shareFileAction({ id: shareFile.id, share: false });
182
- }, children: "Unshare" }) })] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, { xs: 12, children: _jsxs(Typography, { children: ["By sharing this file it will be publicly viewable to people outside of the ", window._APP_CONFIG?.client?.name, " ", "organization. Do you wish to continue?"] }) }), _jsx(Grid, { xs: 12, children: _jsx(Button, { loading: shareFileLoading, fullWidth: true, onClick: () => {
183
- if (shareFile?.id)
184
- shareFileAction({ id: shareFile.id, share: true });
185
- }, children: "Share" }) })] })) }) }) }), _jsx(AddDocumentDialog, { open: open, onClose: () => setOpen(false) })] }));
186
- }
187
- const AddDocumentDialog = ({ open, onClose, }) => {
188
- const { carrierID } = useContext(CarrierPanelContext);
189
- const { t } = useTranslation("common", { i18n: salesKitI18n });
190
- const [file, setFile] = useState(null);
191
- const [documentType, setDocumentType] = useState(null);
192
- const [uploadFile, { isLoading }] = useUploadArcherFileMutation();
193
- const dispatch = useDispatch();
194
- const handleClose = () => {
195
- onClose();
196
- setFile(null);
197
- setDocumentType(null);
198
- };
199
- const handleCreate = () => {
39
+ const [uploadFile] = useUploadArcherFileMutation();
40
+ const handleCreate = (file, documentType) => {
200
41
  const id = Number(carrierID);
201
42
  if (!Number.isNaN(id) && file && documentType)
202
- uploadFile({
43
+ return uploadFile({
203
44
  description: documentType,
204
45
  file,
205
46
  modelID: id,
206
47
  modelType: "Carrier",
207
- })
208
- .unwrap()
209
- .then(() => handleClose())
210
- .catch(() => handleClose());
48
+ });
49
+ return;
211
50
  };
212
- return (_jsx(Modal, { open: open, onClose: handleClose, children: _jsxs(ModalDialog, { "aria-labelledby": "modal-dialog-title", layout: "center", sx: (theme) => ({
213
- width: 500,
214
- [theme.breakpoints.only("xs")]: {
215
- top: 0,
216
- left: 0,
217
- right: 0,
218
- bottom: 0,
219
- border: 0,
220
- borderRadius: 0,
221
- transform: "initial",
222
- maxWidth: "initial",
223
- maxHeight: "initial",
224
- width: "initial",
225
- },
226
- }), children: [_jsx(Typography, { id: "modal-dialog-title", level: "h2", children: t("entities:archerFile.others.upload_document") }), _jsxs(Grid, { container: true, spacing: 2, overflow: "auto", justifyContent: "center", children: [_jsx(Grid, { xs: 12, children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: t("entities:archerFile.others.document_type") }), _jsx(Select, { value: documentType, onChange: (_e, v) => setDocumentType(v), children: carrierDocumentTypes.map((d) => (_jsx(Option, { value: d, children: d }, d))) })] }) }), _jsx(Grid, { xs: 12, children: _jsxs(FormControl, { children: [_jsx(NerdFileUpload, { uploadFile: (file) => setFile(file), slotProps: {
227
- root: {
228
- variant: "soft",
229
- size: "sm",
230
- },
231
- }, accept: [
232
- "image/gif",
233
- "image/jpeg",
234
- "image/jpg",
235
- "image/png",
236
- "image/tiff",
237
- "application/pdf",
238
- "application/vnd.ms-excel",
239
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
240
- ], maxSize: 30000000, onError: (error) => dispatch(showNotification({
241
- severity: "danger",
242
- title: error.message,
243
- autohide: true,
244
- variant: "non-intrusive",
245
- })) }), _jsxs(FormHelperText, { children: ["Accepted formats: gif, jpeg, jpg, png, tiff, pdf, xls, xlsx", _jsx("br", {}), "Limit: 30 MB"] })] }) }), file ? (_jsx(Grid, { xs: 12, children: _jsx(Sheet, { sx: {
246
- p: 0.5,
247
- borderRadius: 5,
248
- }, children: _jsxs(Grid, { container: true, gap: 2, alignItems: "center", children: [_jsx(Grid, { children: _jsx(Typography, { level: "h2", color: "primary", children: _jsx("i", { className: "fa-regular fa-file" }) }) }), _jsxs(Grid, { children: [_jsx(Typography, { textOverflow: "ellipsis", overflow: "hidden", whiteSpace: "nowrap", level: "body-md", display: "inline", children: file.name }), _jsx(Typography, { ml: 1, level: "body-xs", display: "inline", children: `(${(file.size / 1000000).toFixed(2)} MB)` })] }), _jsx(Grid, { marginLeft: "auto", children: _jsx(IconButton, { variant: "plain", color: "danger", onClick: () => setFile(null), size: "sm", children: _jsx("i", { className: "fa-solid fa-xmark" }) }) })] }) }) })) : null] }), _jsxs(DialogActions, { children: [_jsx(Button, { onClick: handleClose, color: "neutral", variant: "soft", children: t("global.Cancel") }), _jsx(Button, { loading: isLoading, onClick: handleCreate, children: t("global.Upload") })] })] }) }));
249
- };
51
+ return (_jsxs(Box, { display: "flex", gap: 0.5, width: "100%", height: "100%", children: [_jsx(Box, { height: "calc(100vh - 230px)", sx: { display: "grid", width: "100%" }, children: _jsx(ArcherFilesDataGrid, { fileTypes: CARRIER_DOCUMENT_TYPES, files: data || [], localStorageKey: localStorageKey, onAddFileDialogClose: () => setOpen(false), openAddFileDialog: open, onUploadFile: handleCreate }) }), _jsx(Button, { size: "sm", variant: "soft", onClick: () => setOpen(true), disabled: Number.isNaN(Number(carrierID)), children: _jsx("i", { className: "fa-solid fa-plus" }) })] }));
52
+ }
250
53
  //# sourceMappingURL=carrierDocuments.js.map