dify/web/app/components/workflow/nodes/trigger-schedule/components/mode-toggle.tsx
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

39 lines
1.1 KiB
TypeScript

import type { ScheduleMode } from '../types'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { Asterisk, CalendarCheckLine } from '@/app/components/base/icons/src/vender/workflow'
type ModeToggleProps = {
mode: ScheduleMode
onChange: (mode: ScheduleMode) => void
}
const ModeToggle = ({ mode, onChange }: ModeToggleProps) => {
const { t } = useTranslation()
const handleToggle = () => {
const newMode = mode === 'visual' ? 'cron' : 'visual'
onChange(newMode)
}
const currentText =
mode === 'visual'
? t(($) => $['nodes.triggerSchedule.useCronExpression'], { ns: 'workflow' })
: t(($) => $['nodes.triggerSchedule.useVisualPicker'], { ns: 'workflow' })
const currentIcon = mode === 'visual' ? Asterisk : CalendarCheckLine
return (
<button
type="button"
onClick={handleToggle}
className="flex cursor-pointer items-center gap-1 rounded-lg px-2 py-1 text-sm text-text-secondary hover:bg-state-base-hover"
>
{React.createElement(currentIcon, { className: 'w-4 h-4' })}
<span>{currentText}</span>
</button>
)
}
export default ModeToggle