@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
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stateAbbreviationMap = exports.getPreviousMonthStartDate = exports.isOlderThan30Days = exports.formatTenure = exports.isOnClickEvent = void 0;
3
+ exports.DOCUMENT_TYPE_CONSTANTS = exports.validateFileUpload = exports.showToast = exports.MAX_FILE_SIZE = exports.ACCEPTED_FILE_TYPES = exports.formatDate = exports.CustomPaper = exports.handleDownloadPdf = exports.getFileMimeType = exports.stateAbbreviationMap = exports.getPreviousMonthStartDate = exports.isOlderThan30Days = exports.formatTenure = exports.isOnClickEvent = void 0;
4
+ exports.getComparator = getComparator;
5
+ exports.stableSort = stableSort;
6
+ exports.compareItems = compareItems;
7
+ const core_1 = require("@material-ui/core");
8
+ const ReviewsTab_1 = require("../ReviewsTab/ReviewsTab");
4
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
5
10
  const isOnClickEvent = (potentialEvent) => {
6
11
  return (potentialEvent === null || potentialEvent === void 0 ? void 0 : potentialEvent.type) === 'mouseup' || (potentialEvent === null || potentialEvent === void 0 ? void 0 : potentialEvent.type) === 'keydown' || (potentialEvent === null || potentialEvent === void 0 ? void 0 : potentialEvent.type) === 'click';
@@ -105,3 +110,159 @@ exports.stateAbbreviationMap = {
105
110
  SK: 'Saskatchewan',
106
111
  YT: 'Yukon'
107
112
  };
113
+ const getFileMimeType = (filename) => {
114
+ var _a;
115
+ const extension = (_a = filename.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
116
+ switch (extension) {
117
+ case 'pdf':
118
+ return 'application/pdf';
119
+ case 'doc':
120
+ return 'application/msword';
121
+ case 'docx':
122
+ return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
123
+ case 'ppt':
124
+ return 'application/vnd.ms-powerpoint';
125
+ case 'xls':
126
+ return 'application/vnd.ms-excel';
127
+ case 'xlsx':
128
+ return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
129
+ default:
130
+ return 'application/octet-stream';
131
+ }
132
+ };
133
+ exports.getFileMimeType = getFileMimeType;
134
+ const handleDownloadPdf = ({ fileData, downloadFilename, }) => {
135
+ var _a, _b;
136
+ const byteCharacters = atob((_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);
137
+ const byteNumbers = new Array(byteCharacters.length);
138
+ for (let i = 0; i < byteCharacters.length; i++) {
139
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
140
+ }
141
+ const byteArray = new Uint8Array(byteNumbers);
142
+ const blob = new Blob([byteArray], { type: 'application/pdf' });
143
+ const blobUrl = URL.createObjectURL(blob);
144
+ const newTab = window.open(blobUrl, '_blank');
145
+ const downloadLink = document.createElement('a');
146
+ downloadLink.href = blobUrl;
147
+ downloadLink.download = downloadFilename;
148
+ document.body.appendChild(downloadLink);
149
+ downloadLink.click();
150
+ document.body.removeChild(downloadLink);
151
+ URL.revokeObjectURL(blobUrl);
152
+ if (newTab) {
153
+ newTab.focus();
154
+ }
155
+ };
156
+ exports.handleDownloadPdf = handleDownloadPdf;
157
+ exports.CustomPaper = (0, core_1.styled)(core_1.Paper)({
158
+ overflow: 'auto',
159
+ padding: '12px',
160
+ scrollbarWidth: 'auto', // For Firefox
161
+ '-ms-overflow-style': 'auto', // For IE 10+
162
+ '&::-webkit-scrollbar': {
163
+ width: '6px',
164
+ height: '6px',
165
+ },
166
+ '&::-webkit-scrollbar-track': {
167
+ background: '#C1C1C1',
168
+ borderRadius: '4px',
169
+ },
170
+ '&::-webkit-scrollbar-thumb': {
171
+ background: '#F1F1F1',
172
+ },
173
+ '&::-webkit-scrollbar-thumb:hover': {
174
+ background: '#FFFFFF',
175
+ },
176
+ });
177
+ function getComparator(order, orderBy, descendingComparator) {
178
+ return order === 'desc'
179
+ ? (a, b) => descendingComparator(a, b, orderBy)
180
+ : (a, b) => -descendingComparator(a, b, orderBy);
181
+ }
182
+ function stableSort(array, comparator) {
183
+ const stabilizedThis = array.map((el, index) => [el, index]);
184
+ stabilizedThis.sort((a, b) => {
185
+ const order = comparator(a[0], b[0]);
186
+ if (order !== 0) {
187
+ return order;
188
+ }
189
+ return a[1] - b[1];
190
+ });
191
+ return stabilizedThis.map((el) => el[0]);
192
+ }
193
+ function compareItems(a, b, orderBy) {
194
+ const selectedColumnA = a === null || a === void 0 ? void 0 : a[orderBy];
195
+ const selectedColumnB = b === null || b === void 0 ? void 0 : b[orderBy];
196
+ if (selectedColumnA === 'N/A' && selectedColumnB !== 'N/A') {
197
+ return 1;
198
+ }
199
+ if (selectedColumnA !== 'N/A' && selectedColumnB === 'N/A') {
200
+ return -1;
201
+ }
202
+ if (selectedColumnB === undefined) {
203
+ return -1;
204
+ }
205
+ if (selectedColumnA === undefined) {
206
+ return 1;
207
+ }
208
+ //@ts-ignore
209
+ if (selectedColumnB < selectedColumnA) {
210
+ return -1;
211
+ }
212
+ //@ts-ignore
213
+ if (selectedColumnB > selectedColumnA) {
214
+ return 1;
215
+ }
216
+ return 0;
217
+ }
218
+ ;
219
+ const formatDate = (timestamp) => {
220
+ const date = new Date(timestamp);
221
+ const month = String(date.getUTCMonth() + 1).padStart(2, '0');
222
+ const day = String(date.getUTCDate()).padStart(2, '0');
223
+ const year = date.getUTCFullYear();
224
+ return `${month}-${day}-${year}`;
225
+ };
226
+ exports.formatDate = formatDate;
227
+ exports.ACCEPTED_FILE_TYPES = [
228
+ 'application/pdf',
229
+ 'application/msword',
230
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
231
+ 'application/vnd.ms-powerpoint',
232
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
233
+ 'application/vnd.ms-excel',
234
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
235
+ ];
236
+ exports.MAX_FILE_SIZE = 5242880; // 5MB
237
+ const showToast = (type, message) => {
238
+ (0, ReviewsTab_1.toastNotification)({
239
+ position: 'top-center',
240
+ color: type,
241
+ message,
242
+ icon: type,
243
+ });
244
+ };
245
+ exports.showToast = showToast;
246
+ const validateFileUpload = (file, isClientTab) => {
247
+ if (!file) {
248
+ (0, exports.showToast)('warning', 'No file selected.');
249
+ return false;
250
+ }
251
+ if (!exports.ACCEPTED_FILE_TYPES.includes(file.type)) {
252
+ (0, exports.showToast)('warning', 'Invalid file type. Please upload a valid file (PDF, DOC, DOCX, PPT, XLS, XLSX).');
253
+ return false;
254
+ }
255
+ if (file.size > exports.MAX_FILE_SIZE && !isClientTab) {
256
+ (0, exports.showToast)('warning', 'Document did not upload due to the file size being too large, please reduce the file size below 5 MB');
257
+ return false;
258
+ }
259
+ return true;
260
+ };
261
+ exports.validateFileUpload = validateFileUpload;
262
+ exports.DOCUMENT_TYPE_CONSTANTS = {
263
+ "Financial Documents": "FINANCIAL_DOCUMENTS",
264
+ "Contractual and Legal Documents": "CONTRACTUAL_AND_LEGAL_DOCUMENTS",
265
+ "Operational and Management Documents": "OPERATIONAL_AND_MANAGEMENT_DOCUMENTS",
266
+ "Tax and Compliance Documents": "TAX_AND_COMPLIANCE_DOCUMENTS",
267
+ "Project Specific Documents": "PROJECT_SPECIFIC_DOCUMENTS"
268
+ };
package/lib/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export { FirmEmployeeSection } from './components/FirmEmployeeSection';
5
5
  export { OrganizationChart } from './components/OrganizationChart';
6
6
  export { ExpertProfileHeader } from './components/ExpertProfileHeader';
7
7
  export { ProfileCompletedPercentage } from './components/ProfileCompletedPercentange';
8
+ export { DocumentCenter } from './components/DocumentCenter';
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProfileCompletedPercentage = exports.ExpertProfileHeader = exports.OrganizationChart = exports.FirmEmployeeSection = exports.ClientReferenceSection = exports.Reviews = exports.ReviewsTab = void 0;
3
+ exports.DocumentCenter = exports.ProfileCompletedPercentage = exports.ExpertProfileHeader = exports.OrganizationChart = exports.FirmEmployeeSection = exports.ClientReferenceSection = exports.Reviews = exports.ReviewsTab = void 0;
4
4
  var ReviewsTab_1 = require("./components/ReviewsTab");
5
5
  Object.defineProperty(exports, "ReviewsTab", { enumerable: true, get: function () { return ReviewsTab_1.ReviewsTab; } });
6
6
  var Reviews_1 = require("./components/Reviews");
@@ -15,3 +15,5 @@ var ExpertProfileHeader_1 = require("./components/ExpertProfileHeader");
15
15
  Object.defineProperty(exports, "ExpertProfileHeader", { enumerable: true, get: function () { return ExpertProfileHeader_1.ExpertProfileHeader; } });
16
16
  var ProfileCompletedPercentange_1 = require("./components/ProfileCompletedPercentange");
17
17
  Object.defineProperty(exports, "ProfileCompletedPercentage", { enumerable: true, get: function () { return ProfileCompletedPercentange_1.ProfileCompletedPercentage; } });
18
+ var DocumentCenter_1 = require("./components/DocumentCenter");
19
+ Object.defineProperty(exports, "DocumentCenter", { enumerable: true, get: function () { return DocumentCenter_1.DocumentCenter; } });
package/package.json CHANGED
@@ -1,59 +1,59 @@
1
- {
2
- "name": "@paro.io/expert-shared-components",
3
- "version": "1.4.12",
4
- "description": "",
5
- "main": "lib/index.js",
6
- "scripts": {
7
- "build": "tsc",
8
- "prepare": "yarn build",
9
- "test": "yarn test:build",
10
- "test:build": "yarn build",
11
- "clean": "yarn -rf lib",
12
- "predeploy": "tsc && cp package.json README.md ./lib",
13
- "link-local": "yarn link && cd node_modules/react && yarn link && cd ../react-dom && yarn link",
14
- "unlink-local": "yarn unlink && cd node_modules/react && yarn unlink && cd ../react-dom && yarn unlink"
15
- },
16
- "repository": "https://github.com/paroadmin/expert-shared-components.git",
17
- "keywords": ["react", "components", "shared"],
18
- "author": "apande@paro.io",
19
- "license": "MIT",
20
- "dependencies": {
21
- "@fortawesome/fontawesome-svg-core": "^6.6.0",
22
- "@fortawesome/free-solid-svg-icons": "^6.6.0",
23
- "@fortawesome/react-fontawesome": "^0.2.2",
24
- "@hookform/resolvers": "3.3.4",
25
- "@material-ui/core": "^4.11.0",
26
- "@material-ui/icons": "^4.11.3",
27
- "@material-ui/lab": "^4.0.0-alpha.61",
28
- "@paro.io/base-icons": "^1.0.4",
29
- "@paro.io/base-ui": "^1.8.3",
30
- "@types/react-input-mask": "^3.0.5",
31
- "dayjs": "^1.10.7",
32
- "lodash": "^4.17.21",
33
- "react": "^18.2.0",
34
- "react-copy-to-clipboard": "^5.0.4",
35
- "react-datepicker": "^4.6.0",
36
- "react-dom": "^17.0.2",
37
- "react-hook-form": "7.51.1",
38
- "react-hot-toast": "^2.4.1",
39
- "react-input-mask": "^3.0.0-alpha.2",
40
- "styled-components": "^5.3.3",
41
- "yup": "^0.32.11"
42
- },
43
- "devDependencies": {
44
- "@types/lodash": "^4.14.170",
45
- "@types/react": "^18.2.73",
46
- "@types/react-copy-to-clipboard": "^5.0.2",
47
- "@types/react-datepicker": "^4.19.6",
48
- "@types/react-dom": "^18.2.22",
49
- "@types/styled-components": "^5.1.22",
50
- "@types/yup": "^0.29.13",
51
- "typescript": "^5.3.3"
52
- },
53
- "files": [
54
- "lib/**/*"
55
- ],
56
- "directories": {
57
- "lib": "lib"
58
- }
59
- }
1
+ {
2
+ "name": "@paro.io/expert-shared-components",
3
+ "version": "1.5.1",
4
+ "description": "",
5
+ "main": "lib/index.js",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "prepare": "yarn build",
9
+ "test": "yarn test:build",
10
+ "test:build": "yarn build",
11
+ "clean": "yarn -rf lib",
12
+ "predeploy": "tsc && cp package.json README.md ./lib",
13
+ "link-local": "yarn link && cd node_modules/react && yarn link && cd ../react-dom && yarn link",
14
+ "unlink-local": "yarn unlink && cd node_modules/react && yarn unlink && cd ../react-dom && yarn unlink"
15
+ },
16
+ "repository": "https://github.com/paroadmin/expert-shared-components.git",
17
+ "keywords": ["react", "components", "shared"],
18
+ "author": "apande@paro.io",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "@fortawesome/fontawesome-svg-core": "^6.6.0",
22
+ "@fortawesome/free-solid-svg-icons": "^6.6.0",
23
+ "@fortawesome/react-fontawesome": "^0.2.2",
24
+ "@hookform/resolvers": "3.3.4",
25
+ "@material-ui/core": "^4.11.0",
26
+ "@material-ui/icons": "^4.11.3",
27
+ "@material-ui/lab": "^4.0.0-alpha.61",
28
+ "@paro.io/base-icons": "^1.0.4",
29
+ "@paro.io/base-ui": "^1.8.3",
30
+ "@types/react-input-mask": "^3.0.5",
31
+ "dayjs": "^1.10.7",
32
+ "lodash": "^4.17.21",
33
+ "react": "^18.2.0",
34
+ "react-copy-to-clipboard": "^5.0.4",
35
+ "react-datepicker": "^4.6.0",
36
+ "react-dom": "^17.0.2",
37
+ "react-hook-form": "7.51.1",
38
+ "react-hot-toast": "^2.4.1",
39
+ "react-input-mask": "^3.0.0-alpha.2",
40
+ "styled-components": "^5.3.3",
41
+ "yup": "^0.32.11"
42
+ },
43
+ "devDependencies": {
44
+ "@types/lodash": "^4.14.170",
45
+ "@types/react": "^18.2.73",
46
+ "@types/react-copy-to-clipboard": "^5.0.2",
47
+ "@types/react-datepicker": "^4.19.6",
48
+ "@types/react-dom": "^18.2.22",
49
+ "@types/styled-components": "^5.1.22",
50
+ "@types/yup": "^0.29.13",
51
+ "typescript": "^5.3.3"
52
+ },
53
+ "files": [
54
+ "lib/**/*"
55
+ ],
56
+ "directories": {
57
+ "lib": "lib"
58
+ }
59
+ }
package/readme.md DELETED
@@ -1,87 +0,0 @@
1
- # Expert Shared Components
2
-
3
- This repository contains shared React components that are developed in the Expert Portal but can be utilized across the Internal and Client Portals. The primary components included are `Reviews` and `ReviewsTab`, which are used to display and manage reviews for experts.
4
-
5
- ## Table of Contents
6
-
7
- - [Installation](#installation)
8
- - [Usage](#usage)
9
- - [Components](#components)
10
- - [Reviews](#reviews)
11
- - [ReviewsTab](#reviewstab)
12
- - [Contributing](#contributing)
13
- - [License](#license)
14
-
15
- ## Installation
16
-
17
- To install the package, use npm or yarn:
18
-
19
- ```sh
20
- npm install expert-shared-components
21
-
22
- or
23
-
24
- yarn add expert-shared-components
25
- ```
26
-
27
- ## Usage
28
-
29
- To use the components in your project, import them as follows:
30
-
31
- `import { Reviews, ReviewsTab } from 'expert-shared-components';`
32
-
33
- ## Components
34
-
35
- ### Reviews
36
-
37
- The Reviews component is used to display a list of reviews for an expert.
38
-
39
- Props
40
-
41
- - paroProjectsData (array): An array of project data.
42
- - legacyFreelancerId (number): The ID of the freelancer.
43
- - expertName (string): The name of the expert.
44
- - refetchParoProjects (function): A function to refetch project data.
45
- - createOrUpdateRating (any): A function or object to create or update a rating.
46
-
47
- ### Example
48
-
49
- ```
50
- <Reviews
51
- paroProjectsData={paroProjectsData}
52
- legacyFreelancerId={123}
53
- expertName="John Doe"
54
- refetchParoProjects={refetchParoProjects}
55
- createOrUpdateRating={createOrUpdateRating}
56
- />
57
- ```
58
-
59
- ### ReviewsTab
60
-
61
- The ReviewsTab component is used to display a tabbed interface for managing reviews.
62
-
63
- Props
64
-
65
- - paroProjectsData (array): An array of project data.
66
- - legacyFreelancerId (number): The ID of the freelancer.
67
- - expertName (string): The name of the expert.
68
- - refetchParoProjects (function): A function to refetch project data.
69
- - createOrUpdateRating (any): A function or object to create or update a rating.
70
- - createOrUpdateRatingRequestMutation (any): A function or object to create or update a rating request.
71
-
72
- ### Example
73
-
74
- ```
75
- <ReviewsTab
76
- paroProjectsData={paroProjectsData}
77
- legacyFreelancerId={123}
78
- expertName="John Doe"
79
- refetchParoProjects={refetchParoProjects}
80
- createOrUpdateRating={createOrUpdateRating}
81
- createOrUpdateRatingRequestMutation={createOrUpdateRatingRequestMutation}
82
- />
83
- ```
84
-
85
- ### Publishing the Components
86
- - Update the version of the component in the package.json file, either the major or the minor version based on how big the change is
87
- - Run `npm publish` to publish the component to the @paro.io/expert-shared-components npm package