@lodashventure/medusa-brand 1.2.1 → 1.2.3

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.
@@ -36,6 +36,10 @@ const ProductBrandWidget = ({ data: product }) => {
36
36
  setBrands(data.brands || []);
37
37
  }
38
38
  } catch (err) {
39
+ if (err instanceof Medusa.FetchError && err.status === 404) {
40
+ setBrands([]);
41
+ return;
42
+ }
39
43
  console.error("Error fetching brands:", err);
40
44
  }
41
45
  };
@@ -56,6 +60,11 @@ const ProductBrandWidget = ({ data: product }) => {
56
60
  }
57
61
  }
58
62
  } catch (err) {
63
+ if (err instanceof Medusa.FetchError && err.status === 404) {
64
+ setCurrentBrand(null);
65
+ setSelectedBrandId("none");
66
+ return;
67
+ }
59
68
  console.error("Error fetching product brand:", err);
60
69
  }
61
70
  };
@@ -692,8 +701,13 @@ const BrandsPage = () => {
692
701
  setError("Failed to fetch brands");
693
702
  }
694
703
  } catch (err) {
695
- setError("Error fetching brands");
696
- console.error("Error fetching brands:", err);
704
+ if (err instanceof Medusa.FetchError && err.status === 404) {
705
+ setBrands([]);
706
+ setError(null);
707
+ } else {
708
+ setError("Error fetching brands");
709
+ console.error("Error fetching brands:", err);
710
+ }
697
711
  } finally {
698
712
  setLoading(false);
699
713
  }
@@ -962,11 +976,13 @@ const formModule = { customFields: {} };
962
976
  const displayModule = {
963
977
  displays: {}
964
978
  };
979
+ const i18nModule = { resources: {} };
965
980
  const plugin = {
966
981
  widgetModule,
967
982
  routeModule,
968
983
  menuItemModule,
969
984
  formModule,
970
- displayModule
985
+ displayModule,
986
+ i18nModule
971
987
  };
972
988
  module.exports = plugin;
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
3
- import Medusa from "@medusajs/js-sdk";
3
+ import Medusa, { FetchError } from "@medusajs/js-sdk";
4
4
  import { Container, Heading, Alert, Text, Button, Label, Select, Badge, Input, Textarea, Switch, clx, Table, DropdownMenu, IconButton } from "@medusajs/ui";
5
5
  import { BuildingStorefront, Trash, Link, X, CloudArrowUp, PhotoSolid, Plus, MagnifyingGlass, EllipsisHorizontal, PencilSquare } from "@medusajs/icons";
6
6
  import { useState, useEffect, useCallback } from "react";
@@ -33,6 +33,10 @@ const ProductBrandWidget = ({ data: product }) => {
33
33
  setBrands(data.brands || []);
34
34
  }
35
35
  } catch (err) {
36
+ if (err instanceof FetchError && err.status === 404) {
37
+ setBrands([]);
38
+ return;
39
+ }
36
40
  console.error("Error fetching brands:", err);
37
41
  }
38
42
  };
@@ -53,6 +57,11 @@ const ProductBrandWidget = ({ data: product }) => {
53
57
  }
54
58
  }
55
59
  } catch (err) {
60
+ if (err instanceof FetchError && err.status === 404) {
61
+ setCurrentBrand(null);
62
+ setSelectedBrandId("none");
63
+ return;
64
+ }
56
65
  console.error("Error fetching product brand:", err);
57
66
  }
58
67
  };
@@ -689,8 +698,13 @@ const BrandsPage = () => {
689
698
  setError("Failed to fetch brands");
690
699
  }
691
700
  } catch (err) {
692
- setError("Error fetching brands");
693
- console.error("Error fetching brands:", err);
701
+ if (err instanceof FetchError && err.status === 404) {
702
+ setBrands([]);
703
+ setError(null);
704
+ } else {
705
+ setError("Error fetching brands");
706
+ console.error("Error fetching brands:", err);
707
+ }
694
708
  } finally {
695
709
  setLoading(false);
696
710
  }
@@ -959,12 +973,14 @@ const formModule = { customFields: {} };
959
973
  const displayModule = {
960
974
  displays: {}
961
975
  };
976
+ const i18nModule = { resources: {} };
962
977
  const plugin = {
963
978
  widgetModule,
964
979
  routeModule,
965
980
  menuItemModule,
966
981
  formModule,
967
- displayModule
982
+ displayModule,
983
+ i18nModule
968
984
  };
969
985
  export {
970
986
  plugin as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodashventure/medusa-brand",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Brand management plugin for Medusa v2",
5
5
  "author": "Lodashventure",
6
6
  "license": "MIT",
@@ -11,7 +11,8 @@
11
11
  "ecommerce"
12
12
  ],
13
13
  "files": [
14
- ".medusa/server"
14
+ ".medusa/server",
15
+ "api"
15
16
  ],
16
17
  "exports": {
17
18
  "./package.json": "./package.json",
@@ -27,33 +28,38 @@
27
28
  "url": "https://github.com/lodashventure/medusa-brand"
28
29
  },
29
30
  "scripts": {
30
- "build": "medusa plugin:build",
31
- "dev": "medusa plugin:develop"
31
+ "build": "medusa plugin:build && node ./scripts/sync-api.js",
32
+ "dev": "medusa plugin:develop",
33
+ "sync:api": "node ./scripts/sync-api.js",
34
+ "prepublishOnly": "medusa plugin:build && node ./scripts/sync-api.js"
32
35
  },
33
36
  "dependencies": {
34
37
  "@google-cloud/storage": "^7.17.2",
35
- "@medusajs/admin-sdk": "*",
36
- "@medusajs/framework": "*",
37
- "@medusajs/icons": "*",
38
+ "@medusajs/admin-sdk": "2.11.1",
39
+ "@medusajs/framework": "2.11.1",
40
+ "@medusajs/icons": "2.11.1",
38
41
  "@medusajs/ui": "*"
39
42
  },
40
43
  "peerDependencies": {
41
- "@medusajs/admin-sdk": "*",
42
- "@medusajs/framework": "*",
43
- "@medusajs/icons": "*",
44
- "@medusajs/medusa": "*",
44
+ "@medusajs/admin-sdk": "2.11.1",
45
+ "@medusajs/framework": "2.11.1",
46
+ "@medusajs/icons": "2.11.1",
47
+ "@medusajs/medusa": "2.11.1",
45
48
  "@medusajs/ui": "*",
46
49
  "react": "^18.0.0",
47
50
  "react-dom": "^18.0.0"
48
51
  },
49
52
  "devDependencies": {
50
- "@medusajs/types": "*",
53
+ "@medusajs/cli": "^2.11.1",
54
+ "@medusajs/types": "2.11.1",
55
+ "@swc/core": "^1.14.0",
51
56
  "@types/multer": "^2.0.0",
52
57
  "@types/node": "^20.19.23",
53
58
  "@types/react": "^18.3.2",
54
59
  "@types/react-dom": "^18.2.25",
55
60
  "ts-node": "^10.9.2",
56
61
  "typescript": "^5.6.2",
62
+ "vite": "^7.1.12",
57
63
  "yalc": "1.0.0-pre.53"
58
64
  }
59
- }
65
+ }