UNPKG

@devx-commerce/strapi-x-custom-jw-mayave

Version:

Medusa plugin for Strapi as CMS - JW Mayave Custom Release

71 lines (70 loc) 1.73 kB
import { jsx, jsxs } from "react/jsx-runtime"; import { defineRouteConfig } from "@medusajs/admin-sdk"; import { toast, Container, Heading, Button } from "@medusajs/ui"; import { useMutation } from "@tanstack/react-query"; import Medusa from "@medusajs/js-sdk"; const sdk = new Medusa({ // @ts-ignore baseUrl: __BACKEND_URL__ || "/", auth: { type: "session" } }); const StrapiSettingsPage = () => { const { mutate, isPending } = useMutation({ mutationFn: () => sdk.client.fetch("/admin/strapi/sync", { method: "POST" }), onSuccess: () => { toast.success("Sync to Strapi triggered successfully"); } }); return /* @__PURE__ */ jsx(Container, { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Strapi Settings" }) }), /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx( Button, { variant: "primary", onClick: () => mutate(), isLoading: isPending, children: "Sync to Strapi" } ) }) ] }) }); }; const config = 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 }; export { plugin as default };