import { Card, CardContent } from "@/components/ui/card"; import { TabsContent } from "@/components/ui/tabs"; import { FormSchema } from "@/types/schema"; import { t } from "i18next"; import { useState } from "react"; import { FormProvider, UseFormReturn } from "react-hook-form"; import { FormControl, FormField, FormItem, FormLabel } from "../ui/form"; import { Input } from "../ui/input"; import { Label } from "../ui/label"; import { RadioGroup, RadioGroupItem } from "../ui/radio-group"; import { Textarea } from "../ui/textarea"; import { OptionalClassFormField } from "./classname-field"; import { ShellTypeFormField } from "./shelltype-field"; import { UrlPatternFormField } from "./urlpattern-field"; export default function CustomTabContent({ form, shellTypes, }: Readonly<{ form: UseFormReturn; shellTypes: Array }>) { const [isFile, setIsFile] = useState(false); return (
( {t("shellToolConfig.base64String")} { field.onChange(""); setIsFile(value === "file"); }} className="flex items-center space-x-2" >
{isFile ? ( { const file = e.target.files?.[0]; if (file) { const reader = new FileReader(); reader.onload = (event) => { const base64String = (event.target?.result as string)?.split(",")[1] || ""; field.onChange(base64String); }; reader.readAsDataURL(file); } }} accept=".class" placeholder={t("placeholders.input")} type="file" /> ) : (