@paro.io/expert-shared-components 1.11.9 → 1.12.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.
@@ -2,6 +2,8 @@ interface ClientDisputeProjectCardProps {
2
2
  clientInvoice: any;
3
3
  updateClientInvoiceDisputeMutation: any;
4
4
  documentUploadUrl: string;
5
+ downloadDocumentUrl: string;
6
+ refetchInvoiceDisputes: any;
5
7
  }
6
- export declare const ClientDisputeProjectCard: ({ clientInvoice, updateClientInvoiceDisputeMutation, documentUploadUrl, }: ClientDisputeProjectCardProps) => JSX.Element;
8
+ export declare const ClientDisputeProjectCard: ({ clientInvoice, updateClientInvoiceDisputeMutation, documentUploadUrl, downloadDocumentUrl, refetchInvoiceDisputes, }: ClientDisputeProjectCardProps) => JSX.Element;
7
9
  export {};
@@ -31,6 +31,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
32
  });
33
33
  };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
34
37
  Object.defineProperty(exports, "__esModule", { value: true });
35
38
  exports.ClientDisputeProjectCard = void 0;
36
39
  const react_1 = __importStar(require("react"));
@@ -39,6 +42,7 @@ const base_ui_2 = require("@paro.io/base-ui");
39
42
  const core_1 = require("@material-ui/core");
40
43
  const base_icons_1 = require("@paro.io/base-icons");
41
44
  const FileUploader_1 = require("../FileUploader");
