import { DatePicker } from 'antd'
import moment from 'moment'
import { formatDate } from './index'

export type DatePickerWrapperProps = {
    value: moment.Moment,
    onChange: (date: moment.Moment | null) => any
    [other: string]: any
}

export const DatePickerWrapper: React.FC<DatePickerWrapperProps> = ({value, onChange, ...other}) => (
  <DatePicker
    allowClear={false}
    defaultValue={moment()}
    value={moment.utc(value).local()}
    format={formatDate}
    showTime
    onChange={(date) => onChange(date)}
    {...other}
  />
)

export default DatePickerWrapper
