'use client'

import { useState } from "react";
import WithDraggable from "@/components/common/draggable/withDraggable";
import { modalState } from "@/store/modalAtom";
import { useRecoilState } from "recoil";
import Tab01 from "./Tab01";
import Tab02 from "./Tab02";
import Tab03 from "./Tab03";
import Tab04 from "./Tab04";
import Tab05 from "./Tab05";


export default function OuterLineWall (){
    const [modalOption, setModalOption] = useRecoilState(modalState); //modal 열림닫힘 state
    const [buttonAct, setButtonAct] = useState(1);
    const [close, setClose] = useState(false)
    const HandleClickClose = () => {
        setClose(true)
        setTimeout(() => {
            setModalOption({...modalOption, outerwall: false})
            setClose(false);
        }, 180)
    }
    return(
        <WithDraggable isShow={true}>
            <div className={`modal-pop-wrap r ${modalOption.outerwall ? 'mount' : ''} ${close ? 'unmount' : ''} `}>
                <div className="modal-head handle">
                    <h1 className="title">外壁線を描</h1>
                    <button className="modal-close" onClick={HandleClickClose}>닫기</button>
                </div>
                <div className="modal-body">
                <div className="left-bar handle"></div>
                <div className="right-bar handle"></div>
                    <div className="modal-btn-wrap">
                        <button 
                        className={`btn-frame modal ${buttonAct === 1 ? 'act' : ''}`} 
                        onClick={() => setButtonAct(1)}
                        >
                            外壁線
                        </button>

                        <button 
                        className={`btn-frame modal ${buttonAct === 2 ? 'act' : ''}`} 
                        onClick={() => setButtonAct(2)}
                        >
                            直角
                        </button>
                        <button 
                        className={`btn-frame modal ${buttonAct === 3 ? 'act' : ''}`} 
                        onClick={() => setButtonAct(3)}
                        >
                            イ・グベ
                        </button>
                        <button 
                        className={`btn-frame modal ${buttonAct === 4 ? 'act' : ''}`} 
                        onClick={() => setButtonAct(4)}
                        >
                            角度
                        </button>
                        <button 
                        className={`btn-frame modal ${buttonAct === 5 ? 'act' : ''}`} 
                        onClick={() => setButtonAct(5)}
                        >
                            対角線
                        </button>
                    </div>
                    <div className="properties-setting-wrap outer">
                        {buttonAct === 1 && <Tab01/>}
                        {buttonAct === 2 && <Tab02/>}
                        {buttonAct === 3 && <Tab03/>}
                        {buttonAct === 4 && <Tab04/>}
                        {buttonAct === 5 && <Tab05/>}
                    </div>
                    
                    <div className="grid-btn-wrap">
                        <button className="btn-frame modal mr5">一変戦に戻る</button>
                        <button className="btn-frame modal act">外壁線確定</button>
                    </div>
                </div>
                <div className="modal-foot handle"></div>
            </div>
        </WithDraggable>
    )
}