@paro.io/expert-shared-components 1.4.12 → 1.5.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.
Files changed (48) hide show
  1. package/lib/components/ClientReferencesSection/DeleteButton.js +11 -11
  2. package/lib/components/ClientReferencesSection/ParoError.js +10 -10
  3. package/lib/components/ClientReferencesSection/TagsSection.js +2 -2
  4. package/lib/components/ClientReferencesSection/styles/BrandedTypography.js +2 -2
  5. package/lib/components/ClientReferencesSection/styles/Buttons.js +15 -15
  6. package/lib/components/ClientReferencesSection/styles/Name.js +5 -5
  7. package/lib/components/ClientReferencesSection/styles/NullContentConditionalColor.js +4 -4
  8. package/lib/components/ClientReferencesSection/styles/SectionBody.js +11 -11
  9. package/lib/components/ClientReferencesSection/styles/SectionTitle.js +6 -6
  10. package/lib/components/ClientReferencesSection/styles/Tags.js +2 -2
  11. package/lib/components/DocumentCenter/ClientDocumentsTable.d.ts +18 -0
  12. package/lib/components/DocumentCenter/ClientDocumentsTable.js +378 -0
  13. package/lib/components/DocumentCenter/DeleteDocumentModal.d.ts +8 -0
  14. package/lib/components/DocumentCenter/DeleteDocumentModal.js +13 -0
  15. package/lib/components/DocumentCenter/DocumentCenter.d.ts +23 -0
  16. package/lib/components/DocumentCenter/DocumentCenter.js +185 -0
  17. package/lib/components/DocumentCenter/DocumentTable.d.ts +15 -0
  18. package/lib/components/DocumentCenter/DocumentTable.js +350 -0
  19. package/lib/components/DocumentCenter/DocumentUploadRow.d.ts +26 -0
  20. package/lib/components/DocumentCenter/DocumentUploadRow.js +173 -0
  21. package/lib/components/DocumentCenter/ParoDocumentsTable.d.ts +16 -0
  22. package/lib/components/DocumentCenter/ParoDocumentsTable.js +380 -0
  23. package/lib/components/DocumentCenter/UploadFilesButton.d.ts +6 -0
  24. package/lib/components/DocumentCenter/UploadFilesButton.js +29 -0
  25. package/lib/components/DocumentCenter/index.d.ts +1 -0
  26. package/lib/components/DocumentCenter/index.js +5 -0
  27. package/lib/components/ExpertProfileHeader/ActionButtonSection.js +6 -6
  28. package/lib/components/ExpertProfileHeader/ProfileSection.js +7 -7
  29. package/lib/components/OrganizationChart/OrganizationChart.js +7 -7
  30. package/lib/components/Reviews/Pagination.js +6 -6
  31. package/lib/components/ReviewsTab/RatingHeader.js +6 -6
  32. package/lib/components/ReviewsTab/expert-shared-components.code-workspace +20 -20
  33. package/lib/components/ReviewsTab/reviewRequestModal.js +5 -5
  34. package/lib/components/shared/Error.d.ts +6 -6
  35. package/lib/components/shared/Error.js +40 -40
  36. package/lib/components/shared/Image.js +13 -13
  37. package/lib/components/shared/ProfileTextField.d.ts +18 -18
  38. package/lib/components/shared/ProfileTextField.js +16 -16
  39. package/lib/components/shared/StyledActionButtons.d.ts +7 -7
  40. package/lib/components/shared/StyledActionButtons.js +15 -15
  41. package/lib/components/shared/ToastNotification.d.ts +10 -0
  42. package/lib/components/shared/ToastNotification.js +63 -0
  43. package/lib/components/shared/utils.d.ts +29 -0
  44. package/lib/components/shared/utils.js +162 -1
  45. package/lib/index.d.ts +1 -0
  46. package/lib/index.js +3 -1
  47. package/package.json +59 -59
  48. package/readme.md +86 -86
@@ -15,26 +15,26 @@ const omitDeleteButtonIconProps = ["isDisabled"];
15
15
  const omitDeleteButtonTypographyProps = ["isDisabled"];
