import React from 'react';
import { AtomImage } from 'native/atoms/Image';
import { AtomCardContainer } from 'native/atoms/CardContainer';
import { IButtonBadgeProps, MoleculeButtonBadge } from 'native/molecules/ButtonBadge';
import {
  BoxImage,
  CardBody,
  ContainerBadge,
  ContainerBadges
} from './styles';

export interface IBadgeCardProps {
  /** Array Badges */
  badges: IButtonBadgeProps[];
  /** Atom's card container width*/
  cardWidth?: string;
  /** Atom's card container height*/
  cardHeight?: string;
  /** Atom's card container shadowsize */
  cardShadowSize?: 'small' | 'regular' | 'large';
  /** Img to card top */
  img?: string;
  /** Img alt (Name or description) */
  imgAlt?: string;
  /** Img width to card top */
  imgWidth?: string;
  /** Img height to card top */
  imgHeight?: string;
  /** Ask if images are svg */
  isSvg?: boolean;
}

export const OrganismBadgeCard = ({
  badges,
  cardWidth = '100%',
  cardHeight = '100%',
  cardShadowSize = 'regular',
  img,
  imgAlt,
  imgWidth = '108px',
  imgHeight = '34px',
  isSvg = false,
}: IBadgeCardProps) => {
  return (
    <AtomCardContainer height={cardHeight} width={cardWidth} shadowSize={cardShadowSize}>
      <CardBody>
        {
          img &&
          <BoxImage>
            <AtomImage
              alt={imgAlt}
              src={img}
              imgWidth={imgWidth}
              imgHeight={imgHeight}
              isSvg={isSvg}
            />
          </BoxImage>
        }
        <ContainerBadges>
          {badges &&
            badges.length > 0 &&
            badges.map((badge: IButtonBadgeProps, index: number) => (
              <ContainerBadge key={index}>
                <MoleculeButtonBadge
                  altTextImg={badge.altTextImg}
                  badgeText={badge.badgeText}
                  badgeStatus={badge.badgeStatus}
                  bgColor={badge.bgColor}
                  image={badge.image}
                  onPress={badge.onPress}
                  styles={badge.styles}
                />
              </ContainerBadge>
            ))}
        </ContainerBadges>
      </CardBody>
    </AtomCardContainer>
  );
};