import React from "react";
import {DesktopDatePicker, LocalizationProvider} from "@mui/lab";
import {TextField} from "@mui/material";
import DateAdapter from '@mui/lab/AdapterDayjs';
import pl from 'dayjs/locale/pl';

export interface DatePickerProps {
    label: string,
    value?: Date,
    handleChange: (newValue: Date | null) => void
}

function SparkDatePicker(props: DatePickerProps) {
    return (
        <LocalizationProvider dateAdapter={DateAdapter} locale={pl}>
            <DesktopDatePicker
                label={props.label}
                value={props.value}
                onChange={props.handleChange}
                renderInput={(params) => <TextField {...params} />}
            />
        </LocalizationProvider>
    );
}

export default SparkDatePicker;
