LoginPage.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import React from "react";
  2. import FloatingLabel from "react-bootstrap/FloatingLabel";
  3. import Form from "react-bootstrap/Form";
  4. import Button from "react-bootstrap/Button";
  5. import Alert from "react-bootstrap/Alert";
  6. import { useState } from "react";
  7. import { store } from "../reducers/index";
  8. import { actionFullLogin } from "../actions";
  9. import { Link } from "react-router-dom";
  10. import { connect } from "react-redux";
  11. const Login = ({ onLogin, loginCheck }) => {
  12. const [login, setLogin] = useState("");
  13. const [password, setPassword] = useState("");
  14. if(loginCheck.token === {}) {
  15. alert('error')
  16. }
  17. return (
  18. <div className="formContainerLogin">
  19. <h1 className="textLogin">Login</h1>
  20. <FloatingLabel
  21. controlId="floatingInput"
  22. label="Enter Login"
  23. className="mb-3"
  24. onChange={(e) => {
  25. setLogin(e.target.value);
  26. }}
  27. >
  28. <Form.Control
  29. type="text"
  30. placeholder="text"
  31. className="form-control-editing"
  32. />
  33. </FloatingLabel>
  34. <FloatingLabel
  35. controlId="floatingPassword"
  36. label="Enter Password"
  37. onChange={(e) => {
  38. setPassword(e.target.value);
  39. }}
  40. >
  41. <Form.Control
  42. type="password"
  43. placeholder="Password"
  44. className="form-control-editing"
  45. />
  46. </FloatingLabel>
  47. <div className="d-flex loginForm">
  48. <Button
  49. variant="primary"
  50. type="submit"
  51. className="btn-setting"
  52. onClick={() => {
  53. onLogin(login, password);
  54. }}
  55. disabled={!login || !password}
  56. >
  57. <b>Login</b>
  58. </Button>
  59. <Link to="/registration" className="registerLink alert-link">
  60. Don't have an account? Register
  61. </Link>
  62. </div>
  63. </div>
  64. );
  65. };
  66. export const CLogin = connect((state) => ({loginCheck: state.auth}), { onLogin: actionFullLogin })(Login);