feat: basic chat app support bool

This commit is contained in:
Joel
2025-07-09 14:06:25 +08:00
parent f2dfb5363f
commit b5782fff8f
6 changed files with 24 additions and 4 deletions

View File

@ -2,10 +2,12 @@
import Checkbox from '@/app/components/base/checkbox'
import type { FC } from 'react'
import React, { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
type Props = {
name: string
value: boolean
required?: boolean
onChange: (value: boolean) => void
}
@ -13,7 +15,9 @@ const BoolInput: FC<Props> = ({
value,
onChange,
name,
required,
}) => {
const { t } = useTranslation()
const handleChange = useCallback(() => {
onChange(!value)
}, [value, onChange])
@ -24,7 +28,10 @@ const BoolInput: FC<Props> = ({
checked={!!value}
onCheck={handleChange}
/>
<div className='system-sm-medium text-text-secondary'>{name}</div>
<div className='system-sm-medium flex items-center gap-1 text-text-secondary'>
{name}
{!required && <span className='system-xs-regular text-text-tertiary'>{t('workflow.panel.optional')}</span>}
</div>
</div>
)
}

View File

@ -172,6 +172,7 @@ const FormItem: FC<Props> = ({
<BoolInput
name={payload.label as string}
value={!!value}
required={payload.required}
onChange={onChange}
/>
)}