sales-frontend-components 0.0.187 → 0.0.188
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 +13 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +13 -20
- package/dist/index.esm.js.map +1 -1
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -144,6 +144,16 @@ var isClient = () => {
|
|
|
144
144
|
return false;
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
|
+
var getBusinessWorkDivisionCode = () => {
|
|
148
|
+
return location.pathname.split("/")[1] ?? "";
|
|
149
|
+
};
|
|
150
|
+
var getServicePath = () => {
|
|
151
|
+
if (typeof window.isStorybookEnv === "boolean") {
|
|
152
|
+
return "";
|
|
153
|
+
} else {
|
|
154
|
+
return `/${getBusinessWorkDivisionCode()}`;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
147
157
|
var isAndroidDevice = () => {
|
|
148
158
|
if (isClient() === false) {
|
|
149
159
|
return false;
|
|
@@ -4555,26 +4565,9 @@ const useDownloader = () => {
|
|
|
4555
4565
|
const [isLoading, setIsLoading] = useState(false);
|
|
4556
4566
|
const downloadFile = async (url, fileName) => {
|
|
4557
4567
|
try {
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
if (!response.ok) {
|
|
4562
|
-
throw new Error(`Failed to download ${url}`);
|
|
4563
|
-
}
|
|
4564
|
-
const blob = await response.blob();
|
|
4565
|
-
downloadUrl = window.URL.createObjectURL(blob);
|
|
4566
|
-
} else if (url.startsWith("blob")) {
|
|
4567
|
-
downloadUrl = url;
|
|
4568
|
-
} else {
|
|
4569
|
-
throw new Error(`unknown type : ${url}`);
|
|
4570
|
-
}
|
|
4571
|
-
const a = document.createElement("a");
|
|
4572
|
-
a.href = downloadUrl;
|
|
4573
|
-
a.download = fileName || url.split("/").pop() || "download";
|
|
4574
|
-
document.body.appendChild(a);
|
|
4575
|
-
a.click();
|
|
4576
|
-
a.remove();
|
|
4577
|
-
window.URL.revokeObjectURL(downloadUrl);
|
|
4568
|
+
const servicePath = getServicePath();
|
|
4569
|
+
const downloadUrl = `${servicePath}/internal/api/download?filename=${encodeURIComponent(fileName)}&filepath=${encodeURIComponent(url)}`;
|
|
4570
|
+
window.location.href = downloadUrl;
|
|
4578
4571
|
} catch (e) {
|
|
4579
4572
|
console.error(e);
|
|
4580
4573
|
throw e;
|