"use client";
import { jsx } from "react/jsx-runtime";
import * as React from "react";
import { useRouter } from "next/navigation";
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
import { createCrud } from "@open-mercato/ui/backend/utils/crud";
import { flash } from "@open-mercato/ui/backend/FlashMessages";
import { buildResourceTypePayload, ResourceTypeCrudForm } from "@open-mercato/core/modules/resources/components/ResourceTypeCrudForm";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function ResourcesResourceTypeCreatePage() {
  const t = useT();
  const router = useRouter();
  const handleSubmit = React.useCallback(async (values) => {
    const payload = buildResourceTypePayload(values);
    await createCrud("resources/resource-types", payload, {
      errorMessage: t("resources.resourceTypes.errors.save", "Failed to save resource type.")
    });
    flash(t("resources.resourceTypes.messages.saved", "Resource type saved."), "success");
    router.push("/backend/resources/resource-types");
  }, [router, t]);
  return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(
    ResourceTypeCrudForm,
    {
      mode: "create",
      initialValues: { name: "", description: "", appearance: { icon: null, color: null } },
      onSubmit: handleSubmit
    }
  ) }) });
}
export {
  ResourcesResourceTypeCreatePage as default
};
//# sourceMappingURL=page.js.map
