"use client"; import { useEffect, useState } from "react"; import { doesSessionExist } from "supertokens-web-js/recipe/thirdpartyemailpassword"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; export default function SuperTokensAuthComponent() { const router = useRouter(); const [isLoading, setIsLoading] = useState(false); useEffect(() => { // Check if user is already logged in doesSessionExist().then((exists) => { if (exists) { router.push("/marks-account/projects"); } }); }, [router]); const handleGoogleSignIn = async () => { setIsLoading(true); try { // Get Google OAuth URL from SuperTokens const response = await fetch("/api/auth/authorisationurl?thirdPartyId=google"); const data = await response.json(); if (data.status === "OK") { // Redirect to Google OAuth window.location.href = data.urlWithQueryParams; } else { console.error("Failed to get auth URL:", data); setIsLoading(false); } } catch (error) { console.error("Google sign-in error:", error); setIsLoading(false); } }; return (
{/* Logo */}
Vib'n
{/* Auth Card */} Welcome to Vib'n Sign in to continue {/* Footer */}

By continuing, you agree to our Terms of Service and Privacy Policy.

); }