LoginForm.js 935 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { useState } from "react";
  2. import "./LoginReg.css";
  3. export const LoginForm = ({ onLogin }) => {
  4. const [login, setLogin] = useState("");
  5. const [password, setPassword] = useState("");
  6. return (
  7. <div className="login">
  8. <h3>Login</h3>
  9. <input
  10. className="u"
  11. type="login"
  12. placeholder="Username"
  13. value={login}
  14. onChange={(e) => setLogin(e.target.value)}
  15. />
  16. <input
  17. className="p"
  18. type="password"
  19. placeholder="Password"
  20. value={password}
  21. onChange={(e) => setPassword(e.target.value)}
  22. />
  23. <button
  24. type="submit"
  25. className="btn btn-primary btn-block btn-large"
  26. disabled={!login || !password}
  27. onClick={() => onLogin(login, password)}
  28. >
  29. Let me in.{" "}
  30. </button>
  31. <button className="main_page">
  32. <a href="/">Main page</a>
  33. </button>
  34. </div>
  35. );
  36. };