import { GoogleAuthProvider, signInWithRedirect } from "firebase/auth"; import { getFirebaseAuth } from "@vertesia/ui/session"; import { Button } from "@vertesia/ui/core"; import { useUITranslation } from "@vertesia/ui/i18n"; interface GoogleSignInButtonProps { redirectTo?: string; } export default function GoogleSignInButton({ redirectTo }: GoogleSignInButtonProps) { const { t } = useUITranslation(); const signIn = () => { localStorage.removeItem("tenantName"); let redirectPath = redirectTo || window.location.pathname || '/'; if (redirectPath[0] !== '/') { redirectPath = '/' + redirectPath; } const provider = new GoogleAuthProvider(); provider.addScope('profile'); provider.addScope('email'); // always ask to select the google account //console.log('redirectPath', window.location.origin + redirectPath) provider.setCustomParameters({ prompt: 'select_account', redirect_uri: window.location.origin + redirectPath }); signInWithRedirect(getFirebaseAuth(), provider); }; return ( ); }