'use client'; import React, { useState, useEffect } from 'react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { supabase } from '@/lib/supabase'; import { toast } from 'sonner'; import { Kanban, Loader2 } from 'lucide-react'; import Image from 'next/image'; import { useTheme } from 'next-themes'; import { ShineBorder } from '@/src/components/magicui/shine-border'; export default function SignUpPage() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [fullName, setFullName] = useState(''); const [loading, setLoading] = useState(false); const [checkingAuth, setCheckingAuth] = useState(true); const router = useRouter(); const { theme, setTheme } = useTheme(); useEffect(() => { // Check if user is already logged in const checkAuth = async () => { try { const { data: { session } } = await supabase.auth.getSession(); if (session?.user) { router.push('/dashboard'); return; } } catch (error) { console.error('Auth check error:', error); } finally { setCheckingAuth(false); } }; checkAuth(); }, [router]); const handleSignUp = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); try { const { error } = await supabase.auth.signUp({ email, password, options: { data: { full_name: fullName, }, }, }); if (error) { toast.error(error.message); } else { toast.success('Account created successfully! Please check your email to verify your account.'); router.push('/login'); } } catch (error) { toast.error('An unexpected error occurred'); } finally { setLoading(false); } }; const handleOAuthSignIn = async (provider: 'google' | 'github') => { setLoading(true); try { const { error } = await supabase.auth.signInWithOAuth({ provider, options: { redirectTo: `${window.location.origin}/dashboard`, }, }); if (error) { toast.error(error.message); } } catch (error) { toast.error('An unexpected error occurred'); } finally { setLoading(false); } }; if (checkingAuth) { return (