import { IMAGE_ROOT } from '@/shared/constants/common';
import { motion } from 'framer-motion';
import { useTranslation } from 'react-i18next';

export interface EscrowMailResendBottomSheetProps {
  setBottomSheetOn: (bottomSheetOn: boolean) => void;
  bottomSheetOn: boolean;
  callMailResend: () => void;
};

export const EscrowMailResendBottomSheet = ({
  setBottomSheetOn,
  bottomSheetOn,
  callMailResend
}: EscrowMailResendBottomSheetProps) => {
  const { t } = useTranslation();

  const onClickToClose = () => {
    setBottomSheetOn(false);
  };
  const onClickToMailResend = () => {
    callMailResend();
  };

  const variants = {
    hidden: { y: '100%' },
    visible: { y: '0%' },
  };

  return (
    <>
      { (bottomSheetOn) &&
        <div className="bg-dim"></div>
      }
      <motion.div
        className="bottomsheet"
        initial="hidden"
        animate={ (bottomSheetOn)? 'visible': 'hidden' }
        variants={ variants }
        transition={{ duration: 0.5 }}
      >
        <div className="bottomsheet-header">
          <div className="bottomsheet-title">
            <h2>{ t('transaction.bottomSheet.escrowMailResend.title') }</h2>
            <button
              className="close-btn"
              type="button"
            >
              <img
                src={ IMAGE_ROOT + '/ico_close.svg' }
                alt={ t('transaction.bottomSheet.escrowMailResend.close') }
                onClick={ () => onClickToClose() }
              />
            </button>
          </div>
        </div>

        <div className="bottomsheet-content">
          <div className="email-section">
            <div className="email-label">
              <div className="mail-icon">
                <div className="mail-icon-bg"></div>
                <img
                  src={ IMAGE_ROOT +'/ico_email.svg' }
                  alt={ t('transaction.bottomSheet.escrowMailResend.mail') }
                />
              </div>
              <span className="label-text">{ t('transaction.bottomSheet.escrowMailResend.mailLabel') }</span>
            </div>

            <div className="email-select">
              <div className="select-wrapper">
                <select>
                  <option>{ t('transaction.bottomSheet.escrowMailResend.select') }</option>
                  <option>{ t('transaction.bottomSheet.escrowMailResend.select') }1</option>
                  <option>{ t('transaction.bottomSheet.escrowMailResend.select') }2</option>
                </select>
              </div>
            </div>

            <div className="error-message">
              <p>{ t('transaction.bottomSheet.escrowMailResend.errorNoEmail') }</p>
            </div>
          </div>
        </div>

        <div className="bottomsheet-footer">
          <button
            className="btn-50 btn-blue flex-1"
            type="button"
            onClick={ () => onClickToMailResend() }
          >{ t('transaction.submit') }</button>
        </div>
      </motion.div>
    </>
  );
};