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


export interface ExtendedPeriodBottomSheetProps {
    bottomSheetOn: boolean,
    setBottomSheetOn: (bottomSheetOn: boolean) => void;
    extendPeriod: () => void;
};

export const ExtendedPeriodBottomSheet = ({
    bottomSheetOn,
    setBottomSheetOn,
    extendPeriod
}: ExtendedPeriodBottomSheetProps) => {
    const onClickToClose = () => {
        setBottomSheetOn(false);
    };

    const onClickToResendSms = () => {
        if(extendPeriod) {
            extendPeriod();
        }
        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>기간 연장</h2>
            <button
              className="close-btn"
              type="button"
            >
              <img 
                src={ IMAGE_ROOT + '/ico_close.svg' }
                alt="취소"
                onClick={ () => onClickToClose() }
              />
            </button>
          </div>
        </div>
        <div className="bottomsheet-content">
          <div className="bottom-section">
            <p>유효기간 연장을 하시겠습니끼?</p>
            <p>개별 상태를 확인해주세요.</p>
          </div>
        </div>
        <div className="bottomsheet-footer">
          <button
            className="btn-50 btn-blue flex-1"
            type="button"
            onClick={ () => onClickToResendSms() }
          >확인</button>
        </div>
      </motion.div>
    </>
  );
}