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