Files
ragflow/web/src/components/excel-to-html-form-field.tsx
BlueYu-0221 fa3e90c72e Refactor: Datasets UI #3221 (#8349)
### What problem does this PR solve?

Refactor Datasets UI #3221.
### Type of change

- [X] New Feature (non-breaking change which adds functionality)
2025-06-19 16:40:30 +08:00

54 lines
1.5 KiB
TypeScript

import { useTranslate } from '@/hooks/common-hooks';
import { useFormContext } from 'react-hook-form';
import {
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from './ui/form';
import { Switch } from './ui/switch';
export function ExcelToHtmlFormField() {
const form = useFormContext();
const { t } = useTranslate('knowledgeDetails');
return (
<FormField
control={form.control}
name="parser_config.html4excel"
render={({ field }) => {
if (typeof field.value === 'undefined') {
// default value set
form.setValue('parser_config.html4excel', false);
}
return (
<FormItem defaultChecked={false} className=" items-center space-y-0 ">
<div className="flex items-center">
<FormLabel
tooltip={t('html4excelTip')}
className="text-sm text-muted-foreground whitespace-nowrap w-1/4"
>
{t('html4excel')}
</FormLabel>
<div className="w-3/4">
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
></Switch>
</FormControl>
</div>
</div>
<div className="flex pt-1">
<div className="w-1/4"></div>
<FormMessage />
</div>
</FormItem>
);
}}
/>
);
}