fix country modal show

This commit is contained in:
saml33 2024-01-06 22:52:31 +11:00
parent 7de1ce9611
commit a662126cd0
2 changed files with 16 additions and 20 deletions

View File

@ -231,12 +231,11 @@ const RestrictedCountryCheck = () => {
NON_RESTRICTED_JURISDICTION_KEY,
false,
)
const [showModal, setShowModal] = useState(false)
useEffect(() => {
if (!confirmedCountry && !ipCountry && !loadingIpCountry) {
setShowModal(true)
}
console.log(loadingIpCountry)
const showModal = useMemo(() => {
return !confirmedCountry && !ipCountry && !loadingIpCountry
}, [confirmedCountry, ipCountry, loadingIpCountry])
return showModal ? (

View File

@ -66,17 +66,16 @@ export default function useIpAddress() {
const [showWarning, setShowWarning] = useState(false)
const [ipCountry, setIpCountry] = useState('')
const {
data: ipCountryCode,
isInitialLoading,
isFetching,
isLoading,
} = useQuery<string, Error>(['ip-address'], () => fetchIpGeolocation(), {
cacheTime: 1000 * 60 * 2,
staleTime: 1000 * 60 * 2,
retry: 3,
refetchOnWindowFocus: true,
})
const { data: ipCountryCode, isInitialLoading } = useQuery<string, Error>(
['ip-address'],
() => fetchIpGeolocation(),
{
cacheTime: 1000 * 60 * 2,
staleTime: 1000 * 60 * 2,
retry: 3,
refetchOnWindowFocus: true,
},
)
useEffect(() => {
if (ipCountryCode) {
@ -90,8 +89,6 @@ export default function useIpAddress() {
}
}, [ipCountryCode])
const loadingIpCountry = isInitialLoading || isFetching || isLoading
if (CLUSTER === 'mainnet-beta' && !process.env.NEXT_PUBLIC_DISABLE_GEOBLOCK) {
return {
ipAllowed,
@ -101,7 +98,7 @@ export default function useIpAddress() {
borrowLendAllowed,
showWarning,
ipCountry,
loadingIpCountry,
loadingIpCountry: isInitialLoading,
}
} else {
return {
@ -112,7 +109,7 @@ export default function useIpAddress() {
borrowLendAllowed: true,
showWarning: true,
ipCountry,
loadingIpCountry,
loadingIpCountry: isInitialLoading,
}
}
}