import React, { FC } from 'react';

import Button from '../../blocks/Button';
import Link from '../../blocks/Link';
import css from './index.module.css';

export interface CookieDisclaimerProps {
  text: string;
  readMoreLinkUrl: string;
  readMoreLinkText: string;
  buttonCtaText: string;
  setIsOpen: () => void;
  isOpen: boolean;
}

const CookieDisclaimer: FC<CookieDisclaimerProps> = ({
  readMoreLinkUrl,
  readMoreLinkText,
  text,
  buttonCtaText,
  setIsOpen,
  isOpen,
}) => {
  if (!isOpen) {
    return null;
  }

  return (
    <div className={css.cookieDisclaimer} data-testid="CookieDisclaimer">
      <div className={css.cookieDisclaimer__wrap}>
        <div className={css.cookieDisclaimer__body}>
          {text}{' '}
          <Link target="_blank" to={readMoreLinkUrl} isExternal>
            {readMoreLinkText}
          </Link>
        </div>
        <div className={css.cookieDisclaimer__cta}>
          <Button variant="secondary" handleClick={setIsOpen}>
            {buttonCtaText}
          </Button>
        </div>
      </div>
    </div>
  );
};

export default CookieDisclaimer;
