import React, {ChangeEvent} from 'react';
import './InputDate.css'
import {format} from "date-fns";

export function InputDate({children, value, onChange, name}: {
    children?: string;
    name: string;
    value: string;
    onChange: (event: ChangeEvent<HTMLInputElement>) => void;
}) {
    return (
        <>
            <label htmlFor={name}>{children}</label>
            <input type="date" value={value ? format(value, "yyyy-MM-dd") : ''} name={name} onChange={onChange}
                   className="input__date"/>
        </>
    );
}
