import React from 'react'; import { InputNumber, Select } from 'antd'; import { css, useCompile, usePlugin } from '@nocobase/client'; import WorkflowPlugin, { Instruction, JOB_STATUS } from '@nocobase/plugin-workflow/client'; import { NAMESPACE } from '../locale'; const UnitOptions = [ { value: 1_000, label: `{{t('Seconds', { ns: "workflow" })}}` }, { value: 60_000, label: `{{t('Minutes', { ns: "workflow" })}}` }, { value: 3600_000, label: `{{t('Hours', { ns: "workflow" })}}` }, { value: 86400_000, label: `{{t('Days', { ns: "workflow" })}}` }, { value: 604800_000, label: `{{t('Weeks', { ns: "workflow" })}}` }, ]; function getNumberOption(v) { return UnitOptions.slice() .reverse() .find((item) => !(v % item.value)); } function Duration({ value = 60000, onChange }) { const compile = useCompile(); const option = getNumberOption(value); const quantity = Math.round(value / option.value); return (
onChange(Math.round(v * option.value))} className="auto-width" />