forked from ddrilling/asb_cloud_front
27 lines
750 B
TypeScript
Executable File
27 lines
750 B
TypeScript
Executable File
import { memo } from 'react'
|
|
import { DatePicker } from 'antd'
|
|
import { PickerDateProps } from 'antd/lib/date-picker/generatePicker'
|
|
import moment, { Moment } from 'moment'
|
|
|
|
import { defaultFormat } from '@utils'
|
|
|
|
export type DatePickerWrapperProps = PickerDateProps<Moment> & {
|
|
value?: Moment,
|
|
onChange?: (date: Moment | null) => any
|
|
isUTC?: boolean
|
|
}
|
|
|
|
export const DatePickerWrapper = memo<DatePickerWrapperProps>(({ value, onChange, isUTC, ...other }) => (
|
|
<DatePicker
|
|
showTime
|
|
allowClear={false}
|
|
format={defaultFormat}
|
|
defaultValue={undefined}
|
|
onChange={(date) => onChange?.(date)}
|
|
value={value && (isUTC ? moment.utc(value).local() : moment(value))}
|
|
{...other}
|
|
/>
|
|
))
|
|
|
|
export default DatePickerWrapper
|