2025-06-03 15:40:04 +08:00
|
|
|
import { SelectWithSearch } from '@/components/originui/select-with-search';
|
|
|
|
|
import {
|
|
|
|
|
FormControl,
|
|
|
|
|
FormField,
|
|
|
|
|
FormItem,
|
|
|
|
|
FormLabel,
|
|
|
|
|
FormMessage,
|
|
|
|
|
} from '@/components/ui/form';
|
|
|
|
|
import { useFormContext } from 'react-hook-form';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2025-06-10 17:06:30 +08:00
|
|
|
import { useBuildQueryVariableOptions } from '../../hooks/use-get-begin-query';
|
2025-06-03 15:40:04 +08:00
|
|
|
|
2025-06-24 18:01:30 +08:00
|
|
|
type QueryVariableProps = { name?: string };
|
|
|
|
|
|
|
|
|
|
export function QueryVariable({ name = 'query' }: QueryVariableProps) {
|
2025-06-03 15:40:04 +08:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const form = useFormContext();
|
2025-06-10 10:49:41 +08:00
|
|
|
|
2025-06-10 17:06:30 +08:00
|
|
|
const nextOptions = useBuildQueryVariableOptions();
|
2025-06-03 15:40:04 +08:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
2025-06-24 18:01:30 +08:00
|
|
|
name={name}
|
2025-06-03 15:40:04 +08:00
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<FormLabel tooltip={t('chat.modelTip')}>{t('flow.query')}</FormLabel>
|
|
|
|
|
<FormControl>
|
2025-06-10 10:49:41 +08:00
|
|
|
<SelectWithSearch
|
|
|
|
|
options={nextOptions}
|
|
|
|
|
{...field}
|
|
|
|
|
></SelectWithSearch>
|
2025-06-03 15:40:04 +08:00
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|