SettingsPassword.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import styled from 'styled-components';
  4. import TextInput from '../TextInput';
  5. import Button from '../Button';
  6. const Form = styled.form`
  7. position: relative;
  8. display: flex;
  9. margin: 32px 0;
  10. input {
  11. flex: 0 0 auto;
  12. margin-right: 16px;
  13. }
  14. `;
  15. const Message = styled.div`
  16. position: absolute;
  17. left: 0;
  18. bottom: -32px;
  19. color: green;
  20. `;
  21. const Error = styled.div`
  22. position: absolute;
  23. left: 0;
  24. bottom: -32px;
  25. color: red;
  26. `;
  27. const SettingsPassword = ({ changePassword, error, message }) => (
  28. <div>
  29. <h3>Change password</h3>
  30. <Form onSubmit={changePassword}>
  31. <Message>{message}</Message>
  32. <TextInput
  33. id="password"
  34. name="password"
  35. type="password"
  36. placeholder="New password"
  37. height={44}
  38. small
  39. />
  40. <Button type="submit" icon="refresh">
  41. Update
  42. </Button>
  43. <Error>{error}</Error>
  44. </Form>
  45. </div>
  46. );
  47. SettingsPassword.propTypes = {
  48. error: PropTypes.string.isRequired,
  49. changePassword: PropTypes.func.isRequired,
  50. message: PropTypes.string.isRequired,
  51. };
  52. export default SettingsPassword;