sales-frontend-components 0.0.147 → 0.0.149

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.cjs.js CHANGED
@@ -4427,12 +4427,19 @@ const useDownloader = () => {
4427
4427
  const [isLoading, setIsLoading] = React.useState(false);
4428
4428
  const downloadFile = async (url, fileName) => {
4429
4429
  try {
4430
- const response = await fetch(url);
4431
- if (!response.ok) {
4432
- throw new Error(`Failed to download ${url}`);
4430
+ let downloadUrl = "";
4431
+ if (url.startsWith("http")) {
4432
+ const response = await fetch(url);
4433
+ if (!response.ok) {
4434
+ throw new Error(`Failed to download ${url}`);
4435
+ }
4436
+ const blob = await response.blob();
4437
+ downloadUrl = window.URL.createObjectURL(blob);
4438
+ } else if (url.startsWith("blob")) {
4439
+ downloadUrl = url;
4440
+ } else {
4441
+ throw new Error(`unknown type : ${url}`);
4433
4442
  }
4434
- const blob = await response.blob();
4435
- const downloadUrl = window.URL.createObjectURL(blob);
4436
4443
  const a = document.createElement("a");
4437
4444
  a.href = downloadUrl;
4438
4445
  a.download = fileName || url.split("/").pop() || "download";