fix country modal show
This commit is contained in:
parent
7de1ce9611
commit
a662126cd0
|
@ -231,12 +231,11 @@ const RestrictedCountryCheck = () => {
|
||||||
NON_RESTRICTED_JURISDICTION_KEY,
|
NON_RESTRICTED_JURISDICTION_KEY,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
const [showModal, setShowModal] = useState(false)
|
|
||||||
|
|
||||||
useEffect(() => {
|
console.log(loadingIpCountry)
|
||||||
if (!confirmedCountry && !ipCountry && !loadingIpCountry) {
|
|
||||||
setShowModal(true)
|
const showModal = useMemo(() => {
|
||||||
}
|
return !confirmedCountry && !ipCountry && !loadingIpCountry
|
||||||
}, [confirmedCountry, ipCountry, loadingIpCountry])
|
}, [confirmedCountry, ipCountry, loadingIpCountry])
|
||||||
|
|
||||||
return showModal ? (
|
return showModal ? (
|
||||||
|
|
|
@ -66,17 +66,16 @@ export default function useIpAddress() {
|
||||||
const [showWarning, setShowWarning] = useState(false)
|
const [showWarning, setShowWarning] = useState(false)
|
||||||
const [ipCountry, setIpCountry] = useState('')
|
const [ipCountry, setIpCountry] = useState('')
|
||||||
|
|
||||||
const {
|
const { data: ipCountryCode, isInitialLoading } = useQuery<string, Error>(
|
||||||
data: ipCountryCode,
|
['ip-address'],
|
||||||
isInitialLoading,
|
() => fetchIpGeolocation(),
|
||||||
isFetching,
|
{
|
||||||
isLoading,
|
|
||||||
} = useQuery<string, Error>(['ip-address'], () => fetchIpGeolocation(), {
|
|
||||||
cacheTime: 1000 * 60 * 2,
|
cacheTime: 1000 * 60 * 2,
|
||||||
staleTime: 1000 * 60 * 2,
|
staleTime: 1000 * 60 * 2,
|
||||||
retry: 3,
|
retry: 3,
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ipCountryCode) {
|
if (ipCountryCode) {
|
||||||
|
@ -90,8 +89,6 @@ export default function useIpAddress() {
|
||||||
}
|
}
|
||||||
}, [ipCountryCode])
|
}, [ipCountryCode])
|
||||||
|
|
||||||
const loadingIpCountry = isInitialLoading || isFetching || isLoading
|
|
||||||
|
|
||||||
if (CLUSTER === 'mainnet-beta' && !process.env.NEXT_PUBLIC_DISABLE_GEOBLOCK) {
|
if (CLUSTER === 'mainnet-beta' && !process.env.NEXT_PUBLIC_DISABLE_GEOBLOCK) {
|
||||||
return {
|
return {
|
||||||
ipAllowed,
|
ipAllowed,
|
||||||
|
@ -101,7 +98,7 @@ export default function useIpAddress() {
|
||||||
borrowLendAllowed,
|
borrowLendAllowed,
|
||||||
showWarning,
|
showWarning,
|
||||||
ipCountry,
|
ipCountry,
|
||||||
loadingIpCountry,
|
loadingIpCountry: isInitialLoading,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
@ -112,7 +109,7 @@ export default function useIpAddress() {
|
||||||
borrowLendAllowed: true,
|
borrowLendAllowed: true,
|
||||||
showWarning: true,
|
showWarning: true,
|
||||||
ipCountry,
|
ipCountry,
|
||||||
loadingIpCountry,
|
loadingIpCountry: isInitialLoading,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue