@devx-commerce/strapi-x-custom-jw-mayave
Version:
Medusa plugin for Strapi as CMS - JW Mayave Custom Release
72 lines (71 loc) • 1.96 kB
JavaScript
"use strict";
const jsxRuntime = require("react/jsx-runtime");
const adminSdk = require("@medusajs/admin-sdk");
const ui = require("@medusajs/ui");
const reactQuery = require("@tanstack/react-query");
const Medusa = require("@medusajs/js-sdk");
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
const Medusa__default = /* @__PURE__ */ _interopDefault(Medusa);
const sdk = new Medusa__default.default({
// @ts-ignore
baseUrl: __BACKEND_URL__ || "/",
auth: {
type: "session"
}
});
const StrapiSettingsPage = () => {
const { mutate, isPending } = reactQuery.useMutation({
mutationFn: () => sdk.client.fetch("/admin/strapi/sync", {
method: "POST"
}),
onSuccess: () => {
ui.toast.success("Sync to Strapi triggered successfully");
}
});
return /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Strapi Settings" }) }),
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
ui.Button,
{
variant: "primary",
onClick: () => mutate(),
isLoading: isPending,
children: "Sync to Strapi"
}
) })
] }) });
};
const config = adminSdk.defineRouteConfig({
label: "Strapi"
});
const widgetModule = { widgets: [] };
const routeModule = {
routes: [
{
Component: StrapiSettingsPage,
path: "/strapi"
}
]
};
const menuItemModule = {
menuItems: [
{
label: config.label,
icon: void 0,
path: "/strapi",
nested: void 0
}
]
};
const formModule = { customFields: {} };
const displayModule = {
displays: {}
};
const plugin = {
widgetModule,
routeModule,
menuItemModule,
formModule,
displayModule
};
module.exports = plugin;