45
+ const DownloadClient_1 = __importDefault(require("../shared/DownloadClient"));
42
46
  const useStyles = (0, core_1.makeStyles)((theme) => ({
43
47
  root: {
44
48
  width: "100%",
@@ -93,8 +97,7 @@ const ACCEPTED_FILE_TYPES = [
93
97
  'image/png',
94
98
  'text/csv',
95
99
  ];
96
- const ClientDisputeProjectCard = ({ clientInvoice, updateClientInvoiceDisputeMutation, documentUploadUrl, }) => {
97
- var _a, _b;
100
+ const ClientDisputeProjectCard = ({ clientInvoice, updateClientInvoiceDisputeMutation, documentUploadUrl, downloadDocumentUrl, refetchInvoiceDisputes, }) => {
98
101
  const [expandRow, setExpandRow] = (0, react_1.useState)(null);
99
102
  const classes = useStyles();
100
103
  const [projects, setProjects] = (0, react_1.useState)(clientInvoice === null || clientInvoice === void 0 ? void 0 : clientInvoice.disputeProjects);
@@ -102,9 +105,39 @@ const ClientDisputeProjectCard = ({ clientInvoice, updateClientInvoiceDisputeMut
102
105
  const [editedExplanation, setEditedExplanation] = (0, react_1.useState)('');
103
106
  const [updatedDispute, setUpdateDispute] = (0, react_1.useState)(false);
104
107
  const [updatingDispute, setUpdatingDispute] = (0, react_1.useState)(false);
105
- const disputeProject = (_a = clientInvoice === null || clientInvoice === void 0 ? void 0 : clientInvoice.disputeProjects) === null || _a === void 0 ? void 0 : _a[0];
106
- const clientDocumentLinks = (_b = disputeProject === null || disputeProject === void 0 ? void 0 : disputeProject.clientDocumentLinks) === null || _b === void 0 ? void 0 : _b.split(',');
108
+ const [uploadingFile, setUploadingFile] = (0, react_1.useState)(false);
107
109
  const fileInputRef = (0, react_1.useRef)(null);
110
+ const handleDownloadPdf = ({ fileData, downloadFilename, streamData }) => {
111
+ var _a, _b;
112
+ let byteArray = streamData ? fileData : new Uint8Array();
113
+ if (!streamData) {
114
+ 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);
115
+ const byteNumbers = new Array(byteCharacters.length);
116
+ for (let i = 0; i < byteCharacters.length; i++) {
117
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
118
+ }
119
+ byteArray = new Uint8Array(byteNumbers);
120
+ }
121
+ const blob = new Blob([byteArray], { type: 'application/pdf' });
122
+ const blobUrl = URL.createObjectURL(blob);
123
+ const newTab = window.open(blobUrl, '_blank');
124
+ const downloadLink = document.createElement('a');
125
+ downloadLink.href = blobUrl;
126
+ downloadLink.download = downloadFilename;
127
+ document.body.appendChild(downloadLink);
128
+ downloadLink.click();
129
+ document.body.removeChild(downloadLink);
130
+ URL.revokeObjectURL(blobUrl);
131
+ if (newTab) {
132
+ newTab.focus();
133
+ }
134
+ };
135
+ const handleDownloadDocument = (projectId, fileName) => __awaiter(void 0, void 0, void 0, function* () {
136
+ const downloadFileName = `project-${projectId}/${fileName}`;
137
+ const downloadClient = new DownloadClient_1.default({ downloadDocumentUrl: downloadDocumentUrl, fileKey: downloadFileName });
138
+ const downloadData = yield downloadClient.downloadDocument();
139
+ handleDownloadPdf({ fileData: downloadData, downloadFilename: fileName, streamData: true });
140
+ });
108
141
  (0, react_1.useEffect)(() => {
109
142
  if (JSON.stringify(clientInvoice === null || clientInvoice === void 0 ? void 0 : clientInvoice.disputeProjects) !== JSON.stringify(projects)) {
110
143
  setUpdateDispute(true);
@@ -119,55 +152,70 @@ const ClientDisputeProjectCard = ({ clientInvoice, updateClientInvoiceDisputeMut
119
152
  setEditingRowId(null);
120
153
  });
121
154
  const handleChange = (e, field) => {
122
- const updatedProject = field === "clientDocumentLinks" ? projects.map((project) => {
123
- if (project.projectId === expandRow) {
124
- return Object.assign(Object.assign({}, project), { clientDocumentLinks: [...project.clientDocumentLinks, ...e.filter((name) => !project.clientDocumentLinks.includes(name))] });
125
- }
126
- return project;
127
- }) : projects.map((project) => {
155
+ const updatedProject = projects.map((project) => {
128
156
  return Object.assign(Object.assign({}, project), { [field]: e.target.value });
129
157
  });
130
158
  setProjects(updatedProject);
131
159
  };
132
- const handleUpload = (event) => {
160
+ const handleUpload = (event) => __awaiter(void 0, void 0, void 0, function* () {
161
+ setUploadingFile(true);
133
162
  const selectedFiles = event.target.files;
134
163
  if (!selectedFiles)
135
164
  return;
136
- const validFiles = Array.from(selectedFiles)
165
+ const validFileNames = Array.from(selectedFiles)
137
166
  .filter(file => validateFileUpload(file))
138
167
  .map(file => file.name);
139
- if (validFiles.length === 0)
168
+ if (validFileNames.length === 0)
140
169
  return;
141
- if (validFiles && validFiles.length > 0) {
142
- Array.from(selectedFiles).forEach((selectedFile) => {
143
- const reader = new FileReader();
144
- reader.onloadend = () => __awaiter(void 0, void 0, void 0, function* () {
145
- var _a, _b;
146
- yield (0, FileUploader_1.fileUploader)({
147
- file: selectedFile,
148
- documentName: selectedFile.name,
149
- projectId: Number((_b = (_a = clientInvoice === null || clientInvoice === void 0 ? void 0 : clientInvoice.disputeProjects) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.projectId),
150
- documentUploadUrl: documentUploadUrl,
151
- updateClientInvoiceDisputeMutation: updateClientInvoiceDisputeMutation,
152
- previousFiles: clientDocumentLinks,
153
- isExpert: false,
170
+ if (validFileNames && validFileNames.length > 0) {
171
+ const uploadPromises = Array.from(selectedFiles).map((selectedFile) => {
172
+ return new Promise((resolve, reject) => {
173
+ const reader = new FileReader();
174
+ reader.onloadend = () => __awaiter(void 0, void 0, void 0, function* () {
175
+ var _a, _b, _c, _d, _e;
176
+ try {
177
+ yield (0, FileUploader_1.fileUploader)({
178
+ file: selectedFile,
179
+ documentName: selectedFile.name,
180
+ disputeId: clientInvoice.disputeId,
181
+ projectId: Number((_b = (_a = clientInvoice === null || clientInvoice === void 0 ? void 0 : clientInvoice.disputeProjects) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.projectId),
182
+ documentUploadUrl: documentUploadUrl,
183
+ updateClientInvoiceDisputeMutation: updateClientInvoiceDisputeMutation,
184
+ previousFiles: (_e = (_d = (_c = clientInvoice === null || clientInvoice === void 0 ? void 0 : clientInvoice.disputeProjects) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.clientDocumentLinks) !== null && _e !== void 0 ? _e : [],
185
+ isExpert: false,
186
+ }).then(() => {
187
+ refetchInvoiceDisputes();
188
+ });
189
+ resolve();
190
+ }
191
+ catch (error) {
192
+ reject(error);
193
+ }
154
194
  });
195
+ reader.readAsDataURL(selectedFile);
155
196
  });
156
- reader.readAsDataURL(selectedFile);
157
197
  });
198
+ try {
199
+ yield Promise.all(uploadPromises);
200
+ }
201
+ catch (error) {
202
+ console.error('Error uploading files:', error);
203
+ }
204
+ finally {
205
+ setUploadingFile(false);
206
+ }
158
207
  }
159
- handleChange(validFiles, "clientDocumentLinks");
160
208
  if (fileInputRef.current) {
161
- fileInputRef.current.value = '';
209
+ fileInputRef.current.value = ''; // Reset the file input
162
210
  }
163
- };
211
+ });
164
212
  const handleSubmitDispute = () => __awaiter(void 0, void 0, void 0, function* () {
165
213
  setUpdatingDispute(true);
166
214
  try {
167
215
  yield updateClientInvoiceDisputeMutation({
168
216
  variables: {
169
217
  input: {
170
- disputeId: projects[0].id,
218
+ disputeId: clientInvoice.disputeId,
171
219
  projectDisputes: projects.map((project) => ({
172
220
  projectId: project.projectId,
173
221
  disputeReasonCode: project.disputeReasonCode,
@@ -179,6 +227,8 @@ const ClientDisputeProjectCard = ({ clientInvoice, updateClientInvoiceDisputeMut
179
227
  })),
180
228
  }
181
229
  }
230
+ }).then(() => {
231
+ refetchInvoiceDisputes();
182
232
  });
183
233
  }
184
234
  catch (error) {
@@ -198,41 +248,42 @@ const ClientDisputeProjectCard = ({ clientInvoice, updateClientInvoiceDisputeMut
198
248
  }),
199
249
  react_1.default.createElement(core_1.TableCell, { className: classes.tableCell }))), projects === null || projects === void 0 ? void 0 :
200
250
  projects.map((row) => {
201
- var _a;
202
- return (react_1.default.createElement(react_1.default.Fragment, { key: row.projectId },
251
+ var _a, _b;
252
+ return (react_1.default.createElement(react_1.default.Fragment, { key: row === null || row === void 0 ? void 0 : row.projectId },
203
253
  react_1.default.createElement(core_1.TableRow, null,
204
- react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, ((_a = row.project) === null || _a === void 0 ? void 0 : _a.name) || "N/A"),
205
- react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, row.disputeType),
206
- react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, row.disputeHours),
207
- react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, row.disputeAmount),
208
- react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, row.disputeReasonCode),
254
+ react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, ((_a = row === null || row === void 0 ? void 0 : row.project) === null || _a === void 0 ? void 0 : _a.name) || "N/A"),
255
+ react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, row === null || row === void 0 ? void 0 : row.disputeType),
256
+ react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, row === null || row === void 0 ? void 0 : row.disputeHours),
257
+ react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, row === null || row === void 0 ? void 0 : row.disputeAmount),
258
+ react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell }, row === null || row === void 0 ? void 0 : row.disputeReasonCode),
209
259
  react_1.default.createElement(core_1.TableCell, { align: "left", className: classes.tableCell },
210
- react_1.default.createElement(core_1.IconButton, { onClick: () => setExpandRow(expandRow === row.projectId ? null : row.projectId) }, expandRow === row.projectId ? react_1.default.createElement(base_icons_1.IconChevronUp, null) : react_1.default.createElement(base_icons_1.IconChevronDown, null)))),
211
- expandRow === row.projectId && (react_1.default.createElement(core_1.TableRow, { key: `expanded-${row.projectId}` },
260
+ react_1.default.createElement(core_1.IconButton, { onClick: () => setExpandRow(expandRow === (row === null || row === void 0 ? void 0 : row.projectId) ? null : row === null || row === void 0 ? void 0 : row.projectId) }, expandRow === (row === null || row === void 0 ? void 0 : row.projectId) ? react_1.default.createElement(base_icons_1.IconChevronUp, null) : react_1.default.createElement(base_icons_1.IconChevronDown, null)))),
261
+ expandRow === (row === null || row === void 0 ? void 0 : row.projectId) && (react_1.default.createElement(core_1.TableRow, { key: `expanded-${row === null || row === void 0 ? void 0 : row.projectId}` },
212
262
  react_1.default.createElement(core_1.TableCell, { colSpan: headCells.length + 1, style: { paddingBottom: 0, paddingTop: 0 } },
213
263
  react_1.default.createElement(core_1.Collapse, { in: true, timeout: "auto", unmountOnExit: true },
214
264
  react_1.default.createElement(react_1.default.Fragment, null,
215
265
  react_1.default.createElement(base_ui_1.Card, { className: "bg-[#F8F9FA] m-2 flex items-start justify-between rounded flex-col w-full p-6" },
216
266
  react_1.default.createElement("b", { className: "mb-2 flex flex-row justify-start items-center" },
217
267
  "Explanation:",
218
- editingRowId === row.projectId ? (react_1.default.createElement(react_1.default.Fragment, null,
268
+ editingRowId === (row === null || row === void 0 ? void 0 : row.projectId) ? (react_1.default.createElement(react_1.default.Fragment, null,
219
269
  react_1.default.createElement(base_ui_2.Input, { label: "", type: "text", className: "w-96 mx-4 overflow-ellipsis", value: editedExplanation, onChange: (e) => setEditedExplanation(e.target.value), placeholder: "Please provide an explanation", isInvalid: !editedExplanation, isInvalidText: "Please provide an explanation" }),
220
- react_1.default.createElement(base_ui_2.Button, { label: "Save", size: "md", color: "success", className: "ml-2 mt-1", onClick: () => { handleEditExplanation(row.projectId); } }))) : (react_1.default.createElement(base_ui_2.Button, { label: "Edit", iconLeft: react_1.default.createElement(base_icons_1.IconPencil, { size: "sm" }), onClick: () => {
221
- setEditedExplanation(row.clientExplanation);
222
- setEditingRowId(row.projectId);
223
- }, size: "sm", color: "info", className: "ml-6" }))),
224
- react_1.default.createElement("p", null, row.clientExplanation),
270
+ react_1.default.createElement(base_ui_2.Button, { label: "Save", size: "md", color: "success", className: "ml-1 mt-1", onClick: () => { handleEditExplanation(row === null || row === void 0 ? void 0 : row.projectId); } }))) : (react_1.default.createElement(react_1.default.Fragment, null,
271
+ react_1.default.createElement("span", { className: "font-normal mx-1" }, row === null || row === void 0 ? void 0 : row.clientExplanation),
272
+ react_1.default.createElement(core_1.Tooltip, { title: "Edit explanation", placement: "top", arrow: true },
273
+ react_1.default.createElement(core_1.IconButton, { onClick: () => {
274
+ setEditedExplanation(row === null || row === void 0 ? void 0 : row.clientExplanation);
275
+ setEditingRowId(row === null || row === void 0 ? void 0 : row.projectId);
276
+ } },
277
+ react_1.default.createElement(base_icons_1.IconPencil, { size: "sm" })))))),
225
278
  react_1.default.createElement("b", { className: "flex flex-row flex-wrap justify-start items-center mt-2" },
226
279
  "Supporting Documents:",
227
- react_1.default.createElement("input", { id: "upload-file", type: "file", multiple: true, accept: ".pdf,.doc,.docx,.jpeg,.png,.gif,.csv", style: { display: 'none' }, ref: fileInputRef, onChange: handleUpload }),
228
- react_1.default.createElement(base_ui_2.Button, { label: "Add File", iconLeft: react_1.default.createElement(base_icons_1.IconPlus, { size: "sm" }), onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, size: "sm", color: "info", className: "mx-2" }),
229
- (Array.isArray(row.clientDocumentLinks)
230
- ? row.clientDocumentLinks
231
- : []).map((f, index) => (react_1.default.createElement("div", { key: index, className: "mx-2" },
232
- react_1.default.createElement(base_ui_1.Tag, { variant: "subtle", color: "success", label: f, iconRight: react_1.default.createElement(base_icons_1.IconXCircle, null), onClick: () => {
233
- const updatedProjects = projects.map((p) => p.projectId === row.projectId
234
- ? Object.assign(Object.assign({}, p), { clientDocumentLinks: p.clientDocumentLinks.filter((file) => file !== f) }) : p);
235
- setProjects(updatedProjects);
280
+ react_1.default.createElement("input", { id: "upload-file", type: "file", multiple: false, accept: ".pdf,.doc,.docx,.jpeg,.png,.gif,.csv", style: { display: 'none' }, ref: fileInputRef, onChange: handleUpload }),
281
+ react_1.default.createElement(base_ui_2.Button, { label: "Add File", iconLeft: react_1.default.createElement(base_icons_1.IconPlus, { size: "sm" }), onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, size: "sm", color: "info", className: "mx-2", isLoading: uploadingFile }),
282
+ ((row === null || row === void 0 ? void 0 : row.clientDocumentLinks)
283
+ ? (typeof (row === null || row === void 0 ? void 0 : row.clientDocumentLinks) === 'string' ? (_b = row === null || row === void 0 ? void 0 : row.clientDocumentLinks) === null || _b === void 0 ? void 0 : _b.split(',') : [...row === null || row === void 0 ? void 0 : row.clientDocumentLinks])
284
+ : []).map((f, index) => (react_1.default.createElement("div", { key: index, className: "m-1" },
285
+ react_1.default.createElement(base_ui_1.Tag, { variant: "subtle", color: "success", label: f.split('%2F')[1], iconRight: react_1.default.createElement(base_icons_1.IconXCircle, null), onClick: () => {
286
+ handleDownloadDocument(row === null || row === void 0 ? void 0 : row.projectId, f.split('%2F')[1]);
236
287
  } })))))))))))));
237
288
  })),
238
289
  updatedDispute && react_1.default.createElement("div", { className: "flex justify-end ml-auto mt-2" },
@@ -5,7 +5,9 @@ interface InvoiceCardProps {
5
5
  chatMessages: any[];
6
6
  updateClientInvoiceDisputeMutation: any;
7
7
  documentUploadUrl: string;
8
+ downloadDocumentUrl: string;
8
9
  isInternal?: boolean;
10
+ refetchInvoiceDisputes: any;
9
11
  }
10
- export declare const InvoiceCard: ({ clientInvoice, createDisputeChatMessage, user, chatMessages, updateClientInvoiceDisputeMutation, documentUploadUrl, isInternal, }: InvoiceCardProps) => JSX.Element;
12
+ export declare const InvoiceCard: ({ clientInvoice, createDisputeChatMessage, user, chatMessages, updateClientInvoiceDisputeMutation, documentUploadUrl, downloadDocumentUrl, isInternal, refetchInvoiceDisputes, }: InvoiceCardProps) => JSX.Element;
11
13
  export {};
@@ -12,7 +12,7 @@ const DisputeSection_1 = require("./DisputeSection");
12
12
  const DiscussionSection_1 = require("./DiscussionSection");
13
13
  const DecisionSection_1 = require("./DecisionSection");
14
14
  const ClientDisputeProjectCard_1 = require("./ClientDisputeProjectCard");
15
- const InvoiceCard = ({ clientInvoice, createDisputeChatMessage, user, chatMessages, updateClientInvoiceDisputeMutation, documentUploadUrl, isInternal = false, }) => {
15
+ const InvoiceCard = ({ clientInvoice, createDisputeChatMessage, user, chatMessages, updateClientInvoiceDisputeMutation, documentUploadUrl, downloadDocumentUrl, isInternal = false, refetchInvoiceDisputes, }) => {
16
16
  var _a, _b;
17
17
  return (react_1.default.createElement(base_ui_1.Card, { className: "w-full bg-white rounded-lg shadow-sm overflow-hidden mb-4" },
18
18
  react_1.default.createElement(InvoiceHeader_1.InvoiceHeader, { invoice: clientInvoice }),
@@ -21,7 +21,7 @@ const InvoiceCard = ({ clientInvoice, createDisputeChatMessage, user, chatMessag
21
21
  isInternal ?
22
22
  react_1.default.createElement(DisputeSection_1.DisputeSection, { dispute: clientInvoice, documentUploadUrl: documentUploadUrl, updateClientInvoiceDisputeMutation: updateClientInvoiceDisputeMutation })
23
23
  :
24
- react_1.default.createElement(ClientDisputeProjectCard_1.ClientDisputeProjectCard, { clientInvoice: clientInvoice, updateClientInvoiceDisputeMutation: updateClientInvoiceDisputeMutation, documentUploadUrl: documentUploadUrl }),
24
+ react_1.default.createElement(ClientDisputeProjectCard_1.ClientDisputeProjectCard, { clientInvoice: clientInvoice, updateClientInvoiceDisputeMutation: updateClientInvoiceDisputeMutation, documentUploadUrl: documentUploadUrl, downloadDocumentUrl: downloadDocumentUrl, refetchInvoiceDisputes: refetchInvoiceDisputes }),
25
25
  (clientInvoice === null || clientInvoice === void 0 ? void 0 : clientInvoice.chatEnabled) && (react_1.default.createElement(DiscussionSection_1.DiscussionSection, { disputeId: (_b = (_a = clientInvoice === null || clientInvoice === void 0 ? void 0 : clientInvoice.disputeProjects) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id, currentUser: user, messages: chatMessages, onCreateMessage: createDisputeChatMessage, isInternal: isInternal })),
26
26
  isInternal &&
27
27
  react_1.default.createElement(DecisionSection_1.DecisionSection, { dispute: clientInvoice, onUpdateDispute: updateClientInvoiceDisputeMutation }))));
@@ -45,6 +45,11 @@ class UploadClient {
45
45
  },
46
46
  body: JSON.stringify(params),
47
47
  });
48
+ if (!response.ok) {
49
+ const errorText = yield response.text(); // Read the response body as text (could be HTML)
50
+ console.error('Error response:', errorText);
51
+ throw new Error('Failed to start multipart upload');
52
+ }
48
53
  let { responseData } = yield response.json();
49
54
  this.state = Object.assign(Object.assign({}, this.state), { uploadId: responseData === null || responseData === void 0 ? void 0 : responseData.UploadId });
50
55
  return this.uploadMultiPartFile();
@@ -71,6 +76,11 @@ class UploadClient {
71
76
  method: 'POST',
72
77
  body: JSON.stringify({ fileName: this.state.fileName, uploadId: this.state.uploadId, partNumber: index, method: 'get-presigned-url', bucketName: this.state.bucketName }),
73
78
  });
79
+ if (!presignedUrlResponse.ok) {
80
+ const errorText = yield presignedUrlResponse.text();
81
+ console.error('Error getting presigned URL:', errorText);
82
+ throw new Error('Failed to get presigned URL');
83
+ }
74
84
  const { responseData } = yield presignedUrlResponse.json();
75
85
  // Add each upload part to promise array using presigned URL
76
86
  let uploadResponse = fetch(responseData, {
@@ -104,6 +114,11 @@ class UploadClient {
104
114
  },
105
115
  body: JSON.stringify({ fileName: this.state.fileName, uploadId: this.state.uploadId, parts: partsArray, method: 'complete-upload', bucketName: this.state.bucketName }),
106
116
  });
117
+ if (!response.ok) {
118
+ const errorText = yield response.text();
119
+ console.error('Error completing upload:', errorText);
120
+ throw new Error('Failed to complete multipart upload');
121
+ }
107
122
  const { responseData } = yield response.json();
108
123
  console.log('Upload Complete', responseData);
109
124
  return `${JSON.stringify(responseData)}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paro.io/expert-shared-components",
3
- "version": "1.11.9",
3
+ "version": "1.12.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {