import { useState, type FormEvent } from 'react'; import { IgrButton, IgrIcon, IgrInput } from 'igniteui-react'; import { useAuth } from '../AuthContext'; import { ExternalAuth } from '../services/externalAuth'; import type { Login as LoginData } from '../models/login'; import styles from './Login.module.css'; interface LoginProps { onRegister: () => void; onSuccess: () => void; } export function Login({ onRegister, onSuccess }: LoginProps) { const { login } = useAuth(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const canSubmit = email.trim() !== '' && password !== ''; const handleSubmit = async (e: FormEvent) => { e.preventDefault(); setError(''); const data: LoginData = { email, password }; const err = await login(data); if (err) { setError(err); } else { setPassword(''); onSuccess(); } }; return (
setEmail(e.detail ?? '')}> setPassword(e.detail ?? '')}> {error &&

{error}

}
Log In Create new account
{ExternalAuth.hasProvider() && (
{ExternalAuth.hasProvider('google') && ( ExternalAuth.login('google')}>Sign in with Google )} {ExternalAuth.hasProvider('facebook') && ( ExternalAuth.login('facebook')}>Sign in with Facebook )} {ExternalAuth.hasProvider('microsoft') && ( ExternalAuth.login('microsoft')}>Sign in with Microsoft )}
)}
); }