changePass.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { Link } from "react-router-dom";
  2. import { connect } from "react-redux";
  3. import { useState } from "react";
  4. import { actionChangePass } from "../actions/actionChangePassword";
  5. const ChangePass = ({onChangePass}) => {
  6. const [log, setLog] = useState('')
  7. const [pass, setPass] = useState('')
  8. const [newPass, setNewPass] = useState('')
  9. //console.log(onChangePass);
  10. return (
  11. <>
  12. <Link to="/">
  13. <button className="float-left btn-secondary d-inline-block mt-2 ml-2">
  14. <span>&#8617;</span>Back to Main Page
  15. </button>
  16. </Link>
  17. <br/>
  18. <br/>
  19. <div className="container">
  20. <div style ={{textAlign: "center" , alignItems:"center", justifyContent:'center', marginTop: "70px"}}>
  21. <p>
  22. <input className="form-control text-center"
  23. value={log}
  24. placeholder='your login'
  25. onChange={(e) => setLog(e.target.value)}
  26. style={{borderColor: log.length > 0 ? 'green' : 'red'}}
  27. />
  28. </p>
  29. <p>
  30. <input className="form-control text-center"
  31. value={pass}
  32. placeholder='your old password'
  33. onChange={(e) => setPass(e.target.value)}
  34. style={{borderColor: pass.length > 0 ? 'green' : 'red'}}
  35. />
  36. </p>
  37. <p>
  38. <input className="form-control col-md-6 text-center"
  39. placeholder='your new password'
  40. style={{borderColor: pass.length > 0 ? 'green' : 'red'}}
  41. onChange={(e) => {setNewPass(e.target.value)}}
  42. />
  43. </p>
  44. <p>
  45. <button class="btn btn-success text-center"
  46. onClick={() => onChangePass(log, pass, newPass)}
  47. disabled={(log.length!==0 && pass.length!==0 && newPass!==0) ? false : true}>
  48. Сменить пароль
  49. </button>
  50. </p>
  51. </div>
  52. </div>
  53. </>
  54. )
  55. };
  56. const CChangePass = connect(state=>({}),{onChangePass: actionChangePass})(ChangePass)
  57. export default CChangePass;