diff --git a/src/components/Componentes/question-birthplace.tsx b/src/components/Componentes/question-birthplace.tsx index d821b2d..067844c 100644 --- a/src/components/Componentes/question-birthplace.tsx +++ b/src/components/Componentes/question-birthplace.tsx @@ -1,12 +1,13 @@ "use client"; -import { useCallback, useEffect, useRef, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { createPortal } from "react-dom"; import { Ic } from "@/icons"; import { getCountryList, resolveCountryName, isKnownCountry, + filterCountryOptions, } from "@/data/countries"; import type { QuestionField } from "@/lib/schema-adapter"; import { useI18n } from "@/translations/provider"; @@ -433,9 +434,10 @@ export function QuestionBirthplace({ lastInternalAnswerRef.current = rawValue as BirthplaceValue | string | null; }, [rawValue, locale, selectedCountry, cityInput]); - const options = getCountryList(locale); - const filteredOptions = options.filter((option) => - option.toLowerCase().includes(searchQuery.toLowerCase()), + const options = useMemo(() => getCountryList(locale), [locale]); + const filteredOptions = useMemo( + () => filterCountryOptions(options, searchQuery, locale), + [options, searchQuery, locale], ); const handleSelectCountry = (country: string) => { @@ -486,26 +488,33 @@ export function QuestionBirthplace({ }; const isRtl = locale === "fa" || locale === "ar" || locale === "ur"; - const selectCountryPlaceholder = isRtl ? "انتخاب کشور" : "Select country"; + const selectCountryPlaceholder = + t["Select country"] || (isRtl ? "انتخاب کشور" : "Select country"); const cityPlaceholder = question.extras?.placeHolder || (isRtl ? "شهر، منطقه یا محله" : "City, region, or neighborhood"); const searchPlaceholder = - locale === "fa" + t["Search..."] || + (locale === "fa" ? "جستجو..." : locale === "ar" ? "بحث..." : locale === "tr" ? "Ara..." - : "Search..."; + : locale === "ru" + ? "Поиск..." + : "Search..."); const noResultsText = - locale === "fa" + t["No options found"] || + (locale === "fa" ? "موردی یافت نشد" : locale === "ar" ? "لم يتم العثور على نتائج" - : "No options found"; + : locale === "ru" + ? "Ничего не найдено" + : "No options found"); return (