|
|
|
@ -10,7 +10,7 @@ import QuestionTitle from "./question-title"; |
|
|
|
import { LoadingThreeDot } from "./loading-three-dot"; |
|
|
|
import { useSheetScrollLock } from "./use-sheet-scroll-lock"; |
|
|
|
import { Input } from "@/components/ui/input"; |
|
|
|
import { getUserGeoRegion } from "@/lib/geo-region"; |
|
|
|
import { getUserGeoRegion, getStoredUserGeoRegion } from "@/lib/geo-region"; |
|
|
|
|
|
|
|
const EXIT_ANIMATION_MS = 220; |
|
|
|
|
|
|
|
@ -89,9 +89,23 @@ export function QuestionBirthplace({ |
|
|
|
const { getAnswerValue, setAnswerValue, isLoading } = useQuestionAnswers(); |
|
|
|
const rawValue = getAnswerValue(question); |
|
|
|
|
|
|
|
const isResidence = question.ui_config?.enable_geoip === true; |
|
|
|
const storedRegion = isResidence ? getStoredUserGeoRegion() : null; |
|
|
|
|
|
|
|
const initial = parseValue(rawValue); |
|
|
|
const [selectedCountry, setSelectedCountry] = useState(initial.country); |
|
|
|
const [cityInput, setCityInput] = useState(initial.city); |
|
|
|
const initialLoc = |
|
|
|
initial.country || initial.city |
|
|
|
? [initial.city, initial.country].filter(Boolean).join(", ") |
|
|
|
: storedRegion?.city || storedRegion?.country |
|
|
|
? [storedRegion.city, storedRegion.country].filter(Boolean).join(", ") |
|
|
|
: ""; |
|
|
|
|
|
|
|
const [selectedCountry, setSelectedCountry] = useState( |
|
|
|
() => initial.country || storedRegion?.country || "", |
|
|
|
); |
|
|
|
const [cityInput, setCityInput] = useState( |
|
|
|
() => initial.city || storedRegion?.city || "", |
|
|
|
); |
|
|
|
|
|
|
|
const [isOpen, setIsOpen] = useState(false); |
|
|
|
const [isClosing, setIsClosing] = useState(false); |
|
|
|
@ -100,11 +114,9 @@ export function QuestionBirthplace({ |
|
|
|
const listRef = useRef<HTMLDivElement>(null); |
|
|
|
const isMountedRef = useRef(true); |
|
|
|
|
|
|
|
const isResidence = question.ui_config?.enable_geoip === true; |
|
|
|
|
|
|
|
const [mode, setMode] = useState<"auto" | "manual">("auto"); |
|
|
|
const [isDetecting, setIsDetecting] = useState(false); |
|
|
|
const [detectedLocation, setDetectedLocation] = useState(""); |
|
|
|
const [detectedLocation, setDetectedLocation] = useState(initialLoc); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
isMountedRef.current = true; |
|
|
|
|