import React from "react";
import StartAndEndDate, { StartAndEndDateType, } from "../../../UI/Components/Date/StartAndEndDate";
import TimeRange from "../../../Types/Time/TimeRange";
import Dropdown from "../../../UI/Components/Dropdown/Dropdown";
import DropdownUtil from "../../../UI/Utils/Dropdown";
const DashboardStartAndEndDateEditElement = (props) => {
    var _a, _b;
    const dropdownOptions = DropdownUtil.getDropdownOptionsFromEnum(TimeRange);
    const defaultDropdownOption = dropdownOptions.find((option) => {
        return option.value === TimeRange.PAST_ONE_HOUR;
    }) || dropdownOptions[0];
    const selectedDropdownnOption = dropdownOptions.find((option) => {
        var _a;
        return option.value === ((_a = props.value) === null || _a === void 0 ? void 0 : _a.range);
    }) || defaultDropdownOption;
    return (React.createElement("div", null,
        React.createElement(Dropdown, { value: selectedDropdownnOption, onChange: (range) => {
                props.onChange({
                    range: range,
                });
            }, options: dropdownOptions }),
        ((_a = props.value) === null || _a === void 0 ? void 0 : _a.range) === TimeRange.CUSTOM && (React.createElement(StartAndEndDate, { type: StartAndEndDateType.DateTime, value: ((_b = props.value) === null || _b === void 0 ? void 0 : _b.startAndEndDate) || undefined, hideTimeButtons: true, onValueChanged: (startAndEndDate) => {
                if (startAndEndDate) {
                    props.onChange({
                        range: TimeRange.CUSTOM,
                        startAndEndDate,
                    });
                }
            } }))));
};
export default DashboardStartAndEndDateEditElement;
//# sourceMappingURL=RangeStartAndEndDateEdit.js.map