fix(plugin-workflow): fix value type for DatePicker to moment (#815) (#819)

fix #815
This commit is contained in:
Junyi 2022-09-09 10:08:46 +08:00 committed by GitHub
parent ce75ecdb2b
commit 295081603e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import { css } from "@emotion/css";
import { DatePicker, Select } from "antd";
import moment from "moment";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
@ -10,6 +11,7 @@ import { OnField } from "./OnField";
export function EndsByField({ value, onChange }) {
const { t } = useTranslation();
const [type, setType] = useState(typeof value === 'object' && !(value instanceof Date) ? 'field' : 'date');
return (
<fieldset className={css`
display: flex;
@ -23,12 +25,8 @@ export function EndsByField({ value, onChange }) {
<Select.Option value={'date'}>{t('By custom date')}</Select.Option>
</Select>
{type === 'field'
? (
<OnField value={value} onChange={onChange} />
)
: (
<DatePicker showTime value={value} onChange={onChange} />
)
? <OnField value={value} onChange={onChange} />
: <DatePicker showTime value={moment(value)} onChange={onChange} />
}
</fieldset>
);