@empty-complete-org/medusa-product-attributes 0.12.1 → 0.12.2

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.
@@ -291,14 +291,28 @@ const ProductAttributeValuesWidget = ({
291
291
  try {
292
292
  const formData = new FormData();
293
293
  formData.append("files", file);
294
- const res = await sdk.client.fetch(`/admin/uploads`, {
294
+ const response = await fetch(`/admin/uploads`, {
295
295
  method: "POST",
296
+ credentials: "include",
296
297
  body: formData
297
298
  });
299
+ if (!response.ok) {
300
+ const text = await response.text();
301
+ console.error("Upload failed", response.status, text);
302
+ alert(`Ошибка загрузки файла: ${response.status}`);
303
+ return;
304
+ }
305
+ const res = await response.json();
298
306
  const url = (_b2 = (_a2 = res == null ? void 0 : res.files) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.url;
299
307
  if (url) {
300
308
  setFormValues((prev) => ({ ...prev, [attrId]: url }));
309
+ } else {
310
+ console.error("No URL in upload response", res);
311
+ alert("Файл загружен, но URL не получен");
301
312
  }
313
+ } catch (err) {
314
+ console.error("Upload error", err);
315
+ alert("Ошибка загрузки файла");
302
316
  } finally {
303
317
  setUploadingId(null);
304
318
  }
@@ -288,14 +288,28 @@ const ProductAttributeValuesWidget = ({
288
288
  try {
289
289
  const formData = new FormData();
290
290
  formData.append("files", file);
291
- const res = await sdk.client.fetch(`/admin/uploads`, {
291
+ const response = await fetch(`/admin/uploads`, {
292
292
  method: "POST",
293
+ credentials: "include",
293
294
  body: formData
294
295
  });
296
+ if (!response.ok) {
297
+ const text = await response.text();
298
+ console.error("Upload failed", response.status, text);
299
+ alert(`Ошибка загрузки файла: ${response.status}`);
300
+ return;
301
+ }
302
+ const res = await response.json();
295
303
  const url = (_b2 = (_a2 = res == null ? void 0 : res.files) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.url;
296
304
  if (url) {
297
305
  setFormValues((prev) => ({ ...prev, [attrId]: url }));
306
+ } else {
307
+ console.error("No URL in upload response", res);
308
+ alert("Файл загружен, но URL не получен");
298
309
  }
310
+ } catch (err) {
311
+ console.error("Upload error", err);
312
+ alert("Ошибка загрузки файла");
299
313
  } finally {
300
314
  setUploadingId(null);
301
315
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empty-complete-org/medusa-product-attributes",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "Custom attributes module for Medusa v2 with support for text, number, file types and units of measurement",
5
5
  "author": "empty-complete",
6
6
  "license": "MIT",
@@ -83,4 +83,4 @@
83
83
  "publishConfig": {
84
84
  "registry": "https://registry.npmjs.org"
85
85
  }
86
- }
86
+ }