Feat: Retrieval test #3221 (#7121)

### What problem does this PR solve?

Feat: Retrieval test #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-04-17 19:03:55 +08:00
committed by GitHub
parent db82c15de4
commit 86f76df586
8 changed files with 147 additions and 124 deletions

View File

@ -5,15 +5,23 @@ import {
FormLabel,
} from '@/components/ui/form';
import { Switch } from '@/components/ui/switch';
import { cn } from '@/lib/utils';
import { ReactNode } from 'react';
import { useFormContext } from 'react-hook-form';
interface SwitchFormItemProps {
name: string;
label: ReactNode;
vertical?: boolean;
tooltip?: ReactNode;
}
export function SwitchFormField({ label, name }: SwitchFormItemProps) {
export function SwitchFormField({
label,
name,
vertical = true,
tooltip,
}: SwitchFormItemProps) {
const form = useFormContext();
return (
@ -21,8 +29,14 @@ export function SwitchFormField({ label, name }: SwitchFormItemProps) {
control={form.control}
name={name}
render={({ field }) => (
<FormItem className="flex justify-between">
<FormLabel className="text-base">{label}</FormLabel>
<FormItem
className={cn('flex', {
'gap-2': vertical,
'flex-col': vertical,
'justify-between': !vertical,
})}
>
<FormLabel tooltip={tooltip}>{label}</FormLabel>
<FormControl>
<Switch
checked={field.value}