import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Textarea } from "@/components/ui/textarea"; import { getIsRtl } from "@/redux/reducer/languageSlice"; import { getCurrencyIsoCode, getCurrencyPosition, getCurrencySymbol, } from "@/redux/reducer/settingSlice"; import { generateSlug, t } from "@/utils"; import PhoneInput from "react-phone-input-2"; import { useSelector } from "react-redux"; const EditComponentOne = ({ setTranslations, current, langId, defaultLangId, handleDetailsSubmit, is_job_category, isPriceOptional, currencies, }) => { const currencyPosition = useSelector(getCurrencyPosition); const currencySymbol = useSelector(getCurrencySymbol); const currencyIsoCode = useSelector(getCurrencyIsoCode); const isRTL = useSelector(getIsRtl); const selectedCurrency = currencies?.find( (curr) => curr?.id === current?.currency_id ); // Use selected currency's symbol and position, or fallback to Redux settings const displaySymbol = selectedCurrency?.symbol || currencySymbol; const displayPosition = selectedCurrency?.position || currencyPosition; const placeholderLabel = displayPosition === "right" ? `00 ${displaySymbol}` : `${displaySymbol} 00`; const handleField = (field) => (e) => { const value = e.target.value; setTranslations((prev) => { const updatedLangData = { ...prev[langId], [field]: value, }; // ✅ Only auto-generate slug if default language and field is title if (field === "name" && langId === defaultLangId) { updatedLangData.slug = generateSlug(value); } return { ...prev, [langId]: updatedLangData, }; }); }; const handlePhoneChange = (value, data) => { const dial = data?.dialCode || ""; // Dial code like "91", "1" const iso2 = data?.countryCode || ""; // Region code like "in", "us", "ae" setTranslations((prev) => { const pureMobile = value.startsWith(dial) ? value.slice(dial.length) : value; return { ...prev, [langId]: { ...prev[langId], contact: pureMobile, country_code: dial, region_code: iso2, }, }; }); }; const handleCurrencyChange = (currencyId) => { setTranslations((prev) => ({ ...prev, [langId]: { ...prev[langId], currency_id: Number(currencyId), }, })); }; return (