import { BottomSheetMotionDuration, BottomSheetMotionVaiants } from "@/entities/common/model/constant";
import { IMAGE_ROOT } from '@/shared/constants/common';
import { motion } from 'framer-motion';
import { useTranslation } from 'react-i18next';

export interface ArsResendSmsBottomSheetProps {
  bottomSheetOn: boolean;
  setBottomSheetOn: (bottomSheetOn: boolean) => void;
  phoneNumber?: string;
  callResendSms: () => void;
};

export const ArsResendSmsBottomSheet = ({
  bottomSheetOn,
  setBottomSheetOn,
  phoneNumber,
  callResendSms
}: ArsResendSmsBottomSheetProps) => {
  const { t } = useTranslation();

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

  const onCliickToResendSms = () => {
    if(callResendSms){
      callResendSms();
    }
    onClickToClose();
  };

  return (
    <>
      { (bottomSheetOn) &&
        <div className="bg-dim"></div>
      }
      <motion.div 
        className="bottomsheet"
        initial="hidden"
        animate={ (bottomSheetOn)? 'visible': 'hidden' }
        variants={ BottomSheetMotionVaiants }
        transition={ BottomSheetMotionDuration }
      >
        <div className="bottomsheet-header">
          <div className="bottomsheet-title">
            <h2>{t('additionalService.common.resend')} SMS</h2>
            <button
              className="close-btn"
              type="button"
            >
              <img
                src={ IMAGE_ROOT + '/ico_close.svg' }
                alt={t('common.close')}
                onClick={ () => onClickToClose() }
              />
            </button>
          </div>
        </div>
        <div className="bottomsheet-content">
          <div className="bottom-section">
            <p>[{phoneNumber}] {t('transaction.sms.resendConfirmMessage')}</p>
          </div>
        </div>
        <div className="bottomsheet-footer">
          <button
            className="btn-50 btn-blue flex-1"
            type="button"
            onClick={ () => onCliickToResendSms() }
          >{t('transaction.apply')}</button>
        </div>
      </motion.div>
    </>
  );
};