import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { useAuthStore } from '../hooks/useAuth' import { useQuery } from '@tanstack/react-query' import api from '../utils/api' export default function LoginPage() { const [username, setUsername] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') const { login, isLoading } = useAuthStore() const navigate = useNavigate() const { data: pocketidData } = useQuery({ queryKey: ['pocketid-available'], queryFn: () => api.get('/auth/pocketid/available').then(r => r.data), }) const handleSubmit = async (e) => { e.preventDefault() setError('') try { await login(username, password) navigate('/') } catch (err) { setError(err.response?.data?.detail || 'Login failed') } } const handlePocketID = async () => { const { data } = await api.get('/auth/pocketid/login-url') window.location.href = data.url } return (

FitTracker

Your personal fitness dashboard

setUsername(e.target.value)} className="w-full bg-gray-800 border border-gray-700 rounded-lg px-3 py-2.5 text-sm text-white focus:outline-none focus:ring-2 focus:ring-blue-500" autoComplete="username" required />
setPassword(e.target.value)} className="w-full bg-gray-800 border border-gray-700 rounded-lg px-3 py-2.5 text-sm text-white focus:outline-none focus:ring-2 focus:ring-blue-500" autoComplete="current-password" required />
{error && (

{error}

)}
{pocketidData?.available && ( <>
or
)}
) }