/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import PropTypes from 'prop-types';
import LinkList from '../../../link-list';
import { copyrightText } from '../../../../../helpers/getters';
import Disclaimer from '../../../../atoms/disclaimer';
import FooterHotline from '../../../../atoms/footer/hotline';
import FooterLicense from '../../../../atoms/footer/license';
import styles from './template-two.module.scss';

const TemplateTwo = ({
  footerLogos,
  footerMenu,
  footerMenuLimit = 3,
  copyrightDisclaimer,
  showLinks,
  asSeenOn,
  gamblingText,
  socialIcons,
  hasFooterLinks,
  hasDisclaimer,
  showCopyright,
  helpText,
  phoneNum,
  logo,
  dmcaImage,
  dmcaWidth,
  dmcaHeight,
  securityIcon,
  copyrightCustomText,
}) => {
  if (footerMenu !== null && footerMenu.children.length) {
    footerMenu.children.splice(footerMenuLimit);
  }

  return (
    <footer>
      <div
        className={`${styles?.footer || ''} ${styles?.templateTwo || ''}
            ${hasFooterLinks && styles.hasFooterLinks ? styles.hasFooterLinks || '' : ''}`}
      >
        {footerMenu && showLinks && (
          <div className={styles?.topPart || ''}>
            {footerMenu && showLinks && (
              <div className={styles?.links || ''}>
                <LinkList lists={footerMenu} gtmClass="mobile-menu-gtm" />
              </div>
            )}

            <FooterLicense
              gamblingText={gamblingText}
              socialIcons={socialIcons}
              template="templateTwo"
              logo={logo}
              securityIcon={securityIcon}
            />
          </div>
        )}

        {(helpText || phoneNum) && (
          <FooterHotline
            showAsSeen={asSeenOn !== null}
            asSeenOn={asSeenOn}
            helpText={helpText}
            phoneNum={phoneNum}
            template="templateTwo"
          />
        )}

        <div className={styles?.bottomPart || ''}>
          {copyrightDisclaimer && (
            <div
              className={styles?.copyrightDisclaimer || ''}
              // eslint-disable-next-line react/no-danger
              dangerouslySetInnerHTML={{ __html: copyrightDisclaimer }}
            />
          )}
          {showCopyright && (
            <p className={styles?.copyrightText || ''}>{copyrightCustomText || copyrightText()}</p>
          )}

          {(footerLogos || hasDisclaimer) && (
            <div className={styles.logos}>
              {footerLogos && (
                <LinkList
                  showListTitle={false}
                  imageOnly
                  singleList
                  lists={footerLogos}
                  gtmClass="mobile-menu-gtm logo-cta"
                  width={130}
                  height={140}
                />
              )}
              {hasDisclaimer && (
                <Disclaimer
                  loading="lazy"
                  dmcaImage={dmcaImage}
                  imgWidth={dmcaWidth}
                  imgHeight={dmcaHeight}
                />
              )}
            </div>
          )}
        </div>
      </div>
    </footer>
  );
};

export default TemplateTwo;

TemplateTwo.propTypes = {
  footerLogos: PropTypes.shape({}),
  footerMenu: PropTypes.shape({
    children: PropTypes.shape([]),
  }),
  copyrightDisclaimer: PropTypes.string,
  showLinks: PropTypes.bool,
  asSeenOn: PropTypes.shape({}),
  gamblingText: PropTypes.string,
  socialIcons: PropTypes.shape({}),
  hasFooterLinks: PropTypes.bool,
  hasDisclaimer: PropTypes.bool,
  showCopyright: PropTypes.bool,
  helpText: PropTypes.string,
  phoneNum: PropTypes.string,
  logo: PropTypes.string,
  dmcaImage: PropTypes.string,
  dmcaWidth: PropTypes.number,
  dmcaHeight: PropTypes.number,
  securityIcon: PropTypes.string,
  copyrightCustomText: PropTypes.string,
  footerMenuLimit: PropTypes.number,
};
