UNPKG

@rokmohar/medusa-plugin-meilisearch

Version:
63 lines (62 loc) 1.72 kB
import { jsx, jsxs } from "react/jsx-runtime"; import { toast, Container, Heading, Button } from "@medusajs/ui"; import { useMutation } from "@tanstack/react-query"; import { defineRouteConfig } from "@medusajs/admin-sdk"; const SyncPage = () => { const { mutate, isPending } = useMutation({ mutationFn: () => fetch("/admin/meilisearch/sync", { method: "POST" }), onSuccess: () => { toast.success("Successfully triggered data sync to Meilisearch"); }, onError: (err) => { console.error(err); toast.error("Failed to sync data to Meilisearch"); } }); const handleSync = () => { mutate(); }; return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [ /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Meilisearch Sync" }), /* @__PURE__ */ jsx("p", { className: "text-gray-500", children: "Manually trigger synchronization with Meilisearch." }), /* @__PURE__ */ jsx(Button, { onClick: handleSync, isLoading: isPending, variant: "primary", children: "Sync Now" }) ] }) }); }; const config = defineRouteConfig({ label: "Meilisearch" }); const widgetModule = { widgets: [] }; const routeModule = { routes: [ { Component: SyncPage, path: "/settings/meilisearch" } ] }; const menuItemModule = { menuItems: [ { label: config.label, icon: void 0, path: "/settings/meilisearch", nested: void 0 } ] }; const formModule = { customFields: {} }; const displayModule = { displays: {} }; const plugin = { widgetModule, routeModule, menuItemModule, formModule, displayModule }; export { plugin as default };