UNPKG

@tsc_tech/medusa-plugin-notification-template

Version:
39 lines (38 loc) 1.18 kB
import { jsxs, jsx } from "react/jsx-runtime"; import { Form } from "react-hook-form"; import { memo } from "react"; import { Button } from "@medusajs/ui"; import GenerateFormFields from "./GenerateFormFields.js"; const DynamicForm = ({ form, onSubmit, onReset, schema, isPending }) => { return /* @__PURE__ */ jsxs( Form, { control: form.control, onSubmit: form.handleSubmit(onSubmit), className: "flex w-full flex-col gap-y-3", style: { flex: 2 }, children: [ /* @__PURE__ */ jsx(GenerateFormFields, { form, schema }), /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [ /* @__PURE__ */ jsx(Button, { type: "submit", disabled: isPending, children: isPending ? "Submitting..." : "Submit" }), onReset && /* @__PURE__ */ jsx( Button, { type: "button", variant: "secondary", disabled: isPending, onClick: onReset, children: "Reset" } ) ] }) ] } ); }; const DynamicForm$1 = memo(DynamicForm); export { DynamicForm$1 as default };