16
16
  const DeleteButtonTypography = (0, styled_components_1.default)((props) => {
17
17
  return react_1.default.createElement(Typography_1.default, Object.assign({}, (0, omit_1.default)(props, omitDeleteButtonTypographyProps)));
18
- }) `
19
- padding-right: 17px;
20
- color: ${colors_1.default.deleteButtonRed} !important ;
18
+ }) `
19
+ padding-right: 17px;
20
+ color: ${colors_1.default.deleteButtonRed} !important ;
21
21
  ${({ isDisabled }) => {
22
22
  return (isDisabled &&
23
- `
24
- color: ${colors_1.default.notice} !important;
23
+ `
24
+ color: ${colors_1.default.notice} !important;
25
25
  `);
26
- }}
26
+ }}
27
27
  `;
28
28
  const DeleteButtonIcon = (0, styled_components_1.default)((props) => {
29
29
  return react_1.default.createElement(Clear_1.default, Object.assign({}, (0, omit_1.default)(props, omitDeleteButtonIconProps)));
30
- }) `
31
- color: ${colors_1.default.deleteButtonRed} !important ;
30
+ }) `
31
+ color: ${colors_1.default.deleteButtonRed} !important ;
32
32
  ${({ isDisabled }) => {
33
33
  return (isDisabled &&
34
- `
35
- color: ${colors_1.default.notice} !important;
34
+ `
35
+ color: ${colors_1.default.notice} !important;
36
36
  `);
37
- }}
37
+ }}
38
38
  `;
39
39
  const DeleteButton = ({ buttonText, onClick, variant = "text", isDisabled, className }) => {
40
40
  return (react_1.default.createElement(Buttons_1.StyledEditOrDeleteButton, { onClick: () => {
@@ -9,18 +9,18 @@ const core_1 = require("@material-ui/core");
9
9
  const styled_components_1 = __importDefault(require("styled-components"));
10
10
  const colors_1 = __importDefault(require("./constants/colors"));
11
11
  const AlertSnackBarButton_1 = require("./AlertSnackBarButton");
12
- const ErrorBox = (0, styled_components_1.default)(core_1.Box) `
13
- width: 100%;
14
- padding-bottom: 100;
12
+ const ErrorBox = (0, styled_components_1.default)(core_1.Box) `
13
+ width: 100%;
14
+ padding-bottom: 100;
15
15
  `;
16
- const ParoTitle = (0, styled_components_1.default)(core_1.Box) `
17
- color: ${colors_1.default.paroBlack};
18
- padding: 0px 0px 18px 0px;
16
+ const ParoTitle = (0, styled_components_1.default)(core_1.Box) `
17
+ color: ${colors_1.default.paroBlack};
18
+ padding: 0px 0px 18px 0px;
19
19
  `;
20
- const ParoSubtitle = styled_components_1.default.div `
21
- color: ${colors_1.default.paroBlack};
22
- margin-bottom: 24px;
23
- font-size: 1rem;
20
+ const ParoSubtitle = styled_components_1.default.div `
21
+ color: ${colors_1.default.paroBlack};
22
+ margin-bottom: 24px;
23
+ font-size: 1rem;
24
24
  `;
25
25
  const ParoError = ({ handleClose }) => {
26
26
  const handleCancelLanguage = handleClose ? "Close" : "Retry";
@@ -9,8 +9,8 @@ const core_1 = require("@material-ui/core");
9
9
  const styled_components_1 = __importDefault(require("styled-components"));
10
10
  const NullContentConditionalColor_1 = require("./styles/NullContentConditionalColor");
11
11
  const Tags_1 = require("./styles/Tags");
12
- const ProfileTags = (0, styled_components_1.default)(Tags_1.Tags) `
13
- margin: 0 5px 8px 0;
12
+ const ProfileTags = (0, styled_components_1.default)(Tags_1.Tags) `
13
+ margin: 0 5px 8px 0;
14
14
  `;
15
15
  const TagsSection = ({ multiLine, tags = [], tagsExpected, }) => {
16
16
  if ((tags === null || tags === void 0 ? void 0 : tags.length) < 1) {
@@ -7,6 +7,6 @@ exports.StyledTypography = void 0;
7
7
  const Typography_1 = __importDefault(require("@material-ui/core/Typography"));
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
9
  const colors_1 = __importDefault(require("../constants/colors"));
10
- exports.StyledTypography = (0, styled_components_1.default)(Typography_1.default) `
11
- color: ${colors_1.default.paroDeepblue} !important ;
10
+ exports.StyledTypography = (0, styled_components_1.default)(Typography_1.default) `
11
+ color: ${colors_1.default.paroDeepblue} !important ;
12
12
  `;
@@ -7,21 +7,21 @@ exports.StyledEditOrDeleteButton = exports.HeaderButtonUnderline = exports.Heade
7
7
  const core_1 = require("@material-ui/core");
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
9
  const colors_1 = __importDefault(require("../constants/colors"));
10
- exports.HeaderButtons = (0, styled_components_1.default)(core_1.Button) `
11
- margin-left: 0px !important;
12
- padding-left: 0px !important;
13
- span {
14
- color: ${colors_1.default.buttonText} !important;
15
- }
10
+ exports.HeaderButtons = (0, styled_components_1.default)(core_1.Button) `
11
+ margin-left: 0px !important;
12
+ padding-left: 0px !important;
13
+ span {
14
+ color: ${colors_1.default.buttonText} !important;
15
+ }
16
16
  `;
17
- exports.HeaderButtonUnderline = (0, styled_components_1.default)(exports.HeaderButtons) `
18
- text-decoration: underline;
17
+ exports.HeaderButtonUnderline = (0, styled_components_1.default)(exports.HeaderButtons) `
18
+ text-decoration: underline;
19
19
  `;
20
- exports.StyledEditOrDeleteButton = (0, styled_components_1.default)(core_1.Button) `
21
- margin: 10px 0px !important;
22
- background-color: ${colors_1.default.primary};
23
- color: ${colors_1.default.white};
24
- :hover {
25
- color: ${colors_1.default.primary} !important;
26
- }
20
+ exports.StyledEditOrDeleteButton = (0, styled_components_1.default)(core_1.Button) `
21
+ margin: 10px 0px !important;
22
+ background-color: ${colors_1.default.primary};
23
+ color: ${colors_1.default.white};
24
+ :hover {
25
+ color: ${colors_1.default.primary} !important;
26
+ }
27
27
  `;
@@ -11,12 +11,12 @@ const styled_components_1 = __importDefault(require("styled-components"));
11
11
  const colors_1 = __importDefault(require("../constants/colors"));
12
12
  exports.Name = (0, styled_components_1.default)((props) => {
13
13
  return react_1.default.createElement(core_1.Typography, Object.assign({}, (0, omit_1.default)(props, ["isNull"])));
14
- }) `
15
- font-family: Roboto-Bold;
14
+ }) `
15
+ font-family: Roboto-Bold;
16
16
  ${({ isNull }) => {
17
17
  return (isNull &&
18
- `
19
- color: ${colors_1.default.paroRed} !important;
18
+ `
19
+ color: ${colors_1.default.paroRed} !important;
20
20
  `);
21
- }}
21
+ }}
22
22
  `;
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NullContentConditionalColor = void 0;
7
7
  const styled_components_1 = __importDefault(require("styled-components"));
8
8
  const colors_1 = __importDefault(require("../constants/colors"));
9
- exports.NullContentConditionalColor = styled_components_1.default.span `
9
+ exports.NullContentConditionalColor = styled_components_1.default.span `
10
10
  ${(props) => {
11
11
  return (props.isNull &&
12
- `
13
- color: ${colors_1.default.paroRed} !important
12
+ `
13
+ color: ${colors_1.default.paroRed} !important
14
14
  `);
15
- }}
15
+ }}
16
16
  `;
@@ -10,18 +10,18 @@ const styled_components_1 = __importDefault(require("styled-components"));
10
10
  const colors_1 = __importDefault(require("../constants/colors"));
11
11
  exports.SectionBody = (0, styled_components_1.default)((props) => {
12
12
  return react_1.default.createElement("div", Object.assign({}, (0, omit_1.default)(props, ["atLeastOneValueIsNull"])));
13
- }) `
14
- background-color: ${colors_1.default.white};
15
- border-radius: 2px;
16
- border: 1px Solid ${colors_1.default.lightGray};
17
- color: ${colors_1.default.paroBlack};
18
- font-family: Roboto;
19
- padding: 32.5px 42.5px 32.5px 42.5px;
20
- width: 100%;
13
+ }) `
14
+ background-color: ${colors_1.default.white};
15
+ border-radius: 2px;
16
+ border: 1px Solid ${colors_1.default.lightGray};
17
+ color: ${colors_1.default.paroBlack};
18
+ font-family: Roboto;
19
+ padding: 32.5px 42.5px 32.5px 42.5px;
20
+ width: 100%;
21
21
  ${({ atLeastOneValueIsNull }) => {
22
22
  return (atLeastOneValueIsNull &&
23
- `
24
- border-color: ${colors_1.default.paroRed} !important;
23
+ `
24
+ border-color: ${colors_1.default.paroRed} !important;
25
25
  `);
26
- }}
26
+ }}
27
27
  `;
@@ -10,12 +10,12 @@ const styled_components_1 = __importDefault(require("styled-components"));
10
10
  const colors_1 = __importDefault(require("../constants/colors"));
11
11
  exports.SectionTitle = (0, styled_components_1.default)((props) => {
12
12
  return react_1.default.createElement("div", Object.assign({}, (0, omit_1.default)(props, ["noBottomPadding"])));
13
- }) `
14
- font-family: Roboto-Bold;
15
- font-size: 20px;
16
- color: ${colors_1.default.paroBlack};
17
- padding: 23px 0px 15.5px 0px;
13
+ }) `
14
+ font-family: Roboto-Bold;
15
+ font-size: 20px;
16
+ color: ${colors_1.default.paroBlack};
17
+ padding: 23px 0px 15.5px 0px;
18
18
  ${({ noBottomPadding }) => {
19
19
  return noBottomPadding && "padding-bottom: 0 !important;";
20
- }}
20
+ }}
21
21
  `;
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Tags = void 0;
7
7
  const core_1 = require("@material-ui/core");
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
- exports.Tags = (0, styled_components_1.default)(core_1.Chip) `
10
- font-family: Roboto-Bold;
9
+ exports.Tags = (0, styled_components_1.default)(core_1.Chip) `
10
+ font-family: Roboto-Bold;
11
11
  `;
@@ -0,0 +1,18 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"container" | "tableCell" | "tableRow" | "tableCellBorder" | "shade">;
2
+ interface ClientDocumentTableProps {
3
+ legacyFreelancerId: number | number[];
4
+ expertFiles: any[];
5
+ setExpertClientFiles: (expertFiles: any[]) => void;
6
+ clientAndProjectsList: any[];
7
+ uploadExpertClientFiles: any;
8
+ updateFileLastViewed: any;
9
+ deleteExpertClientFile: any;
10
+ paroDocuments: boolean;
11
+ freelancerName: string;
12
+ freelancerEmail: string;
13
+ getFileLazyQuery: any;
14
+ expertClientFilesLazyQuery: any;
15
+ isClientPortal: boolean;
16
+ }
17
+ export declare const ClientDocumentsTable: ({ legacyFreelancerId, expertFiles, setExpertClientFiles, clientAndProjectsList, uploadExpertClientFiles, paroDocuments, freelancerName, freelancerEmail, updateFileLastViewed, deleteExpertClientFile, getFileLazyQuery, expertClientFilesLazyQuery, isClientPortal, }: ClientDocumentTableProps) => JSX.Element;
18
+ export {};
@@ -0,0 +1,378 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.ClientDocumentsTable = exports.useStyles = void 0;
39
+ const react_1 = __importStar(require("react"));
40
+ const core_1 = require("@material-ui/core");
41
+ const Pagination_1 = __importDefault(require("../Reviews/Pagination"));
42
+ const DocumentUploadRow_1 = require("./DocumentUploadRow");
43
+ const base_icons_1 = require("@paro.io/base-icons");
44
+ const DeleteDocumentModal_1 = require("./DeleteDocumentModal");
45
+ const utils_1 = require("../shared/utils");
46
+ exports.useStyles = (0, core_1.makeStyles)({
47
+ tableCell: {
48
+ whiteSpace: 'normal',
49
+ border: '1px solid #E2E8F0',
50
+ padding: '10px'
51
+ },
52
+ tableRow: {
53
+ height: 40
54
+ },
55
+ container: {
56
+ overflow: 'auto',
57
+ padding: 10,
58
+ width: '100%',
59
+ borderRadius: '12px',
60
+ margin: '12px'
61
+ },
62
+ tableCellBorder: {
63
+ whiteSpace: 'nowrap',
64
+ border: '1px solid #E2E8F0'
65
+ },
66
+ shade: {
67
+ backgroundColor: '#D9EFEF'
68
+ }
69
+ });
70
+ function descendingComparator(a, b, orderBy) {
71
+ var _a, _b, _c, _d, _e, _f;
72
+ if (orderBy === 'docSize') {
73
+ //@ts-ignore
74
+ const sizeA = (_a = a === null || a === void 0 ? void 0 : a.docSize) !== null && _a !== void 0 ? _a : 0;
75
+ //@ts-ignore
76
+ const sizeB = (_b = b === null || b === void 0 ? void 0 : b.docSize) !== null && _b !== void 0 ? _b : 0;
77
+ if (sizeB < sizeA) {
78
+ return -1;
79
+ }
80
+ if (sizeB > sizeA) {
81
+ return 1;
82
+ }
83
+ return 0;
84
+ }
85
+ else if (orderBy === 'uploadedDate' || orderBy === 'lastViewed') {
86
+ //@ts-ignore
87
+ const dateA = a === null || a === void 0 ? void 0 : a[orderBy];
88
+ //@ts-ignore
89
+ const dateB = b === null || b === void 0 ? void 0 : b[orderBy];
90
+ //@ts-ignore
91
+ if (dateB < dateA) {
92
+ return -1;
93
+ }
94
+ //@ts-ignore
95
+ if (dateB > dateA) {
96
+ return 1;
97
+ }
98
+ return 0;
99
+ }
100
+ else if (orderBy === 'clientName') {
101
+ //@ts-ignore
102
+ const clientA = (_c = a === null || a === void 0 ? void 0 : a.clientName) !== null && _c !== void 0 ? _c : "";
103
+ //@ts-ignore
104
+ const clientB = (_d = b === null || b === void 0 ? void 0 : b.clientName) !== null && _d !== void 0 ? _d : "";
105
+ if (clientB < clientA) {
106
+ return -1;
107
+ }
108
+ if (clientB > clientA) {
109
+ return 1;
110
+ }
111
+ return 0;
112
+ }
113
+ else if (orderBy === 'fileName' || orderBy === 'docType' || orderBy === 'projectName' || orderBy === 'uploadedBy') {
114
+ //@ts-ignore
115
+ const valueA = (_e = a === null || a === void 0 ? void 0 : a[orderBy]) !== null && _e !== void 0 ? _e : "";
116
+ //@ts-ignore
117
+ const valueB = (_f = b === null || b === void 0 ? void 0 : b[orderBy]) !== null && _f !== void 0 ? _f : "";
118
+ if (valueB < valueA) {
119
+ return -1;
120
+ }
121
+ if (valueB > valueA) {
122
+ return 1;
123
+ }
124
+ return 0;
125
+ }
126
+ else {
127
+ (0, utils_1.compareItems)(a, b, orderBy);
128
+ }
129
+ }
130
+ const getKeyByValue = (object, value) => {
131
+ if (!value) {
132
+ return '-';
133
+ }
134
+ return Object.keys(object).find(key => object[key] === value);
135
+ };
136
+ const ClientDocumentsTable = ({ legacyFreelancerId, expertFiles, setExpertClientFiles, clientAndProjectsList, uploadExpertClientFiles, paroDocuments, freelancerName, freelancerEmail, updateFileLastViewed, deleteExpertClientFile, getFileLazyQuery, expertClientFilesLazyQuery, isClientPortal, }) => {
137
+ const classes = (0, exports.useStyles)();
138
+ const [order, setOrder] = react_1.default.useState('desc');
139
+ const [orderBy, setOrderBy] = react_1.default.useState('lastViewed');
140
+ const [currentPage, setCurrentPage] = (0, react_1.useState)(1);
141
+ const [perPageItems, setPerPageItems] = (0, react_1.useState)(10);
142
+ const [files, setFiles] = (0, react_1.useState)(expertFiles);
143
+ const [clientAndProject, setClientAndProject] = (0, react_1.useState)('');
144
+ const [docType, setDocType] = (0, react_1.useState)('');
145
+ const [searchText, setSearchText] = (0, react_1.useState)('');
146
+ const [downloadFilename, setDownloadFilename] = (0, react_1.useState)('');
147
+ const [isDeleteModalOpen, setDeleteModalOpen] = (0, react_1.useState)(false);
148
+ const [deleteFileName, setDeleteFileName] = (0, react_1.useState)('');
149
+ const [fileData, setFileData] = (0, react_1.useState)('');
150
+ const [fileId, setFileId] = (0, react_1.useState)(null);
151
+ const firstItem = (currentPage - 1) * perPageItems;
152
+ const lastItem = (currentPage - 1) * perPageItems + perPageItems;
153
+ const headCells = (0, react_1.useMemo)(() => [
154
+ { id: 'fileName', label: 'File Name' },
155
+ { id: 'docType', label: 'Document Type' },
156
+ { id: 'docSize', label: 'Document Size' },
157
+ {
158
+ id: isClientPortal ? 'expertName' : 'clientName',
159
+ label: isClientPortal ? 'Expert Name' : 'Client Name',
160
+ },
161
+ { id: 'projectName', label: 'Project Name' },
162
+ { id: 'projectStatus', label: 'Project Status' },
163
+ { id: 'uploadedDate', label: 'Uploaded Date' },
164
+ { id: 'uploadedBy', label: 'Uploaded By' },
165
+ { id: 'lastViewed', label: 'Last Viewed' },
166
+ ], [isClientPortal]);
167
+ const tableData = (files === null || files === void 0 ? void 0 : files.length) ? files === null || files === void 0 ? void 0 : files.map((file) => {
168
+ return {
169
+ fileId: file === null || file === void 0 ? void 0 : file.id,
170
+ fileName: (file === null || file === void 0 ? void 0 : file.fileName) || "-",
171
+ docType: getKeyByValue(utils_1.DOCUMENT_TYPE_CONSTANTS, file === null || file === void 0 ? void 0 : file.fileType) || "-",
172
+ docSize: Math.ceil((file === null || file === void 0 ? void 0 : file.fileSize) / 1000000) || 0,
173
+ clientName: (file === null || file === void 0 ? void 0 : file.clientName) || "-",
174
+ expertName: (file === null || file === void 0 ? void 0 : file.freelancerName) || "-",
175
+ projectName: (file === null || file === void 0 ? void 0 : file.projectName) || "-",
176
+ projectStatus: file === null || file === void 0 ? void 0 : file.projectStatus,
177
+ uploadedDate: (0, utils_1.formatDate)(file === null || file === void 0 ? void 0 : file.uploadedDate),
178
+ uploadedBy: (file === null || file === void 0 ? void 0 : file.uploadedBy) || "-",
179
+ lastViewed: (file === null || file === void 0 ? void 0 : file.lastViewed) ? (0, utils_1.formatDate)(file === null || file === void 0 ? void 0 : file.lastViewed) : 'Not opened',
180
+ projectId: file === null || file === void 0 ? void 0 : file.projectId,
181
+ };
182
+ }) : [];
183
+ (0, react_1.useEffect)(() => {
184
+ const sortByTextProjects = searchText === ''
185
+ ? expertFiles
186
+ : expertFiles === null || expertFiles === void 0 ? void 0 : expertFiles.filter((p) => {
187
+ var _a, _b, _c;
188
+ return ((_a = p === null || p === void 0 ? void 0 : p.clientName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchText.toLowerCase())) ||
189
+ ((_b = p === null || p === void 0 ? void 0 : p.projectName) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchText.toLowerCase())) ||
190
+ ((_c = p === null || p === void 0 ? void 0 : p.fileName) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes(searchText.toLowerCase()));
191
+ });
192
+ setFiles(sortByTextProjects);
193
+ }, [searchText]);
194
+ const getFileData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ fileName, folderName }) {
195
+ var _b, _c;
196
+ const fileData = yield getFileLazyQuery({
197
+ skip: !downloadFilename,
198
+ variables: {
199
+ input: {
200
+ foldername: folderName,
201
+ filename: fileName,
202
+ isClientFile: true, // to fetch data from new s3 bucket
203
+ },
204
+ },
205
+ });
206
+ if ((_c = (_b = fileData === null || fileData === void 0 ? void 0 : fileData.data) === null || _b === void 0 ? void 0 : _b.getFile) === null || _c === void 0 ? void 0 : _c.data) {
207
+ (0, utils_1.showToast)('success', 'File Data fetched successfully!');
208
+ setFileData(fileData);
209
+ }
210
+ else {
211
+ (0, utils_1.showToast)('warning', 'Failed to fetch file data! Please try again.');
212
+ }
213
+ });
214
+ const refetchFiles = () => __awaiter(void 0, void 0, void 0, function* () {
215
+ var _a, _b;
216
+ try {
217
+ const freelancerIds = Array.isArray(legacyFreelancerId) ? legacyFreelancerId : [legacyFreelancerId];
218
+ const { data } = yield expertClientFilesLazyQuery({
219
+ variables: { freelancerIds },
220
+ fetchPolicy: 'network-only',
221
+ });
222
+ setExpertClientFiles((_a = data === null || data === void 0 ? void 0 : data.getExpertClientFiles) === null || _a === void 0 ? void 0 : _a.files);
223
+ setFiles((_b = data === null || data === void 0 ? void 0 : data.getExpertClientFiles) === null || _b === void 0 ? void 0 : _b.files);
224
+ }
225
+ catch (error) {
226
+ console.error('Error refetching query:', error);
227
+ }
228
+ });
229
+ const updateLastViewed = () => __awaiter(void 0, void 0, void 0, function* () {
230
+ yield updateFileLastViewed({
231
+ variables: {
232
+ input: {
233
+ fileId: fileId,
234
+ lastViewed: new Date().toISOString(),
235
+ },
236
+ }
237
+ }).then(() => {
238
+ refetchFiles();
239
+ });
240
+ });
241
+ (0, react_1.useEffect)(() => {
242
+ var _a, _b;
243
+ if (!fileData || !fileData.data || !fileData.data.getFile || !fileData.data.getFile.data) {
244
+ console.error("Invalid file data.");
245
+ return;
246
+ }
247
+ try {
248
+ const a = document.createElement('a');
249
+ const mimeType = (0, utils_1.getFileMimeType)(downloadFilename);
250
+ if (mimeType === 'application/pdf') {
251
+ // handle pdf type files
252
+ (0, utils_1.handleDownloadPdf)({ fileData, downloadFilename });
253
+ updateLastViewed();
254
+ }
255
+ else {
256
+ // handle other type files
257
+ a.href = `data:${mimeType};base64,${(_b = (_a = fileData === null || fileData === void 0 ? void 0 : fileData.data) === null || _a === void 0 ? void 0 : _a.getFile) === null || _b === void 0 ? void 0 : _b.data}`;
258
+ a.download = downloadFilename;
259
+ a.click();
260
+ updateLastViewed();
261
+ }
262
+ }
263
+ catch (error) {
264
+ console.error('Error downloading file:', error);
265
+ (0, utils_1.showToast)('warning', 'Failed to download file! Please try again.');
266
+ }
267
+ finally {
268
+ setDownloadFilename('');
269
+ setFileData('');
270
+ setFileId(null);
271
+ }
272
+ }, [fileData]);
273
+ const handleRequestSort = (event, property) => {
274
+ const isDesc = orderBy === property && order === 'desc';
275
+ setOrder(isDesc ? 'asc' : 'desc');
276
+ setOrderBy(property);
277
+ };
278
+ const createSortHandler = (property) => (event) => {
279
+ handleRequestSort(event, property);
280
+ };
281
+ const handleDelete = () => {
282
+ deleteExpertClientFile({
283
+ variables: {
284
+ input: {
285
+ fileId: fileId,
286
+ },
287
+ }
288
+ })
289
+ .then(() => {
290
+ toggleDeleteModal(deleteFileName, fileId);
291
+ refetchFiles();
292
+ (0, utils_1.showToast)('success', 'File deleted successfully!');
293
+ setFileId(null);
294
+ })
295
+ .catch((err) => {
296
+ toggleDeleteModal(deleteFileName, fileId);
297
+ console.error(`Error deleting file ${err}`);
298
+ (0, utils_1.showToast)('warning', 'Failed to delete file! Please retry.');
299
+ setFileId(null);
300
+ });
301
+ };
302
+ const handleDownloadFile = (fileName, fileId, projectId) => __awaiter(void 0, void 0, void 0, function* () {
303
+ (0, utils_1.showToast)('success', 'Starting File Download...');
304
+ fileId && setFileId(fileId);
305
+ if (fileName) {
306
+ setDownloadFilename(fileName);
307
+ const folderName = `project-${projectId}`;
308
+ yield getFileData({ fileName, folderName });
309
+ }
310
+ });
311
+ const toggleDeleteModal = (fileName, fileId) => {
312
+ setDeleteModalOpen(!isDeleteModalOpen);
313
+ if (fileName) {
314
+ setDeleteFileName(fileName);
315
+ }
316
+ fileId && setFileId(fileId);
317
+ };
318
+ return (react_1.default.createElement(utils_1.CustomPaper, null,
319
+ react_1.default.createElement(DocumentUploadRow_1.DocumentUploadRow, { clientAndProject: clientAndProject, setClientAndProject: setClientAndProject, clientAndProjectsList: clientAndProjectsList, docType: docType, setDocType: setDocType, searchText: searchText, setSearchText: setSearchText, paroDocuments: paroDocuments, uploadExpertClientFiles: uploadExpertClientFiles, refetchFiles: refetchFiles, legacyFreelancerId: legacyFreelancerId, freelancerName: freelancerName, freelancerEmail: freelancerEmail, isClientPortal: isClientPortal }),
320
+ react_1.default.createElement(core_1.Box, { mt: 2 }, (files === null || files === void 0 ? void 0 : files.length) > 0 ? react_1.default.createElement(core_1.Table, { style: { overflow: 'auto' } },
321
+ react_1.default.createElement(core_1.TableHead, null,
322
+ react_1.default.createElement(core_1.TableRow, { className: [classes.tableCellBorder, classes.shade].join(" ") },
323
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }),
324
+ headCells.map((headCell) => (react_1.default.createElement(core_1.TableCell, { key: headCell.id, sortDirection: orderBy === headCell.id ? order : false, align: "center", className: classes.tableCell },
325
+ react_1.default.createElement(core_1.TableSortLabel, { active: orderBy === headCell.id, direction: orderBy === headCell.id ? order : 'asc', onClick: createSortHandler(headCell.id) },
326
+ react_1.default.createElement("div", { className: "flex flex-row items-center gap-x-1" },
327
+ react_1.default.createElement("div", { className: "flex flex-col justify-center items-center" },
328
+ react_1.default.createElement("b", null, headCell.label)),
329
+ orderBy === headCell.id && null))))),
330
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }))),
331
+ react_1.default.createElement(core_1.TableBody, null, (0, utils_1.stableSort)(tableData, (0, utils_1.getComparator)(order, orderBy, descendingComparator)).slice(firstItem, lastItem).map((row, index) => {
332
+ const { fileId, fileName, docType, docSize, clientName, expertName, projectName, projectStatus, uploadedDate, uploadedBy, lastViewed, projectId } = row;
333
+ return (react_1.default.createElement(core_1.TableRow, { key: fileId },
334
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, index + 1),
335
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" },
336
+ react_1.default.createElement("a", { onClick: () => handleDownloadFile(fileName, fileId, projectId), style: {
337
+ color: 'blue',
338
+ textDecoration: 'underline',
339
+ cursor: 'pointer',
340
+ } }, fileName)),
341
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, docType),
342
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" },
343
+ docSize.toFixed(1),
344
+ " MB"),
345
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, isClientPortal ? expertName : clientName),
346
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, projectName),
347
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, projectStatus),
348
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, uploadedDate),
349
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, `${uploadedBy.charAt(0)}${uploadedBy.slice(1).toLowerCase()}`),
350
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, lastViewed),
351
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell },
352
+ react_1.default.createElement(core_1.Grid, { item: true, container: true, direction: "row", justify: "space-evenly", alignItems: "center" },
353
+ react_1.default.createElement(core_1.Tooltip, { arrow: true, placement: "top", interactive: true, className: "whitespace-nowrap", title: "Download Document" },
354
+ react_1.default.createElement(core_1.IconButton, { onClick: () => __awaiter(void 0, void 0, void 0, function* () { return handleDownloadFile(fileName, fileId, projectId); }) },
355
+ " ",
356
+ react_1.default.createElement(base_icons_1.IconDocumentDownload, { size: "sm" }),
357
+ " ")),
358
+ (isClientPortal ? uploadedBy === 'CLIENT' : uploadedBy === 'FREELANCER') && react_1.default.createElement(core_1.Tooltip, { arrow: true, placement: "top", interactive: true, className: "whitespace-nowrap", title: `This will delete the document for you and the ${isClientPortal ? 'Expert' : 'Client'}` },
359
+ react_1.default.createElement(core_1.IconButton, { onClick: () => toggleDeleteModal(fileName, fileId) },
360
+ " ",
361
+ react_1.default.createElement(base_icons_1.IconTrash, { size: "sm" }),
362
+ " "))))));
363
+ })))
364
+ :
365
+ react_1.default.createElement(core_1.Box, null,
366
+ react_1.default.createElement(core_1.Divider, null),
367
+ react_1.default.createElement(core_1.Typography, { variant: "h6", style: { fontWeight: 'bold' }, align: 'center' }, "No Documents Found"),
368
+ react_1.default.createElement(core_1.Typography, { variant: "body1", align: 'center' }, "You haven\u2019t uploaded any documents yet. Click above and upload any .pdf , .doc, .docx, .ppt, .xls, .xlsx file."))),
369
+ (expertFiles === null || expertFiles === void 0 ? void 0 : expertFiles.length) >= 10 && react_1.default.createElement(core_1.Box, { m: 2 },
370
+ react_1.default.createElement(Pagination_1.default, { total: expertFiles === null || expertFiles === void 0 ? void 0 : expertFiles.length, currentPage: currentPage, setCurrentPage: setCurrentPage, perPageItems: perPageItems, setPerPageItems: setPerPageItems, displayText: "projects" })),
371
+ react_1.default.createElement(DeleteDocumentModal_1.DeleteDocumentModal, { isDeleteModalOpen: isDeleteModalOpen, setDeleteModalOpen: setDeleteModalOpen, handleDelete: handleDelete, content: (react_1.default.createElement(react_1.default.Fragment, null,
372
+ "Are you sure you want to delete document ",
373
+ react_1.default.createElement("strong", null, deleteFileName),
374
+ " ?",
375
+ react_1.default.createElement("br", null),
376
+ "If you continue, this document will no longer be available.")) })));
377
+ };
378
+ exports.ClientDocumentsTable = ClientDocumentsTable;
@@ -0,0 +1,8 @@
1
+ interface DeleteDocumentModalProps {
2
+ isDeleteModalOpen: boolean;
3
+ setDeleteModalOpen: (isDeleteModalOpen: boolean) => void;
4
+ handleDelete: any;
5
+ content: any;
6
+ }
7
+ export declare const DeleteDocumentModal: ({ isDeleteModalOpen, setDeleteModalOpen, handleDelete, content, }: DeleteDocumentModalProps) => JSX.Element;
8
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DeleteDocumentModal = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const base_ui_1 = require("@paro.io/base-ui");
9
+ const base_icons_1 = require("@paro.io/base-icons");
10
+ const DeleteDocumentModal = ({ isDeleteModalOpen, setDeleteModalOpen, handleDelete, content, }) => {
11
+ return (react_1.default.createElement(base_ui_1.Modal, { variant: base_ui_1.ModalVariant.transactional, label: "Delete Document?", color: "danger", open: isDeleteModalOpen, onClose: () => setDeleteModalOpen(!isDeleteModalOpen), icon: "danger", iconCustom: react_1.default.createElement(base_icons_1.IconExclamation, null), size: "md", onPrimaryButtonClickHandler: handleDelete }, content));
12
+ };
13
+ exports.DeleteDocumentModal = DeleteDocumentModal;