import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' import type { ScheduleTriggerNodeType } from './types' import Field from '@/app/components/workflow/nodes/_base/components/field' import type { NodePanelProps } from '@/app/components/workflow/types' import ModeToggle from './components/mode-toggle' import FrequencySelector from './components/frequency-selector' import WeekdaySelector from './components/weekday-selector' import TimePicker from '@/app/components/base/date-and-time-picker/time-picker' import NextExecutionTimes from './components/next-execution-times' import MonthlyDaysSelector from './components/monthly-days-selector' import OnMinuteSelector from './components/on-minute-selector' import Input from '@/app/components/base/input' import useConfig from './use-config' const i18nPrefix = 'workflow.nodes.triggerSchedule' const Panel: FC> = ({ id, data, }) => { const { t } = useTranslation() const { inputs, setInputs, handleModeChange, handleFrequencyChange, handleCronExpressionChange, handleWeekdaysChange, handleTimeChange, handleOnMinuteChange, } = useConfig(id, data) return (
} >
{inputs.mode === 'visual' && (
{inputs.frequency === 'hourly' ? ( ) : ( <> { if (time) { const timeString = time.format('h:mm A') handleTimeChange(timeString) } }} onClear={() => { handleTimeChange('12:00 AM') }} placeholder={t('workflow.nodes.triggerSchedule.selectTime')} showTimezone={true} /> )}
{inputs.frequency === 'weekly' && ( )} {inputs.frequency === 'monthly' && ( { const newInputs = { ...inputs, visual_config: { ...inputs.visual_config, monthly_days: days, }, } setInputs(newInputs) }} /> )}
)} {inputs.mode === 'cron' && (
handleCronExpressionChange(e.target.value)} placeholder="0 0 * * *" className="font-mono" />
)}
) } export default React.memo(Panel)