@visns-studio/visns-components 3.5.1 → 3.5.3

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.
@@ -157,6 +157,7 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
157
157
  };
158
158
 
159
159
  const handleFileDownload = async (d) => {
160
+ const toastId = toast.loading('Downloading file...'); // Show loading toast
160
161
  try {
161
162
  const res = await Download(setting.file, 'POST', {
162
163
  extension: d.extension,
@@ -166,12 +167,33 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
166
167
 
167
168
  if (res.data) {
168
169
  saveAs(res.data, d.filename);
170
+ toast.update(toastId, {
171
+ render: 'Download successful!',
172
+ type: 'success',
173
+ isLoading: false,
174
+ autoClose: 5000,
175
+ closeButton: true,
176
+ });
169
177
  } else {
170
- toast.error('Error downloading file');
178
+ // Update the toast to show an error message
179
+ toast.update(toastId, {
180
+ render: 'Error downloading form',
181
+ type: 'error',
182
+ isLoading: false,
183
+ autoClose: 5000,
184
+ closeButton: true,
185
+ });
171
186
  }
172
187
  } catch (err) {
173
188
  console.error(err);
174
- toast.error('Error downloading file');
189
+ // Update the toast to show an error message
190
+ toast.update(toastId, {
191
+ render: 'Error downloading form',
192
+ type: 'error',
193
+ isLoading: false,
194
+ autoClose: 5000,
195
+ closeButton: true,
196
+ });
175
197
  }
176
198
  };
177
199
 
@@ -220,6 +242,9 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
220
242
  };
221
243
 
222
244
  const handleDownloadForm = async (item, key) => {
245
+ // Show loading toast and keep its ID
246
+ const toastId = toast.loading('Downloading form...');
247
+
223
248
  try {
224
249
  const res = await Download(setting.download, 'POST', {
225
250
  data: item,
@@ -227,14 +252,39 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
227
252
  });
228
253
 
229
254
  if (res.data) {
230
- const fileName = slugify(label) + '.pdf';
231
- saveAs(res.data, fileName); // Use file-saver to save the file with a slugified label as the filename
255
+ // Update loading toast to a success message before closing it
256
+ toast.update(toastId, {
257
+ render: 'Download successful!',
258
+ type: 'success',
259
+ isLoading: false,
260
+ autoClose: 5000,
261
+ closeButton: true,
262
+ });
263
+ // Perform the download
264
+
265
+ // const fileName = slugify(label) + '.pdf';
266
+ // saveAs(res.data, fileName);
267
+ saveAs(res.data);
232
268
  } else {
233
- toast.error('Error downloading form');
269
+ // Update the toast to show an error message
270
+ toast.update(toastId, {
271
+ render: 'Error downloading form',
272
+ type: 'error',
273
+ isLoading: false,
274
+ autoClose: 5000,
275
+ closeButton: true,
276
+ });
234
277
  }
235
278
  } catch (err) {
236
279
  console.error(err);
237
- toast.error('Error downloading form');
280
+ // Update the toast to show an error message
281
+ toast.update(toastId, {
282
+ render: 'Error downloading form',
283
+ type: 'error',
284
+ isLoading: false,
285
+ autoClose: 5000,
286
+ closeButton: true,
287
+ });
238
288
  }
239
289
  };
240
290
 
package/package.json CHANGED
@@ -37,6 +37,7 @@
37
37
  "react-window": "^1.8.10",
38
38
  "reactjs-popup": "^2.0.6",
39
39
  "truncate": "^3.0.0",
40
+ "uuid": "^9.0.1",
40
41
  "validator": "^13.11.0",
41
42
  "yarn": "^1.22.21"
42
43
  },
@@ -49,7 +50,7 @@
49
50
  "react-dom": "^17.0.1"
50
51
  },
51
52
  "name": "@visns-studio/visns-components",
52
- "version": "3.5.1",
53
+ "version": "3.5.3",
53
54
  "description": "Various packages to assist in the development of our Custom Applications.",
54
55
  "main": "index.js",
55
56
  "scripts": {