"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSingleDatePickerModal = void 0;
const react_1 = require("react");
const useSingleDatePicker_1 = require("../SingleDatePicker/hooks/useSingleDatePicker");
const types_1 = require("../../../types");
const today = new types_1.PurpleDate().today;
const useSingleDatePickerModal = (props) => {
    const [visibleModal, setVisibleModal] = (0, react_1.useState)(false);
    const [tempSelectedDate, setTempSelectedDate] = (0, react_1.useState)(props.selectedDate);
    const rightDisabled = !tempSelectedDate;
    const baseDatePicker = (0, useSingleDatePicker_1.useSingleDatePicker)(Object.assign(Object.assign({}, props), { 
        // 모달 내 임시 value, setter
        selectedDate: tempSelectedDate, onUpdateSelectedDate: setTempSelectedDate }));
    const openModal = () => {
        setVisibleModal(true);
        props.onUpdateDisplayDate(props.selectedDate || today);
        setTempSelectedDate(props.selectedDate);
    };
    const closeModal = () => {
        setVisibleModal(false);
    };
    const onReset = () => {
        baseDatePicker.resetSelectedData();
    };
    const onConfirm = () => {
        props.onUpdateSelectedDate(tempSelectedDate);
        closeModal();
    };
    return Object.assign(Object.assign({}, baseDatePicker), { visibleModal,
        rightDisabled,
        openModal,
        closeModal,
        onReset,
        onConfirm });
};
exports.useSingleDatePickerModal = useSingleDatePickerModal;
