import type { FC } from 'react' import * as React from 'react' import { useTranslation } from 'react-i18next' import Input from '@/app/components/base/input' import { cn } from '@/utils/classnames' const i18nPrefix = 'nodes.humanInput' type Props = { timeout: number unit: 'day' | 'hour' onChange: (state: { timeout: number, unit: 'day' | 'hour' }) => void readonly?: boolean } const TimeoutInput: FC = ({ timeout, unit, onChange, readonly, }) => { const { t } = useTranslation() const handleValueChange = (e: React.ChangeEvent) => { const value = e.target.value if (/^\d*$/.test(value)) onChange({ timeout: Number(value) || 1, unit }) else onChange({ timeout: 1, unit }) } return (
!readonly && onChange({ timeout, unit: 'day' })} >
{t(`${i18nPrefix}.timeout.days`, { ns: 'workflow' })}
!readonly && onChange({ timeout, unit: 'hour' })} >
{t(`${i18nPrefix}.timeout.hours`, { ns: 'workflow' })}
) } export default TimeoutInput