@algorithm-shift/design-system 1.2.987 → 1.2.989
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.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -350,12 +350,17 @@ function useFileService(options) {
|
|
|
350
350
|
formData.append(key, value);
|
|
351
351
|
});
|
|
352
352
|
const axiosClient = options.axiosInstance ?? axios;
|
|
353
|
-
const apiUrl = "/fileservice/upload";
|
|
353
|
+
const apiUrl = options.apiUrl ?? "/fileservice/upload";
|
|
354
354
|
const result = await axiosClient.post(`${apiUrl}`, formData, {
|
|
355
355
|
withCredentials: true
|
|
356
356
|
});
|
|
357
357
|
setData(result);
|
|
358
|
-
|
|
358
|
+
if (result.status === 200) {
|
|
359
|
+
options?.onSuccess?.(result.data);
|
|
360
|
+
} else {
|
|
361
|
+
const err = new Error(`Fetch failed with status ${result.status}`);
|
|
362
|
+
throw err;
|
|
363
|
+
}
|
|
359
364
|
return result;
|
|
360
365
|
} catch (err) {
|
|
361
366
|
setError(err);
|
|
@@ -375,7 +380,12 @@ function useFileService(options) {
|
|
|
375
380
|
withCredentials: true
|
|
376
381
|
});
|
|
377
382
|
setData(result);
|
|
378
|
-
|
|
383
|
+
if (result.status === 200) {
|
|
384
|
+
options?.onSuccess?.(result.data);
|
|
385
|
+
} else {
|
|
386
|
+
const err = new Error(`Fetch failed with status ${result.status}`);
|
|
387
|
+
throw err;
|
|
388
|
+
}
|
|
379
389
|
return result;
|
|
380
390
|
} catch (err) {
|
|
381
391
|
setError(err);
|
|
@@ -395,7 +405,12 @@ function useFileService(options) {
|
|
|
395
405
|
withCredentials: true
|
|
396
406
|
});
|
|
397
407
|
setData(result);
|
|
398
|
-
|
|
408
|
+
if (result.status === 200) {
|
|
409
|
+
options?.onSuccess?.(result.data);
|
|
410
|
+
} else {
|
|
411
|
+
const err = new Error(`Fetch failed with status ${result.status}`);
|
|
412
|
+
throw err;
|
|
413
|
+
}
|
|
399
414
|
return result;
|
|
400
415
|
} catch (err) {
|
|
401
416
|
setError(err);
|
|
@@ -422,6 +437,7 @@ var ImageControl = ({
|
|
|
422
437
|
style,
|
|
423
438
|
imageUrl,
|
|
424
439
|
altText = "Preview",
|
|
440
|
+
apiUrl,
|
|
425
441
|
...props
|
|
426
442
|
}) => {
|
|
427
443
|
const defaultImgClass = cn(
|
|
@@ -438,8 +454,12 @@ var ImageControl = ({
|
|
|
438
454
|
};
|
|
439
455
|
const { uploadFile } = useFileService({
|
|
440
456
|
axiosInstance: props.axiosInstance,
|
|
457
|
+
apiUrl,
|
|
441
458
|
onSuccess: async (result) => {
|
|
442
|
-
if (!result?.data?.url && !props.onSuccess)
|
|
459
|
+
if (!result?.data?.url && !props.onSuccess) {
|
|
460
|
+
setLoader(false);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
443
463
|
props.onSuccess?.({ url: result.data.url || "", fileName: result.data.originalname || "" });
|
|
444
464
|
setLoader(false);
|
|
445
465
|
}
|
|
@@ -4791,6 +4811,7 @@ function showSonnerToast({
|
|
|
4791
4811
|
onAction
|
|
4792
4812
|
}) {
|
|
4793
4813
|
const options = {
|
|
4814
|
+
closeButton: true,
|
|
4794
4815
|
description,
|
|
4795
4816
|
duration,
|
|
4796
4817
|
action: actionLabel ? {
|