import type { BrapiFormField } from "@/components/brapi/BrapiEntityPage";
import { LIST_TYPE_OPTIONS, NONE_SELECT_VALUE, type SelectOption } from "../types";

export function buildListFormFields(personOptions: SelectOption[]): BrapiFormField[] {
  return [
    { key: "listName", label: "列表名称", type: "text", required: true, placeholder: "如 2026 核心种质清单" },
    {
      key: "listType",
      label: "列表类型",
      type: "select",
      required: true,
      options: LIST_TYPE_OPTIONS.map((option) => ({ value: option.value, label: option.label })),
    },
    { key: "listDescription", label: "列表描述", type: "textarea", colSpan: 2, placeholder: "用途、范围或备注" },
    { key: "listSource", label: "列表来源", type: "text", placeholder: "如 田间调查、导入批次" },
    { key: "listOwnerName", label: "Owner 名称", type: "text", placeholder: "可选，选择人员后可自动带出" },
    {
      key: "listOwnerPersonDbId",
      label: "Owner 人员",
      type: "select",
      options: [{ value: NONE_SELECT_VALUE, label: "不绑定人员" }, ...personOptions],
    },
  ];
}
