import { ComponentConfig } from "@reacteditor/core";
import { FolderOpen } from "lucide-react";
import { CollectionView, type CollectionProps } from "@/components/commerce/collection";

export function createCollectionEditor(opts: {
  collectionField: any;
}): ComponentConfig<CollectionProps> {
  return {
    label: "Collection page",
    icon: <FolderOpen size={16} />,
    category: "commerce",
    defaultProps: { collection: null, showDescription: "no" },
    fields: {
      collection: { label: "Collection", ...opts.collectionField },
      showDescription: {
        label: "Description",
        type: "radio",
        options: [
          { label: "Hide description", value: "no" },
          { label: "Show description", value: "yes" },
        ],
      },
    },
    render: (props) => <CollectionView {...props} />,
  };
}
