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