import React, { useState } from 'react'; import { useDispatch } from 'react-redux'; import { loginSuccess, setError } from '../features/auth/authSlice'; import { Box, Button, TextField, Typography, Alert } from '@mui/material'; const LoginPage = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setErrorState] = useState(null); const dispatch = useDispatch(); const handleLogin = () => { if (!email || !password) { setErrorState('Email and Password are required.'); return; } // Simulate login API call try { dispatch(loginSuccess({ email })); // Replace with actual API response } catch (err) { dispatch(setError(err.message)); setErrorState('Invalid credentials.'); } }; return ( Login {error && {error}} setEmail(e.target.value)} /> setPassword(e.target.value)} /> ); }; export default LoginPage;