import SparkDatePicker from "../SparkDatePicker";
import React from "react";
import {Box} from "@mui/material";

export interface DatePeriodPickerProps {
    label: {
        start: string,
        end: string
    },
    start?: Date,
    end?: Date,
    onChange: (element: PickerType, newDate: Date | null) => void
}

export type PickerType = "start" | "end";


function DatePeriodPicker(props: DatePeriodPickerProps) {
    return (
        <Box>
            <SparkDatePicker label={props.label.start}
                             value={props.start}
                             handleChange={date => props.onChange("start", date)}/>
            <SparkDatePicker label={props.label.end}
                             value={props.end}
                             handleChange={date => props.onChange("end", date)}/>
        </Box>)
}

export default DatePeriodPicker;