import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Checkbox } from "@/components/ui/checkbox"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { toast } from "sonner"; import { HiOutlineUpload } from "react-icons/hi"; import { MdOutlineAttachFile } from "react-icons/md"; import CustomLink from "@/components/Common/CustomLink"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Label } from "@/components/ui/label"; import { handleKeyDown, inpNum, t } from "@/utils"; import CustomImage from "@/components/Common/CustomImage"; const ComponentThree = ({ customFields, setExtraDetails, filePreviews, setFilePreviews, setStep, handleGoBack, currentExtraDetails, langId, defaultLangId, }) => { const write = (fieldId, value) => setExtraDetails((prev) => ({ ...prev, [langId]: { ...prev[langId], [fieldId]: value, }, })); const handleFileChange = (id, file) => { if (file) { const allowedExtensions = /\.(jpg|jpeg|svg|png|pdf)$/i; if (!allowedExtensions.test(file.name)) { toast.error(t("notAllowedFile")); return; } const fileUrl = URL.createObjectURL(file); setFilePreviews((prev) => { const oldUrl = prev?.[langId]?.[id]?.url; if (oldUrl) { URL.revokeObjectURL(oldUrl); } return { ...prev, [langId]: { ...(prev[langId] || {}), [id]: { url: fileUrl, isPdf: /\.pdf$/i.test(file.name), }, }, }; }); write(id, file); } }; const handleChange = (id, value) => write(id, value ?? ""); const handleCheckboxChange = (id, value, checked) => { const list = currentExtraDetails[id] || []; const next = checked ? [...list, value] : list.filter((v) => v !== value); write(id, next); }; const renderCustomFields = (field) => { let { id, name, translated_name, type, translated_value, values, min_length, max_length, is_required, } = field; const inputProps = { id, name: id, required: !!is_required, onChange: (e) => handleChange(id, e.target.value), value: currentExtraDetails[id] || "", ...(type === "number" ? { min: min_length, max: max_length } : { minLength: min_length, maxLength: max_length }), }; switch (type) { case "number": { return (