import { jsx as _jsx } from "react/jsx-runtime";
import { useState } from 'react';
import './style.scss';
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
const DateTimePicker = ({ pickDate, pickTime, }) => {
    const [startDate, setStartDate] = useState(new Date());
    const handleChange = (dateTime) => {
        setStartDate(dateTime);
        const date = new Date(dateTime);
        const formattedDate = `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
        const formattedTime = format12HourTime(date);
        pickTime(formattedTime);
        pickDate(formattedDate);
    };
    function format12HourTime(date) {
        const hours = date.getHours();
        const minutes = date.getMinutes();
        const ampm = hours >= 12 ? 'PM' : 'AM';
        const formattedHours = hours % 12 === 0 ? 12 : hours % 12;
        const formattedMinutes = String(minutes).padStart(2, '0');
        return `${formattedHours}:${formattedMinutes} ${ampm}`;
    }
    return (_jsx("div", { children: _jsx(DatePicker, { selected: startDate, onChange: (date) => handleChange(date), showTimeSelect: true, dateFormat: "Pp", showPopperArrow: false, timeIntervals: 15, customInput: _jsx("input", { className: 'ii' }) }) }));
};
export default DateTimePicker;
