@@ -4,30 +4,26 @@ import { useToast } from "@/hooks/use-toast";
44import { Button } from "@/components/ui/button" ;
55import { Chrome , Loader2 } from "lucide-react" ;
66import { useTranslation } from "react-i18next" ;
7+ import { useParams } from "react-router-dom" ;
78
89interface GoogleOAuthButtonProps {
910 onSuccess ?: ( ) => void ;
1011 onError ?: ( error : string ) => void ;
1112 inviteToken ?: string ;
1213}
1314
14- export function GoogleOAuthButton ( {
15- onSuccess : _onSuccess ,
16- onError,
17- inviteToken,
18- } : GoogleOAuthButtonProps ) {
15+ export function GoogleOAuthButton ( { onSuccess : _onSuccess , onError } : GoogleOAuthButtonProps ) {
1916 const [ isLoading , setIsLoading ] = useState ( false ) ;
17+ const { slug } = useParams < { slug : string } > ( ) ;
2018 const { t } = useTranslation ( "auth" ) ;
2119 const { toast } = useToast ( ) ;
2220
2321 const handleGoogleSignIn = async ( ) => {
2422 setIsLoading ( true ) ;
2523 try {
2624 // Include invite token in redirect URL for tenant flows
27- const redirectTo = inviteToken
28- ? `${ window . location . origin } /auth/callback?inviteToken=${ inviteToken } `
29- : `${ window . location . origin } /auth/callback` ;
30-
25+ const authPath = slug ? `/tenant/${ slug } /auth` : "/auth" ;
26+ const redirectTo = window . location . origin + authPath ;
3127 const { data : _data , error } = await supabase . auth . signInWithOAuth ( {
3228 provider : "google" ,
3329 options : {
0 commit comments