-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #990 from basedosdados/development
Development
- Loading branch information
Showing
60 changed files
with
1,107 additions
and
567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Menu, MenuButton, MenuList, MenuItem, Button } from "@chakra-ui/react"; | ||
import { useRouter } from "next/router"; | ||
import { useTranslation } from "next-i18next"; | ||
import LanguageIcon from "../../public/img/icons/languageIcon"; | ||
|
||
export default function LanguageSelector() { | ||
const { locale } = useRouter(); | ||
const router = useRouter(); | ||
|
||
const changeLanguage = (locale) => { | ||
router.push(router.pathname, router.asPath, { locale }); | ||
}; | ||
|
||
return ( | ||
<Menu> | ||
<MenuButton as={Button} rightIcon={<LanguageIcon />} variant="ghost"> | ||
{locale === 'pt' ? 'PT' : locale === 'en' ? 'EN' : 'ES'} | ||
</MenuButton> | ||
<MenuList> | ||
<MenuItem onClick={() => changeLanguage('pt')}>Português</MenuItem> | ||
<MenuItem onClick={() => changeLanguage('en')}>English</MenuItem> | ||
<MenuItem onClick={() => changeLanguage('es')}>Español</MenuItem> | ||
</MenuList> | ||
</Menu> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useEffect } from 'react'; | ||
import Script from 'next/script'; | ||
import { useRouter } from 'next/router'; | ||
|
||
const PayPalButton = () => { | ||
const router = useRouter(); | ||
const { locale } = router; | ||
|
||
useEffect(() => { | ||
const renderButton = () => { | ||
if (window.paypal) { | ||
const buttonConfig = getButtonConfig(locale); | ||
window.paypal.HostedButtons({ | ||
hostedButtonId: buttonConfig.id, | ||
}).render(`#paypal-container-${buttonConfig.id}`); | ||
} | ||
}; | ||
|
||
if (window.paypal) { | ||
renderButton(); | ||
} else { | ||
window.renderPayPalButton = renderButton; | ||
} | ||
}, [locale]); | ||
|
||
const getButtonConfig = (locale) => { | ||
switch (locale) { | ||
case 'en': | ||
return { id: '7Z8VZRT49598E', localeParam: 'en_US' }; | ||
case 'es': | ||
return { id: '9T4KS6AZABF92', localeParam: 'es_ES' }; | ||
default: | ||
return { id: '9XUDXZSNZFS84', localeParam: 'pt_BR' }; | ||
} | ||
}; | ||
|
||
const buttonConfig = getButtonConfig(locale); | ||
|
||
return ( | ||
<> | ||
<Script | ||
src={`https://www.paypal.com/sdk/js?client-id=BAAMRKxOIs8HZRucUi9h6KGCm--Le5G4bexjKHt6phnjlGLYPvr4VvXNxKuABcWPY8Cr6-E3AydIRd0r-4&components=hosted-buttons&disable-funding=venmo&locale=${buttonConfig.localeParam}`} | ||
onLoad={() => { | ||
if (window.renderPayPalButton) { | ||
window.renderPayPalButton(); | ||
} | ||
}} | ||
/> | ||
<div id={`paypal-container-${buttonConfig.id}`}></div> | ||
</> | ||
); | ||
}; | ||
|
||
export default PayPalButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.