import React, { useState } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { useAuthStore } from '../../stores/authStore'; export function LoginPage() { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const login = useAuthStore((s) => s.login); const isLoading = useAuthStore((s) => s.isLoading); const navigate = useNavigate(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); if (!username.trim()) { setError('Username is required'); return; } if (!password) { setError('Password is required'); return; } try { await login(username.trim(), password); navigate('/channels/@me'); } catch (err) { setError(err instanceof Error ? err.message : 'Login failed'); } }; return (

Welcome back!

We're so excited to see you again!

{error && (
{error}
)}
setUsername(e.target.value)} className="w-full px-3 py-2.5 bg-discord-bg-tertiary border-none rounded text-discord-text-primary outline-none focus:ring-2 focus:ring-discord-blurple transition-all" autoFocus autoComplete="username" />
setPassword(e.target.value)} className="w-full px-3 py-2.5 bg-discord-bg-tertiary border-none rounded text-discord-text-primary outline-none focus:ring-2 focus:ring-discord-blurple transition-all" autoComplete="current-password" />

Need an account?{' '} Register

); }