import { useEffect } from 'react'; import { useSearchParams } from 'react-router-dom'; import { toast } from 'sonner'; import { useAuthStore } from '../stores/authStore'; const LoginPage = () => { const [searchParams] = useSearchParams(); const { login } = useAuthStore(); useEffect(() => { const token = searchParams.get('token'); const error = searchParams.get('error'); if (error) { toast.error('Authentication failed. Please try again.'); } else if (token) { const userData = { id: searchParams.get('user_id') || '', username: searchParams.get('username') || '', discriminator: searchParams.get('discriminator') || '', avatar: searchParams.get('avatar'), }; login(token, userData); toast.success('Successfully logged in!'); } }, [searchParams, login]); const handleDiscordLogin = async () => { try { window.location.href = `${import.meta.env.VITE_FRONTEND_URL}/api/auth/discord`; } catch (_error) { toast.error('Failed to initiate Discord login'); } }; return (
Aethel Bot Logo

Aethel Dashboard

Manage your todos and AI API keys

Welcome back

Sign in with your Discord account to continue

By signing in, you agree to our terms of service and privacy policy.

Need help? Contact us on our Discord server

); }; export default LoginPage;