import _variants from "@/components/ui/button/_variants";
import { AddDownloadLinkSchema } from "@/schemas/files/_addDownloadLink";
import { FormBuilderElement } from "@/types/app-component-formbuilder";

type Field = FormBuilderElement<AddDownloadLinkSchema, typeof _variants>;

type gAddDownloadLinkFieldsProps = {
  isPending: boolean;
  closeModal: (id: string) => void;
  dict: Dictionary;
};
export default function getAddDownloadLinkFields({
  isPending,
  closeModal,
  dict,
}: gAddDownloadLinkFieldsProps) {
  return [
    {
      type: "text",
      label: "Title",
      name: "title",
      className: "w-full",
      required: true,
      errors: dict.pages.downloads.form.fields.download_link_title.errors,
    },
    {
      type: "file",
      label: "File",
      name: "file",
      required: true,
      errors: dict.pages.downloads.form.fields.download_link_file.errors,
    },
    {
      type: "group",
      className: "w-full flex justify-end gap-4",
      fields: [
        {
          type: "button",
          label: dict.pages.general.close,
          variant: "solid",
          color: "danger",
          onClick: () => closeModal("upload-download-form"),
        },
        {
          type: "submit",
          label: dict.pages.general.upload,
          variant: "solid",
          color: "primary",
          disabled: isPending,
        },
      ],
    },
  ] as Field[];
}
