AllenYuan

Untitled

May 26th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. import React from 'react';
  2. import { Link } from 'react-router-dom';
  3. import PropTypes from 'prop-types';
  4. import FlatButton from 'material-ui/FlatButton';
  5. import { connect } from 'react-redux';
  6. import { ButtonsDiv } from './Styled';
  7. import { IconSteam } from '../Icons';
  8.  
  9. const Buttons = ({ user, strings }) => {
  10. console.log('home buttons props', user, strings);
  11. return (<ButtonsDiv>
  12. {/* only show the login button if the user isn't logged in */}
  13. {
  14. !user &&
  15. <div>
  16. <FlatButton
  17. label={<span className="label"><b>{strings.home_login}</b>{strings.home_login_desc}</span>}
  18. icon={<IconSteam />}
  19. href={`${process.env.REACT_APP_API_HOST}/login`}
  20. />
  21. </div>
  22. }
  23. <div className="bottomButtons">
  24. <div>
  25. <FlatButton
  26. label={<span className="label"><b>{strings.home_parse}</b>{strings.home_parse_desc}</span>}
  27. containerElement={<Link to="/request">{strings.home_parse}</Link>}
  28. />
  29. </div>
  30. </div>
  31. </ButtonsDiv>);
  32. }
  33.  
  34. Buttons.propTypes = {
  35. user: PropTypes.shape({}),
  36. strings: PropTypes.shape({}),
  37. };
  38.  
  39. const mapStateToProps = (state) => {
  40. const { data } = state.app.metadata;
  41. return {
  42. user: data.user,
  43. strings: state.app.strings,
  44. };
  45. };
  46.  
  47. export default connect(mapStateToProps, null)(Buttons);
Add Comment
Please, Sign In to add comment