Skip to content

Commit

Permalink
Update BuyACoffee.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tmoitie authored Jan 29, 2025
1 parent 1dba2bd commit 82f9a8e
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions src/components/BuyACoffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,15 @@ import styles from './styles/buyACoffee.module.css';

export default function BuyACoffee(): React.Node {
const { t, i18n } = useTranslation();
const getBCUrl = async () => {
let response;
try {
response = await axios.get('https://geolocation-db.com/json/09068b10-55fe-11eb-8939-299a0c3ab5e5', {
headers: { Accept: '' }, // Avoid OPTION
});
} catch (error) {
if (i18n.language === 'en-GB') {
return 'https://www.buymeacoffee.com/iwpgbp';
}
if (['es', 'fr', 'de'].includes(i18n.language)) {
return 'https://www.buymeacoffee.com/iwpeur';
}
return 'https://www.buymeacoffee.com/tmoitie';
}

if (response.data.country_code === 'GB') {
return 'https://www.buymeacoffee.com/iwpgbp';
}

const euroCountries = [
'AT', 'BE', 'CY', 'EE', 'FI', 'FR', 'DE', 'GR', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PT', 'ES', 'SI', 'SK',
'XK', 'ME', 'AD', 'MC', 'SM', 'VA',
];

if (euroCountries.includes(response.data.country_code)) {
return 'https://www.buymeacoffee.com/iwpeur';
}

return 'https://www.buymeacoffee.com/tmoitie';
};

const clickBuyCoffee = async () => {
const clickBuyCoffee = () => {
window.dataLayer.push({
event: 'select_content',
contentType: 'sponsor',
contentID: 'Buy A Coffee',
});

window.location.assign(await getBCUrl());
window.location.assign('https://www.buymeacoffee.com/tmoitie');
};

return (
Expand Down

0 comments on commit 82f9a8e

Please sign in to comment.