fix: bing search response filter (#2519)

This commit is contained in:
Yeuoly
2024-02-22 13:06:55 +08:00
committed by GitHub
parent 1ecbd95adf
commit d8ab4474b4
6 changed files with 170 additions and 23 deletions

View File

@@ -17,6 +17,7 @@ import Input from './Input'
import { SimpleSelect } from '@/app/components/base/select'
import Tooltip from '@/app/components/base/tooltip-plus'
import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general'
import Radio from '@/app/components/base/radio'
type FormProps = {
value: FormValue
onChange: (val: FormValue) => void
@@ -47,7 +48,7 @@ const Form: FC<FormProps> = ({
const language = useLanguage()
const [changeKey, setChangeKey] = useState('')
const handleFormChange = (key: string, val: string) => {
const handleFormChange = (key: string, val: string | boolean) => {
if (isEditMode && (key === '__model_type' || key === '__model_name'))
return
@@ -214,6 +215,37 @@ const Form: FC<FormProps> = ({
</div>
)
}
if (formSchema.type === 'boolean') {
const {
variable,
label,
show_on,
} = formSchema as CredentialFormSchemaRadio
if (show_on.length && !show_on.every(showOnItem => value[showOnItem.variable] === showOnItem.value))
return null
return (
<div key={variable} className='py-3'>
<div className='flex items-center justify-between py-2 text-sm text-gray-900'>
<div className='flex items-center space-x-2'>
<span>{label[language]}</span>
{tooltipContent}
</div>
<Radio.Group
className='flex items-center'
value={value[variable] ? 1 : 0}
onChange={val => handleFormChange(variable, val === 1)}
>
<Radio value={1} className='!mr-1'>True</Radio>
<Radio value={0}>False</Radio>
</Radio.Group>
</div>
{fieldMoreInfo?.(formSchema)}
</div>
)
}
}
return (