"use client";
import { jsx } from "react/jsx-runtime";
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
import { CrudForm } from "@open-mercato/ui/backend/CrudForm";
import { createCrud } from "@open-mercato/ui/backend/utils/crud";
import { useRouter } from "next/navigation";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { createFormGroups, createFieldDefinitions } from "../../../../components/formConfig.js";
function CreateFeatureTogglePage() {
  const router = useRouter();
  const t = useT();
  const initialValues = {
    identifier: "",
    name: "",
    description: "",
    category: "",
    type: "",
    defaultValue: null
  };
  const fields = createFieldDefinitions(t);
  const formGroups = createFormGroups(t);
  return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(
    CrudForm,
    {
      title: "Create Feature Toggle",
      backHref: "/backend/feature-toggles/global",
      fields,
      groups: formGroups,
      initialValues,
      onSubmit: async (values) => {
        const payload = {
          identifier: values.identifier,
          name: values.name,
          description: values.description,
          category: values.category,
          type: values.type,
          defaultValue: values.defaultValue
        };
        await createCrud("feature_toggles/global", payload);
        router.push("/backend/feature-toggles/global");
        router.refresh();
      }
    }
  ) }) });
}
export {
  CreateFeatureTogglePage as default
};
//# sourceMappingURL=page.js.map
