@paro.io/expert-shared-components 1.4.12 → 1.5.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 (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 +381 -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 +183 -0
  21. package/lib/components/DocumentCenter/ParoDocumentsTable.d.ts +16 -0
  22. package/lib/components/DocumentCenter/ParoDocumentsTable.js +384 -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 +0 -87
@@ -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,381 @@
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 base_ui_1 = require("@paro.io/base-ui");
43
+ const DocumentUploadRow_1 = require("./DocumentUploadRow");
44
+ const base_icons_1 = require("@paro.io/base-icons");
45
+ const DeleteDocumentModal_1 = require("./DeleteDocumentModal");
46
+ const utils_1 = require("../shared/utils");
47
+ exports.useStyles = (0, core_1.makeStyles)({
48
+ tableCell: {
49
+ whiteSpace: 'normal',
50
+ border: '1px solid #E2E8F0',
51
+ padding: '10px'
52
+ },
53
+ tableRow: {
54
+ height: 40
55
+ },
56
+ container: {
57
+ overflow: 'auto',
58
+ padding: 10,
59
+ width: '100%',
60
+ borderRadius: '12px',
61
+ margin: '12px'
62
+ },
63
+ tableCellBorder: {
64
+ whiteSpace: 'nowrap',
65
+ border: '1px solid #E2E8F0'
66
+ },
67
+ shade: {
68
+ backgroundColor: '#D9EFEF'
69
+ }
70
+ });
71
+ function descendingComparator(a, b, orderBy) {
72
+ var _a, _b, _c, _d, _e, _f;
73
+ if (orderBy === 'docSize') {
74
+ //@ts-ignore
75
+ const sizeA = (_a = a === null || a === void 0 ? void 0 : a.docSize) !== null && _a !== void 0 ? _a : 0;
76
+ //@ts-ignore
77
+ const sizeB = (_b = b === null || b === void 0 ? void 0 : b.docSize) !== null && _b !== void 0 ? _b : 0;
78
+ if (sizeB < sizeA) {
79
+ return -1;
80
+ }
81
+ if (sizeB > sizeA) {
82
+ return 1;
83
+ }
84
+ return 0;
85
+ }
86
+ else if (orderBy === 'uploadedDate' || orderBy === 'lastViewed') {
87
+ //@ts-ignore
88
+ const dateA = a === null || a === void 0 ? void 0 : a[orderBy];
89
+ //@ts-ignore
90
+ const dateB = b === null || b === void 0 ? void 0 : b[orderBy];
91
+ //@ts-ignore
92
+ if (dateB < dateA) {
93
+ return -1;
94
+ }
95
+ //@ts-ignore
96
+ if (dateB > dateA) {
97
+ return 1;
98
+ }
99
+ return 0;
100
+ }
101
+ else if (orderBy === 'clientName') {
102
+ //@ts-ignore
103
+ const clientA = (_c = a === null || a === void 0 ? void 0 : a.clientName) !== null && _c !== void 0 ? _c : "";
104
+ //@ts-ignore
105
+ const clientB = (_d = b === null || b === void 0 ? void 0 : b.clientName) !== null && _d !== void 0 ? _d : "";
106
+ if (clientB < clientA) {
107
+ return -1;
108
+ }
109
+ if (clientB > clientA) {
110
+ return 1;
111
+ }
112
+ return 0;
113
+ }
114
+ else if (orderBy === 'fileName' || orderBy === 'docType' || orderBy === 'projectName' || orderBy === 'uploadedBy') {
115
+ //@ts-ignore
116
+ const valueA = (_e = a === null || a === void 0 ? void 0 : a[orderBy]) !== null && _e !== void 0 ? _e : "";
117
+ //@ts-ignore
118
+ const valueB = (_f = b === null || b === void 0 ? void 0 : b[orderBy]) !== null && _f !== void 0 ? _f : "";
119
+ if (valueB < valueA) {
120
+ return -1;
121
+ }
122
+ if (valueB > valueA) {
123
+ return 1;
124
+ }
125
+ return 0;
126
+ }
127
+ else {
128
+ (0, utils_1.compareItems)(a, b, orderBy);
129
+ }
130
+ }
131
+ const getKeyByValue = (object, value) => {
132
+ if (!value) {
133
+ return '-';
134
+ }
135
+ return Object.keys(object).find(key => object[key] === value);
136
+ };
137
+ const ClientDocumentsTable = ({ legacyFreelancerId, expertFiles, setExpertClientFiles, clientAndProjectsList, uploadExpertClientFiles, paroDocuments, freelancerName, freelancerEmail, updateFileLastViewed, deleteExpertClientFile, getFileLazyQuery, expertClientFilesLazyQuery, isClientPortal, }) => {
138
+ const classes = (0, exports.useStyles)();
139
+ const [order, setOrder] = react_1.default.useState('desc');
140
+ const [orderBy, setOrderBy] = react_1.default.useState('lastViewed');
141
+ const [currentPage, setCurrentPage] = (0, react_1.useState)(1);
142
+ const [perPageItems, setPerPageItems] = (0, react_1.useState)(10);
143
+ const [files, setFiles] = (0, react_1.useState)(expertFiles);
144
+ const [clientAndProject, setClientAndProject] = (0, react_1.useState)('');
145
+ const [docType, setDocType] = (0, react_1.useState)('');
146
+ const [searchText, setSearchText] = (0, react_1.useState)('');
147
+ const [downloadFilename, setDownloadFilename] = (0, react_1.useState)('');
148
+ const [isDeleteModalOpen, setDeleteModalOpen] = (0, react_1.useState)(false);
149
+ const [deleteFileName, setDeleteFileName] = (0, react_1.useState)('');
150
+ const [fileData, setFileData] = (0, react_1.useState)('');
151
+ const [fileId, setFileId] = (0, react_1.useState)(null);
152
+ const firstItem = (currentPage - 1) * perPageItems;
153
+ const lastItem = (currentPage - 1) * perPageItems + perPageItems;
154
+ const headCells = (0, react_1.useMemo)(() => [
155
+ { id: 'fileName', label: 'File Name' },
156
+ { id: 'docType', label: 'Document Type' },
157
+ { id: 'docSize', label: 'Document Size' },
158
+ {
159
+ id: isClientPortal ? 'expertName' : 'clientName',
160
+ label: isClientPortal ? 'Expert Name' : 'Client Name',
161
+ },
162
+ { id: 'projectName', label: 'Project Name' },
163
+ { id: 'projectStatus', label: 'Project Status' },
164
+ { id: 'uploadedDate', label: 'Uploaded Date' },
165
+ { id: 'uploadedBy', label: 'Uploaded By' },
166
+ { id: 'lastViewed', label: 'Last Viewed' },
167
+ ], [isClientPortal]);
168
+ const tableData = (files === null || files === void 0 ? void 0 : files.length) ? files === null || files === void 0 ? void 0 : files.map((file) => {
169
+ return {
170
+ fileId: file === null || file === void 0 ? void 0 : file.id,
171
+ fileName: (file === null || file === void 0 ? void 0 : file.fileName) || "-",
172
+ docType: getKeyByValue(utils_1.DOCUMENT_TYPE_CONSTANTS, file === null || file === void 0 ? void 0 : file.fileType) || "-",
173
+ docSize: Math.ceil((file === null || file === void 0 ? void 0 : file.fileSize) / 1000000) || 0,
174
+ clientName: (file === null || file === void 0 ? void 0 : file.clientName) || "-",
175
+ expertName: (file === null || file === void 0 ? void 0 : file.freelancerName) || "-",
176
+ projectName: (file === null || file === void 0 ? void 0 : file.projectName) || "-",
177
+ projectStatus: file === null || file === void 0 ? void 0 : file.projectStatus,
178
+ uploadedDate: (0, utils_1.formatDate)(file === null || file === void 0 ? void 0 : file.uploadedDate),
179
+ uploadedBy: (file === null || file === void 0 ? void 0 : file.uploadedBy) || "-",
180
+ 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',
181
+ projectId: file === null || file === void 0 ? void 0 : file.projectId,
182
+ };
183
+ }) : [];
184
+ (0, react_1.useEffect)(() => {
185
+ const sortByTextProjects = searchText === ''
186
+ ? expertFiles
187
+ : expertFiles === null || expertFiles === void 0 ? void 0 : expertFiles.filter((p) => {
188
+ var _a, _b, _c;
189
+ return ((_a = p === null || p === void 0 ? void 0 : p.clientName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchText.toLowerCase())) ||
190
+ ((_b = p === null || p === void 0 ? void 0 : p.projectName) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchText.toLowerCase())) ||
191
+ ((_c = p === null || p === void 0 ? void 0 : p.fileName) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes(searchText.toLowerCase()));
192
+ });
193
+ setFiles(sortByTextProjects);
194
+ }, [searchText]);
195
+ const getFileData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ fileName, folderName }) {
196
+ var _b, _c;
197
+ const fileData = yield getFileLazyQuery({
198
+ skip: !downloadFilename,
199
+ variables: {
200
+ input: {
201
+ foldername: folderName,
202
+ filename: fileName,
203
+ isClientFile: true, // to fetch data from new s3 bucket
204
+ },
205
+ },
206
+ });
207
+ 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) {
208
+ (0, utils_1.showToast)('success', 'File Data fetched successfully!');
209
+ setFileData(fileData);
210
+ }
211
+ else {
212
+ (0, utils_1.showToast)('warning', 'Failed to fetch file data! Please try again.');
213
+ }
214
+ });
215
+ const refetchFiles = () => __awaiter(void 0, void 0, void 0, function* () {
216
+ var _a, _b;
217
+ try {
218
+ const freelancerIds = Array.isArray(legacyFreelancerId) ? legacyFreelancerId : [legacyFreelancerId];
219
+ const { data } = yield expertClientFilesLazyQuery({
220
+ variables: { freelancerIds },
221
+ fetchPolicy: 'network-only',
222
+ });
223
+ setExpertClientFiles((_a = data === null || data === void 0 ? void 0 : data.getExpertClientFiles) === null || _a === void 0 ? void 0 : _a.files);
224
+ setFiles((_b = data === null || data === void 0 ? void 0 : data.getExpertClientFiles) === null || _b === void 0 ? void 0 : _b.files);
225
+ }
226
+ catch (error) {
227
+ console.error('Error refetching query:', error);
228
+ }
229
+ });
230
+ const updateLastViewed = () => __awaiter(void 0, void 0, void 0, function* () {
231
+ yield updateFileLastViewed({
232
+ variables: {
233
+ input: {
234
+ fileId: fileId,
235
+ lastViewed: new Date().toISOString(),
236
+ },
237
+ }
238
+ }).then(() => {
239
+ refetchFiles();
240
+ });
241
+ });
242
+ (0, react_1.useEffect)(() => {
243
+ var _a, _b;
244
+ if (!fileData || !fileData.data || !fileData.data.getFile || !fileData.data.getFile.data) {
245
+ console.error("Invalid file data.");
246
+ return;
247
+ }
248
+ try {
249
+ const a = document.createElement('a');
250
+ const mimeType = (0, utils_1.getFileMimeType)(downloadFilename);
251
+ if (mimeType === 'application/pdf') {
252
+ // handle pdf type files
253
+ (0, utils_1.handleDownloadPdf)({ fileData, downloadFilename });
254
+ updateLastViewed();
255
+ }
256
+ else {
257
+ // handle other type files
258
+ 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}`;
259
+ a.download = downloadFilename;
260
+ a.click();
261
+ updateLastViewed();
262
+ }
263
+ }
264
+ catch (error) {
265
+ console.error('Error downloading file:', error);
266
+ (0, utils_1.showToast)('warning', 'Failed to download file! Please try again.');
267
+ }
268
+ finally {
269
+ setDownloadFilename('');
270
+ setFileData('');
271
+ setFileId(null);
272
+ }
273
+ }, [fileData]);
274
+ const handleRequestSort = (event, property) => {
275
+ const isDesc = orderBy === property && order === 'desc';
276
+ setOrder(isDesc ? 'asc' : 'desc');
277
+ setOrderBy(property);
278
+ };
279
+ const createSortHandler = (property) => (event) => {
280
+ handleRequestSort(event, property);
281
+ };
282
+ const handleDelete = () => {
283
+ deleteExpertClientFile({
284
+ variables: {
285
+ input: {
286
+ fileId: fileId,
287
+ },
288
+ }
289
+ })
290
+ .then(() => {
291
+ toggleDeleteModal(deleteFileName, fileId);
292
+ refetchFiles();
293
+ (0, utils_1.showToast)('success', 'File deleted successfully!');
294
+ setFileId(null);
295
+ })
296
+ .catch((err) => {
297
+ toggleDeleteModal(deleteFileName, fileId);
298
+ console.error(`Error deleting file ${err}`);
299
+ (0, utils_1.showToast)('warning', 'Failed to delete file! Please retry.');
300
+ setFileId(null);
301
+ });
302
+ };
303
+ const handleDownloadFile = (fileName, fileId, projectId) => __awaiter(void 0, void 0, void 0, function* () {
304
+ (0, utils_1.showToast)('success', 'Starting File Download...');
305
+ fileId && setFileId(fileId);
306
+ if (fileName) {
307
+ setDownloadFilename(fileName);
308
+ const folderName = `project-${projectId}`;
309
+ yield getFileData({ fileName, folderName });
310
+ }
311
+ });
312
+ const toggleDeleteModal = (fileName, fileId) => {
313
+ setDeleteModalOpen(!isDeleteModalOpen);
314
+ if (fileName) {
315
+ setDeleteFileName(fileName);
316
+ }
317
+ fileId && setFileId(fileId);
318
+ };
319
+ return (react_1.default.createElement(react_1.default.Fragment, null,
320
+ react_1.default.createElement(DocumentUploadRow_1.DocumentUploadRow, { clientAndProject: clientAndProject, setClientAndProject: setClientAndProject, clientAndProjectsList: clientAndProjectsList, docType: docType, setDocType: setDocType, paroDocuments: paroDocuments, uploadExpertClientFiles: uploadExpertClientFiles, refetchFiles: refetchFiles, legacyFreelancerId: legacyFreelancerId, freelancerName: freelancerName, freelancerEmail: freelancerEmail, isClientPortal: isClientPortal }),
321
+ react_1.default.createElement(utils_1.CustomPaper, { style: { height: `${(files === null || files === void 0 ? void 0 : files.length) === 0 ? '30vh' : 'auto'}` } },
322
+ (files === null || files === void 0 ? void 0 : files.length) > 0 && react_1.default.createElement("div", { className: 'w-1/4' },
323
+ react_1.default.createElement(base_ui_1.Input, { placeholder: "Search Documents", type: "text", value: searchText, onChange: (e) => setSearchText(e.target.value) })),
324
+ 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' } },
325
+ react_1.default.createElement(core_1.TableHead, null,
326
+ react_1.default.createElement(core_1.TableRow, { className: [classes.tableCellBorder, classes.shade].join(" ") },
327
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }),
328
+ headCells.map((headCell) => (react_1.default.createElement(core_1.TableCell, { key: headCell.id, sortDirection: orderBy === headCell.id ? order : false, align: "center", className: classes.tableCell },
329
+ react_1.default.createElement(core_1.TableSortLabel, { active: orderBy === headCell.id, direction: orderBy === headCell.id ? order : 'asc', onClick: createSortHandler(headCell.id) },
330
+ react_1.default.createElement("div", { className: "flex flex-row items-center gap-x-1" },
331
+ react_1.default.createElement("div", { className: "flex flex-col justify-center items-center" },
332
+ react_1.default.createElement("b", null, headCell.label)),
333
+ orderBy === headCell.id && null))))),
334
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }))),
335
+ 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) => {
336
+ const { fileId, fileName, docType, docSize, clientName, expertName, projectName, projectStatus, uploadedDate, uploadedBy, lastViewed, projectId } = row;
337
+ return (react_1.default.createElement(core_1.TableRow, { key: fileId },
338
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, index + 1),
339
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" },
340
+ react_1.default.createElement("a", { onClick: () => handleDownloadFile(fileName, fileId, projectId), style: {
341
+ color: 'blue',
342
+ textDecoration: 'underline',
343
+ cursor: 'pointer',
344
+ } }, fileName)),
345
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, docType),
346
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" },
347
+ docSize.toFixed(1),
348
+ " MB"),
349
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, isClientPortal ? expertName : clientName),
350
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, projectName),
351
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, projectStatus),
352
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, uploadedDate),
353
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, `${uploadedBy.charAt(0)}${uploadedBy.slice(1).toLowerCase()}`),
354
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell, align: "center" }, lastViewed),
355
+ react_1.default.createElement(core_1.TableCell, { className: classes.tableCell },
356
+ react_1.default.createElement(core_1.Grid, { item: true, container: true, direction: "row", justify: "space-evenly", alignItems: "center" },
357
+ react_1.default.createElement(core_1.Tooltip, { arrow: true, placement: "top", interactive: true, className: "whitespace-nowrap", title: "Download Document" },
358
+ react_1.default.createElement(core_1.IconButton, { onClick: () => __awaiter(void 0, void 0, void 0, function* () { return handleDownloadFile(fileName, fileId, projectId); }) },
359
+ " ",
360
+ react_1.default.createElement(base_icons_1.IconDocumentDownload, { size: "sm" }),
361
+ " ")),
362
+ (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'}` },
363
+ react_1.default.createElement(core_1.IconButton, { onClick: () => toggleDeleteModal(fileName, fileId) },
364
+ " ",
365
+ react_1.default.createElement(base_icons_1.IconTrash, { size: "sm" }),
366
+ " "))))));
367
+ })))
368
+ :
369
+ react_1.default.createElement(core_1.Box, { style: { marginTop: '5rem' } },
370
+ react_1.default.createElement(core_1.Typography, { variant: "h6", style: { fontWeight: 'bold' }, align: 'center' }, "No Documents Found"),
371
+ 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."))),
372
+ (expertFiles === null || expertFiles === void 0 ? void 0 : expertFiles.length) >= 10 && react_1.default.createElement(core_1.Box, { m: 2 },
373
+ 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" })),
374
+ react_1.default.createElement(DeleteDocumentModal_1.DeleteDocumentModal, { isDeleteModalOpen: isDeleteModalOpen, setDeleteModalOpen: setDeleteModalOpen, handleDelete: handleDelete, content: (react_1.default.createElement(react_1.default.Fragment, null,
375
+ "Are you sure you want to delete document ",
376
+ react_1.default.createElement("strong", null, deleteFileName),
377
+ " ?",
378
+ react_1.default.createElement("br", null),
379
+ "If you continue, this document will no longer be available.")) }))));
380
+ };
381
+ 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;