@lodashventure/medusa-banner 1.4.0 → 1.4.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.
|
@@ -8,7 +8,6 @@ const ui = require("@medusajs/ui");
|
|
|
8
8
|
const lucideReact = require("lucide-react");
|
|
9
9
|
const react = require("react");
|
|
10
10
|
const Medusa = require("@medusajs/js-sdk");
|
|
11
|
-
const reactQuery = require("@tanstack/react-query");
|
|
12
11
|
const utilities = require("@dnd-kit/utilities");
|
|
13
12
|
const reactDropzone = require("react-dropzone");
|
|
14
13
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
@@ -21,19 +20,38 @@ const sdk = new Medusa__default.default({
|
|
|
21
20
|
}
|
|
22
21
|
});
|
|
23
22
|
const useBanners = () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const [data, setData] = react.useState(null);
|
|
24
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
25
|
+
const [error, setError] = react.useState(null);
|
|
26
|
+
const fetchBanners = async () => {
|
|
27
|
+
setIsLoading(true);
|
|
28
|
+
setError(null);
|
|
29
|
+
try {
|
|
27
30
|
const response = await sdk.client.fetch(
|
|
28
31
|
"/admin/banners",
|
|
29
32
|
{
|
|
30
33
|
method: "GET"
|
|
31
34
|
}
|
|
32
35
|
);
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
setData(response ?? { banners: [], count: 0 });
|
|
37
|
+
} catch (err) {
|
|
38
|
+
setError(
|
|
39
|
+
err instanceof Error ? err : new Error("Failed to fetch banners")
|
|
40
|
+
);
|
|
41
|
+
setData({ banners: [], count: 0 });
|
|
42
|
+
} finally {
|
|
43
|
+
setIsLoading(false);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
react.useEffect(() => {
|
|
47
|
+
fetchBanners();
|
|
48
|
+
}, []);
|
|
49
|
+
return {
|
|
50
|
+
data,
|
|
51
|
+
isLoading,
|
|
52
|
+
error,
|
|
53
|
+
refetch: fetchBanners
|
|
54
|
+
};
|
|
37
55
|
};
|
|
38
56
|
const DraggableItem = ({ banner }) => {
|
|
39
57
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg shadow-md border border-gray-200 dark:border-gray-700 opacity-80 scale-105 bg-white dark:bg-gray-800", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
@@ -871,11 +889,13 @@ const formModule = { customFields: {} };
|
|
|
871
889
|
const displayModule = {
|
|
872
890
|
displays: {}
|
|
873
891
|
};
|
|
892
|
+
const i18nModule = { resources: {} };
|
|
874
893
|
const plugin = {
|
|
875
894
|
widgetModule,
|
|
876
895
|
routeModule,
|
|
877
896
|
menuItemModule,
|
|
878
897
|
formModule,
|
|
879
|
-
displayModule
|
|
898
|
+
displayModule,
|
|
899
|
+
i18nModule
|
|
880
900
|
};
|
|
881
901
|
module.exports = plugin;
|
|
@@ -5,9 +5,8 @@ import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, close
|
|
|
5
5
|
import { useSortable, sortableKeyboardCoordinates, SortableContext, rectSortingStrategy, arrayMove } from "@dnd-kit/sortable";
|
|
6
6
|
import { Label, Input, Button, usePrompt, Drawer } from "@medusajs/ui";
|
|
7
7
|
import { Link, Check, Edit, Upload, ImageIcon, Trash, Trash2, MoveHorizontal, X } from "lucide-react";
|
|
8
|
-
import { useState, useCallback } from "react";
|
|
8
|
+
import { useState, useEffect, useCallback } from "react";
|
|
9
9
|
import Medusa from "@medusajs/js-sdk";
|
|
10
|
-
import { useQuery } from "@tanstack/react-query";
|
|
11
10
|
import { CSS } from "@dnd-kit/utilities";
|
|
12
11
|
import { useDropzone } from "react-dropzone";
|
|
13
12
|
const sdk = new Medusa({
|
|
@@ -18,19 +17,38 @@ const sdk = new Medusa({
|
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
19
|
const useBanners = () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const [data, setData] = useState(null);
|
|
21
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
22
|
+
const [error, setError] = useState(null);
|
|
23
|
+
const fetchBanners = async () => {
|
|
24
|
+
setIsLoading(true);
|
|
25
|
+
setError(null);
|
|
26
|
+
try {
|
|
24
27
|
const response = await sdk.client.fetch(
|
|
25
28
|
"/admin/banners",
|
|
26
29
|
{
|
|
27
30
|
method: "GET"
|
|
28
31
|
}
|
|
29
32
|
);
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
setData(response ?? { banners: [], count: 0 });
|
|
34
|
+
} catch (err) {
|
|
35
|
+
setError(
|
|
36
|
+
err instanceof Error ? err : new Error("Failed to fetch banners")
|
|
37
|
+
);
|
|
38
|
+
setData({ banners: [], count: 0 });
|
|
39
|
+
} finally {
|
|
40
|
+
setIsLoading(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
fetchBanners();
|
|
45
|
+
}, []);
|
|
46
|
+
return {
|
|
47
|
+
data,
|
|
48
|
+
isLoading,
|
|
49
|
+
error,
|
|
50
|
+
refetch: fetchBanners
|
|
51
|
+
};
|
|
34
52
|
};
|
|
35
53
|
const DraggableItem = ({ banner }) => {
|
|
36
54
|
return /* @__PURE__ */ jsx("div", { className: "rounded-lg shadow-md border border-gray-200 dark:border-gray-700 opacity-80 scale-105 bg-white dark:bg-gray-800", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -868,12 +886,14 @@ const formModule = { customFields: {} };
|
|
|
868
886
|
const displayModule = {
|
|
869
887
|
displays: {}
|
|
870
888
|
};
|
|
889
|
+
const i18nModule = { resources: {} };
|
|
871
890
|
const plugin = {
|
|
872
891
|
widgetModule,
|
|
873
892
|
routeModule,
|
|
874
893
|
menuItemModule,
|
|
875
894
|
formModule,
|
|
876
|
-
displayModule
|
|
895
|
+
displayModule,
|
|
896
|
+
i18nModule
|
|
877
897
|
};
|
|
878
898
|
export {
|
|
879
899
|
plugin as default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodashventure/medusa-banner",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "A starter for Medusa plugins.",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"prepublishOnly": "medusa plugin:build"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@medusajs/admin-sdk": "2.11.
|
|
33
|
-
"@medusajs/cli": "2.11.
|
|
34
|
-
"@medusajs/framework": "2.11.
|
|
35
|
-
"@medusajs/icons": "^2.11.
|
|
36
|
-
"@medusajs/medusa": "2.11.
|
|
37
|
-
"@medusajs/test-utils": "2.11.
|
|
32
|
+
"@medusajs/admin-sdk": "2.11.1",
|
|
33
|
+
"@medusajs/cli": "2.11.1",
|
|
34
|
+
"@medusajs/framework": "2.11.1",
|
|
35
|
+
"@medusajs/icons": "^2.11.1",
|
|
36
|
+
"@medusajs/medusa": "2.11.1",
|
|
37
|
+
"@medusajs/test-utils": "2.11.1",
|
|
38
38
|
"@medusajs/ui": "4.0.4",
|
|
39
39
|
"@swc/core": "1.5.7",
|
|
40
40
|
"@types/multer": "^1.4.12",
|
|
@@ -50,14 +50,13 @@
|
|
|
50
50
|
"yalc": "^1.0.0-pre.53"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@medusajs/admin-sdk": "2.11.
|
|
54
|
-
"@medusajs/cli": "2.11.
|
|
55
|
-
"@medusajs/framework": "2.11.
|
|
56
|
-
"@medusajs/icons": "^2.11.
|
|
57
|
-
"@medusajs/medusa": "2.11.
|
|
58
|
-
"@medusajs/test-utils": "2.11.
|
|
59
|
-
"@medusajs/ui": "4.0.3"
|
|
60
|
-
"@tanstack/react-query": "*"
|
|
53
|
+
"@medusajs/admin-sdk": "2.11.1",
|
|
54
|
+
"@medusajs/cli": "2.11.1",
|
|
55
|
+
"@medusajs/framework": "2.11.1",
|
|
56
|
+
"@medusajs/icons": "^2.11.1",
|
|
57
|
+
"@medusajs/medusa": "2.11.1",
|
|
58
|
+
"@medusajs/test-utils": "2.11.1",
|
|
59
|
+
"@medusajs/ui": "4.0.3"
|
|
61
60
|
},
|
|
62
61
|
"engines": {
|
|
63
62
|
"node": ">=20"
|