import React, { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Redirect, Link } from "react-router-dom";
import { loginUser } from "../../actions/users";
export const UserLoginForm = () => {
const dispatch = useDispatch();
const isLogged = useSelector((state) => state.user.isLogged);
const isLoading = useSelector((state) => state.user.loading);
const error = useSelector((state) => state.user.error);
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const handleSubmit = (e) => {
e.preventDefault();
if (!isLoading) {
dispatch(loginUser(username, password));
}
};
if (isLogged) {
return