'use client'; import { useRef, useState } from 'react'; import { useRouter } from 'next/navigation'; import { createClient } from '@/lib/supabase/client'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Label } from '@/components/ui/label'; import { X } from 'lucide-react'; import Link from 'next/link'; import HCaptcha from '@hcaptcha/react-hcaptcha'; export default function RegisterPage() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const [success, setSuccess] = useState(false); const [captchaToken, setCaptchaToken] = useState(null); const captchaRef = useRef(null); const router = useRouter(); const supabase = createClient(); const handleGoogleSignup = async () => { setLoading(true); const { error } = await supabase.auth.signInWithOAuth({ provider: 'google', options: { redirectTo: `${location.origin}/auth/callback`, }, }); if (error) { setError(error.message); setLoading(false); } }; const handleRegister = async (e: React.FormEvent) => { e.preventDefault(); if (!captchaToken) { setError('Please complete the captcha'); return; } setLoading(true); setError(''); const { error } = await supabase.auth.signUp({ email, password, options: { captchaToken, }, }); if (error) { setError(error.message); setLoading(false); setCaptchaToken(null); captchaRef.current?.resetCaptcha(); } else { setSuccess(true); setLoading(false); } }; if (success) { return (
Check Your Email We have sent a verification link to {email}.
); } return (
Join Cineprime Today
setEmail(e.target.value)} className="bg-black/40 border-gray-600 text-white placeholder:text-gray-500 h-12" required />
setPassword(e.target.value)} className="bg-black/40 border-gray-600 text-white h-12" required minLength={6} />
{error && (
{error}
)}
setCaptchaToken(token)} onExpire={() => setCaptchaToken(null)} ref={captchaRef} theme="dark" />
Already have an account? Log In
); }