|
|
|
@ -163,6 +163,14 @@ export function QuestionBirthplace({ |
|
|
|
question.id?.includes("residence") || |
|
|
|
question.id?.includes("living_area") || |
|
|
|
question.id?.includes("location"); |
|
|
|
|
|
|
|
const isCurrentResidenceQuestion = Boolean( |
|
|
|
question.id === "contact_residence.current_residence_location" || |
|
|
|
question.id?.endsWith(".current_residence_location") || |
|
|
|
question.id?.endsWith(".current_residence") || |
|
|
|
question.ui_config?.read_only_fields === true |
|
|
|
); |
|
|
|
|
|
|
|
const storedRegion = isResidence ? getStoredUserGeoRegion() : null; |
|
|
|
|
|
|
|
const initial = parseValue(rawValue); |
|
|
|
@ -189,6 +197,13 @@ export function QuestionBirthplace({ |
|
|
|
|
|
|
|
const initialCity = hasSavedAnswer ? initial.city || "" : ""; |
|
|
|
|
|
|
|
const fallbackCountry = isResidence |
|
|
|
? resolveCountryName(storedRegion?.country, locale) || |
|
|
|
storedRegion?.country || |
|
|
|
"" |
|
|
|
: ""; |
|
|
|
const fallbackCity = isResidence ? storedRegion?.city || "" : ""; |
|
|
|
|
|
|
|
const initialLoc = |
|
|
|
localizedInitialCountry || initialCity |
|
|
|
? [localizedInitialCountry, initialCity].filter(Boolean).join(", ") |
|
|
|
@ -203,12 +218,14 @@ export function QuestionBirthplace({ |
|
|
|
: ""; |
|
|
|
|
|
|
|
const [selectedCountry, setSelectedCountry] = useState( |
|
|
|
() => localizedInitialCountry || "", |
|
|
|
() => localizedInitialCountry || fallbackCountry, |
|
|
|
); |
|
|
|
const [cityInput, setCityInput] = useState(() => initialCity); |
|
|
|
const [cityInput, setCityInput] = useState(() => initialCity || fallbackCity); |
|
|
|
|
|
|
|
const cityInputStateRef = useRef(initialCity); |
|
|
|
const selectedCountryStateRef = useRef(localizedInitialCountry || ""); |
|
|
|
const cityInputStateRef = useRef(initialCity || fallbackCity); |
|
|
|
const selectedCountryStateRef = useRef( |
|
|
|
localizedInitialCountry || fallbackCountry, |
|
|
|
); |
|
|
|
|
|
|
|
const lastCoordsRef = useRef<{ latitude?: number; longitude?: number } | undefined>( |
|
|
|
storedRegion?.latitude && storedRegion?.longitude |
|
|
|
@ -642,13 +659,16 @@ export function QuestionBirthplace({ |
|
|
|
<div className="relative w-full"> |
|
|
|
<button |
|
|
|
type="button" |
|
|
|
disabled={disabled} |
|
|
|
onClick={openSheet} |
|
|
|
disabled={disabled || isCurrentResidenceQuestion} |
|
|
|
onClick={isCurrentResidenceQuestion ? undefined : openSheet} |
|
|
|
aria-readonly={isCurrentResidenceQuestion} |
|
|
|
className={[ |
|
|
|
"flex h-[54px] w-full items-center justify-between rounded-[16px] border bg-white px-4.5 text-start transition-all cursor-pointer outline-none", |
|
|
|
isOpen |
|
|
|
? "border-[#6F6F6F] ring-1 ring-[#6F6F6F]" |
|
|
|
: "border-[#D0D5DD] hover:border-[#98A2B3]", |
|
|
|
"flex h-[54px] w-full items-center justify-between rounded-[16px] border bg-white px-4.5 text-start transition-all outline-none", |
|
|
|
isCurrentResidenceQuestion |
|
|
|
? "border-[#D0D5DD] cursor-default select-none" |
|
|
|
: isOpen |
|
|
|
? "border-[#6F6F6F] ring-1 ring-[#6F6F6F] cursor-pointer" |
|
|
|
: "border-[#D0D5DD] hover:border-[#98A2B3] cursor-pointer", |
|
|
|
].join(" ")} |
|
|
|
> |
|
|
|
<span |
|
|
|
@ -659,24 +679,26 @@ export function QuestionBirthplace({ |
|
|
|
> |
|
|
|
{selectedCountry || selectCountryPlaceholder} |
|
|
|
</span> |
|
|
|
<svg |
|
|
|
width="16" |
|
|
|
height="10" |
|
|
|
viewBox="0 0 16 10" |
|
|
|
fill="none" |
|
|
|
className={[ |
|
|
|
"shrink-0 transition-transform duration-200", |
|
|
|
isOpen ? "rotate-180" : "", |
|
|
|
].join(" ")} |
|
|
|
> |
|
|
|
<path |
|
|
|
d="M14.75 1.25L7.75 8.25L0.75 1.25" |
|
|
|
stroke="#344054" |
|
|
|
strokeWidth="1.75" |
|
|
|
strokeLinecap="round" |
|
|
|
strokeLinejoin="round" |
|
|
|
/> |
|
|
|
</svg> |
|
|
|
{!isCurrentResidenceQuestion && ( |
|
|
|
<svg |
|
|
|
width="16" |
|
|
|
height="10" |
|
|
|
viewBox="0 0 16 10" |
|
|
|
fill="none" |
|
|
|
className={[ |
|
|
|
"shrink-0 transition-transform duration-200", |
|
|
|
isOpen ? "rotate-180" : "", |
|
|
|
].join(" ")} |
|
|
|
> |
|
|
|
<path |
|
|
|
d="M14.75 1.25L7.75 8.25L0.75 1.25" |
|
|
|
stroke="#344054" |
|
|
|
strokeWidth="1.75" |
|
|
|
strokeLinecap="round" |
|
|
|
strokeLinejoin="round" |
|
|
|
/> |
|
|
|
</svg> |
|
|
|
)} |
|
|
|
</button> |
|
|
|
</div> |
|
|
|
|
|
|
|
@ -686,13 +708,19 @@ export function QuestionBirthplace({ |
|
|
|
ref={cityInputRef} |
|
|
|
type="text" |
|
|
|
data-no-auto-focus |
|
|
|
readOnly={isCurrentResidenceQuestion} |
|
|
|
disabled={disabled} |
|
|
|
value={cityInput} |
|
|
|
onChange={handleCityChange} |
|
|
|
onFocus={handleCityFocus} |
|
|
|
onBlur={handleCityBlur} |
|
|
|
onChange={isCurrentResidenceQuestion ? undefined : handleCityChange} |
|
|
|
onFocus={isCurrentResidenceQuestion ? (e) => e.target.blur() : handleCityFocus} |
|
|
|
onBlur={isCurrentResidenceQuestion ? undefined : handleCityBlur} |
|
|
|
placeholder={cityPlaceholder} |
|
|
|
className="h-[54px] w-full rounded-[16px] border border-[#D0D5DD] bg-white px-4.5 text-[15px] font-medium text-[#181818] placeholder:text-[#98A2B3] hover:border-[#98A2B3] focus:border-[#6F6F6F] focus:ring-1 focus:ring-[#6F6F6F] outline-none transition-all" |
|
|
|
className={[ |
|
|
|
"h-[54px] w-full rounded-[16px] border border-[#D0D5DD] bg-white px-4.5 text-[15px] font-medium text-[#181818] placeholder:text-[#98A2B3] outline-none transition-all", |
|
|
|
isCurrentResidenceQuestion |
|
|
|
? "cursor-default select-none focus:border-[#D0D5DD] focus:ring-0" |
|
|
|
: "hover:border-[#98A2B3] focus:border-[#6F6F6F] focus:ring-1 focus:ring-[#6F6F6F]", |
|
|
|
].join(" ")} |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</> |
|
|
|
|