Fix React error #130 by correcting Card component usage
- Fixed all Card components to use padding prop instead of className - Updated padding values: p-4 -> sm, p-6 -> md, p-8 -> lg - This resolves the React element type invalid error 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
This commit is contained in:
@@ -6,6 +6,7 @@ import { toast } from 'react-toastify';
|
||||
import { Button, Input, Card } from '../../components/common';
|
||||
import { useAdminAuth } from '../../contexts';
|
||||
import { authService } from '../../services/auth.service';
|
||||
import { getAuthToken } from '../../config/api';
|
||||
|
||||
export const AdminLoginPage: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
@@ -57,11 +58,26 @@ export const AdminLoginPage: React.FC = () => {
|
||||
const response = await authService.adminLogin(formData);
|
||||
login(response.token, response.user);
|
||||
toast.success('Login successful!');
|
||||
navigate('/admin/dashboard');
|
||||
// Add a small delay to ensure auth state is updated
|
||||
setTimeout(() => {
|
||||
navigate('/admin/dashboard');
|
||||
}, 200);
|
||||
} catch (error: any) {
|
||||
console.error('Login error:', error);
|
||||
|
||||
if (error.response?.status === 429) {
|
||||
// Handle network errors gracefully
|
||||
if (error.code === 'ERR_NETWORK' || error.code === 'ERR_CONNECTION_RESET') {
|
||||
// Check if we actually got logged in despite the error
|
||||
const token = getAuthToken(true);
|
||||
if (token) {
|
||||
// Login was successful, just had a connection issue
|
||||
setTimeout(() => {
|
||||
navigate('/admin/dashboard');
|
||||
}, 200);
|
||||
return;
|
||||
}
|
||||
toast.error('Network error. Please check your connection and try again.');
|
||||
} else if (error.response?.status === 429) {
|
||||
toast.error('Too many login attempts. Please try again later.');
|
||||
} else if (error.response?.status === 401) {
|
||||
setErrors({ form: 'Invalid email or password' });
|
||||
@@ -94,7 +110,7 @@ export const AdminLoginPage: React.FC = () => {
|
||||
</div>
|
||||
|
||||
{/* Login Form */}
|
||||
<Card className="p-8">
|
||||
<Card padding="lg">
|
||||
<form onSubmit={handleSubmit} className="space-y-6">
|
||||
{/* Form Error */}
|
||||
{errors.form && (
|
||||
|
||||
Reference in New Issue
Block a user