import * as React from 'react';

import Hiperlink from './Link.styled';
import { Forward, Backward, ArrowPlus, Download, Plus } from './LinksIcon';

export interface IProps {
  href?: string;
  children?: React.ReactNode;
  target?: string;
  isType?: string;
  className?: string;
  css?: string|Object;
  title?: string;
  alt?: string;
  onClick?: (any?: any) => any;
  isActiveRoute?: boolean;
  route?: string;
  params?: any;
}

const renderChildAndTypeIcon = (type?: string, children?: any) => {
  const mapIconLinks = new Map();
  mapIconLinks
    .set('forward', Forward(children))
    .set('backward', Backward(children))
    .set('download', Download(children))
    .set('arrow-plus', ArrowPlus(children))
    .set('plus', Plus(children));

  return mapIconLinks.get(type) || children;
};

export default ({ children, isType, ...props }: IProps) => {
  const restProps = { isType, ...props};

  return (
    <Hiperlink {...restProps}>
      {renderChildAndTypeIcon(isType, children)}
    </Hiperlink>
  );
};
