;hg
Browse files
frontend/src/pages/Login.jsx
CHANGED
|
@@ -6,7 +6,10 @@ import { loginUser, clearError, updateCacheInfo } from '../store/reducers/authSl
|
|
| 6 |
const Login = () => {
|
| 7 |
const dispatch = useDispatch();
|
| 8 |
const navigate = useNavigate();
|
| 9 |
-
const { isAuthenticated, loading, error } = useSelector(state =>
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
const [formData, setFormData] = useState({
|
| 12 |
email: '',
|
|
|
|
| 6 |
const Login = () => {
|
| 7 |
const dispatch = useDispatch();
|
| 8 |
const navigate = useNavigate();
|
| 9 |
+
const { isAuthenticated, loading, error } = useSelector(state => {
|
| 10 |
+
console.log('Redux auth state updated:', state.auth);
|
| 11 |
+
return state.auth;
|
| 12 |
+
});
|
| 13 |
|
| 14 |
const [formData, setFormData] = useState({
|
| 15 |
email: '',
|
frontend/src/store/reducers/authSlice.js
CHANGED
|
@@ -329,10 +329,11 @@ const authSlice = createSlice({
|
|
| 329 |
name: 'auth',
|
| 330 |
initialState,
|
| 331 |
reducers: {
|
| 332 |
-
clearError
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
|
|
|
| 336 |
|
| 337 |
setUser: (state, action) => {
|
| 338 |
state.user = action.payload.user;
|
|
@@ -502,6 +503,7 @@ const authSlice = createSlice({
|
|
| 502 |
}
|
| 503 |
}
|
| 504 |
|
|
|
|
| 505 |
state.error = errorMessage;
|
| 506 |
})
|
| 507 |
|
|
|
|
| 329 |
name: 'auth',
|
| 330 |
initialState,
|
| 331 |
reducers: {
|
| 332 |
+
export const clearError = (state) => {
|
| 333 |
+
console.log('Clearing Redux error');
|
| 334 |
+
state.error = null;
|
| 335 |
+
state.loading = 'idle';
|
| 336 |
+
};,
|
| 337 |
|
| 338 |
setUser: (state, action) => {
|
| 339 |
state.user = action.payload.user;
|
|
|
|
| 503 |
}
|
| 504 |
}
|
| 505 |
|
| 506 |
+
console.log('Setting Redux error:', errorMessage);
|
| 507 |
state.error = errorMessage;
|
| 508 |
})
|
| 509 |
|