feat(google): add toast to display error message from google

This commit is contained in:
Amruth Pillai
2022-07-13 11:05:27 +02:00
parent 1c3beee6cd
commit 25cf594eb9
2 changed files with 11 additions and 3 deletions

View File

@ -87,16 +87,24 @@ const LoginModal: React.FC = () => {
const handleLoginWithGoogle = async () => { const handleLoginWithGoogle = async () => {
google.accounts.id.initialize({ google.accounts.id.initialize({
auto_select: true,
itp_support: true,
client_id: env('GOOGLE_CLIENT_ID'), client_id: env('GOOGLE_CLIENT_ID'),
callback: async (response: any) => { callback: async (response: any) => {
await loginWithGoogleMutation({ credential: response.credential }); await loginWithGoogleMutation({ credential: response.credential });
handleClose(); handleClose();
}, },
auto_select: false,
}); });
google.accounts.id.prompt(); google.accounts.id.prompt((notification: any) => {
if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
const reason = notification.getNotDisplayedReason() || notification.getSkippedReason();
toast.error(`Google returned an error while trying to sign in: ${reason}.`);
toast("Please try logging in using email/password, or use another browser that supports Google's One Tap API.");
}
});
}; };
const PasswordVisibility = (): React.ReactElement => { const PasswordVisibility = (): React.ReactElement => {

View File

@ -54,7 +54,7 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
</LocalizationProvider> </LocalizationProvider>
</ReduxProvider> </ReduxProvider>
<Script src="https://accounts.google.com/gsi/client" /> <Script src="https://accounts.google.com/gsi/client" async defer />
</> </>
); );
}; };