profileBar.js 909 B

123456789101112131415161718192021222324
  1. import { connect } from "react-redux"
  2. import { actionAuthLogout } from "../actions"
  3. const Profile = ({ user, onLogout }) => {
  4. return (
  5. <>
  6. {user && <div>
  7. {user.avatar ?
  8. <img src={user.avatar.url} alt="ava" />
  9. :
  10. <img src="https://img.icons8.com/external-bearicons-glyph-bearicons/64/000000/external-User-essential-collection-bearicons-glyph-bearicons.png"
  11. alt="ava" />}
  12. <span>{user.nick || user.login}</span>
  13. <a href="/profile">Редактировать профиль</a>
  14. <button onClick={() => onLogout()}>Выйти</button>
  15. </div>}
  16. </>
  17. )
  18. }
  19. export const ConnectProfile = connect(state => ({ user: state.promise.userInfo?.payload?.data?.UserFindOne }),
  20. {
  21. onLogout: actionAuthLogout
  22. })(Profile)