asb_cloud_front/src/components/Table/DatePickerWrapper.tsx

24 lines
581 B
TypeScript
Raw Normal View History

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