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


export interface LinkBreakBottomSheetProps {
    bottomSheetOn: boolean,
    setBottomSheetOn: (bottomSheetOn: boolean) => void;
    linkBreak: () => void;
};

export const LinkBreakBottomSheet = ({
    bottomSheetOn,
    setBottomSheetOn,
    linkBreak
}: LinkBreakBottomSheetProps) => {
    const onClickToClose = () => {
        setBottomSheetOn(false);
    };

    const onClickToLinkBreak = () => {
        if(linkBreak) {
            linkBreak();
        }
        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={ () => onClickToLinkBreak() }
          >확인</button>
        </div>
      </motion.div>
    </>
  );
}