import { useState } from 'react'; import { Link, useLocation, useNavigate } from 'react-router-dom'; import { AuthLayout } from '../components/app/AuthLayout'; import { useAuth } from '../features/auth/useAuth'; import { login } from '../lib/api'; export default function LoginPage() { const navigate = useNavigate(); const location = useLocation(); const { setUser } = useAuth(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [submitting, setSubmitting] = useState(false); async function submit(event: React.FormEvent) { event.preventDefault(); setSubmitting(true); setError(''); try { const user = await login(email, password); setUser(user); const destination = (location.state as { from?: string } | null)?.from || '/dashboard'; navigate(destination, { replace: true }); } catch (reason) { setError(reason instanceof Error ? reason.message : 'Could not sign in.'); } finally { setSubmitting(false); } } return (

Welcome back

Your work,
waiting.

Sign in to keep shaping the way your clients experience their photographs.

{error &&

{error}

}

New to Northline? Create an account

); }