import React, { useState } from 'react'; import { useMockAuth, MockAuthConfig } from './MockAuthProvider'; // Login Form Component export const MockAuthLoginForm: React.FC<{ onSuccess?: () => void }> = ({ onSuccess }) => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const { login } = useMockAuth(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); setError(''); const result = await login(email, password); if (result.success) { onSuccess?.(); } else { setError(result.error || 'Login failed'); } setIsLoading(false); }; return (
); }; // Register Form Component export const MockAuthRegisterForm: React.FC<{ onSuccess?: () => void }> = ({ onSuccess }) => { const [formData, setFormData] = useState({ email: '', username: '', password: '', confirmPassword: '', firstName: '', lastName: '' }); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const { register } = useMockAuth(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); setError(''); if (formData.password !== formData.confirmPassword) { setError('Passwords do not match'); setIsLoading(false); return; } const result = await register({ email: formData.email, username: formData.username, password: formData.password, firstName: formData.firstName, lastName: formData.lastName }); if (result.success) { onSuccess?.(); } else { setError(result.error || 'Registration failed'); } setIsLoading(false); }; const handleChange = (e: React.ChangeEvent