import { IReactComponent } from '@wowpic/xform-types';
import { DatePicker } from 'antd';
import React, { FunctionComponent, useCallback } from 'react';
import { getMomentTime } from '../utils';

const AntdWeekPicker = DatePicker.WeekPicker;

const WeekPicker: FunctionComponent<IReactComponent> = ({
    value: originValue,
    onChange,
    ...props
}) => {
    const value: any = getMomentTime(originValue);
    const onValueChange = useCallback(
        (v) => onChange(+v),
        [onChange]
    );
    return (
        <AntdWeekPicker value={value} onChange={onValueChange} {...props} />
    );
};

export default WeekPicker;
