diff --git a/src/app/client-login/page.tsx b/src/app/client-login/page.tsx new file mode 100644 index 0000000..76acfa1 --- /dev/null +++ b/src/app/client-login/page.tsx @@ -0,0 +1,105 @@ +'use client'; + +import { useState } from 'react'; +import { useRouter } from 'next/navigation'; + +export default function ClientLoginPage() { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [error, setError] = useState(''); + const [loading, setLoading] = useState(false); + const router = useRouter(); + + const handleLogin = async (e: React.FormEvent) => { + e.preventDefault(); + setError(''); + setLoading(true); + + try { + // Call WP auth endpoint + const res = await fetch('/api/auth/wp-login', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ email, password }), + }); + + const data = await res.json(); + + if (!res.ok) { + setError(data.error || 'Login failed'); + return; + } + + // Redirect to contributor dashboard + router.push('/contributor'); + } catch (err: any) { + setError(err.message || 'An error occurred'); + } finally { + setLoading(false); + } + }; + + return ( +
Contributor Portal
++ New contributor?{' '} + + Register here + +
+