import { Button } from "antd";
import ConfigListEmptyState from "./config-list-empty-state.component.jsx";

export const buildConfigListActionButton = ({ key, label, onClick, id }) => (
  <Button key={key} type="primary" block id={id} onClick={onClick}>
    {label}
  </Button>
);

export const renderConfigListOrEmpty = ({ fields, actionLabel, renderItems }) =>
  fields.length === 0 ? <ConfigListEmptyState actionLabel={actionLabel} /> : renderItems();

export const buildSectionActionButton = (key, label, onClick, id) =>
  buildConfigListActionButton({ key, label, onClick, id });

export const renderListOrEmpty = (fields, actionLabel, renderItems) =>
  renderConfigListOrEmpty({ fields, actionLabel, renderItems });
