import { Button } from '../../ui-kit/Button/Button';
import { MAX_CATEGORIES } from './constants';

type RenderButtonsProps = {
  cashbacksLength: number;
  onAddNewCashback: () => void;
  onResetCashback: () => void;
  calculatorType?: string;
  maxCategories?: number;
};

export const renderButtons = ({
  cashbacksLength,
  onAddNewCashback,
  onResetCashback,
  calculatorType = 'standard',
  maxCategories = MAX_CATEGORIES[calculatorType],
}: RenderButtonsProps) => {
  return (
    <div className="w-full flex flex-col gap-lg">
      {cashbacksLength < maxCategories ? (
        <Button
          className="self-start text-primary-main"
          embedded
          version="secondary"
          onClick={onAddNewCashback}
        >
          {cashbacksLength ? 'Добавить ещё категорию' : 'Добавить категорию'}
        </Button>
      ) : null}
      {cashbacksLength > 2 ? (
        <Button className="self-start" version="secondary" onClick={onResetCashback}>
          Сбросить все категории
        </Button>
      ) : null}
    </div>
  );
};
