update FramelessButton, PhoneInput, TextInput
- FramelessButton: use cursor-pointer - PhoneInput: add setCountryByIP with geo lookup - TextInput: add $bindable ref property
This commit is contained in:
@@ -63,6 +63,20 @@
|
||||
}
|
||||
};
|
||||
|
||||
// setCountryByIP queries ip-api.com for user location based on IP
|
||||
export const setCountryByIP = async (ip: string) => {
|
||||
const res = await fetch(`http://ip-api.com/json/${ip}`);
|
||||
const locationData = await res.json();
|
||||
let country = 'CA'; // default to Canada
|
||||
if (locationData.status !== 'fail') {
|
||||
const { countryCode } = locationData;
|
||||
country = countryCode;
|
||||
console.log('updating country code according to IP', country);
|
||||
}
|
||||
|
||||
setCountryByISO(country);
|
||||
};
|
||||
|
||||
// set the default country based on the provided ISO code
|
||||
if (defaultISO) {
|
||||
setCountryByISO(defaultISO);
|
||||
|
||||
Reference in New Issue
Block a user