diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 4bd4a29..c6cc8c8 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index bd0ee49..258ebc9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,9 @@ + - + @@ -115,7 +116,7 @@ - + 1569512995385 @@ -208,7 +209,14 @@ - @@ -241,6 +249,7 @@ - \ No newline at end of file diff --git a/src/components/users/User.js b/src/components/users/User.js index cdd754e..5e2fc47 100644 --- a/src/components/users/User.js +++ b/src/components/users/User.js @@ -1,114 +1,111 @@ -import React, { Component, Fragment } from "react"; -import Spinner from "../layout/Spinner"; +import React, { useEffect, Fragment } from 'react'; +import Spinner from '../layout/Spinner'; import Repos from '../repos/Repos'; -import PropTypes from "prop-types"; -import { Link } from "react-router-dom"; +import PropTypes from 'prop-types'; +import { Link } from 'react-router-dom'; -class User extends Component { - componentDidMount() { - this.props.getUser(this.props.match.params.login); - this.props.getUserRepos(this.props.match.params.login); - } +const User = ({ user, loading, getUser, getUserRepos, repos, match }) => { + useEffect(() => { + getUser(match.params.login); + getUserRepos(match.params.login); + // eslint-disable-next-line + }, []); - static propTypes = { - loading: PropTypes.bool, - user: PropTypes.object.isRequired, - getUser: PropTypes.func.isRequired, - getUserRepos: PropTypes.func.isRequired, - repos: PropTypes.array.isRequired - }; + const { + name, + company, + avatar_url, + location, + bio, + blog, + login, + html_url, + followers, + following, + public_repos, + public_gists, + hireable + } = user; - render() { - const { - name, - company, - avatar_url, - location, - bio, - blog, - login, - html_url, - followers, - following, - public_repos, - public_gists, - hireable - } = this.props.user; + if (loading) return ; - const { loading, repos } = this.props; - - if (loading) return ; - - return ( - - {name} - + return ( + + {name} + Back to search - - Hireable:{" "} - {hireable ? ( - - ) : ( - - )} -
-
- -

{name}

-

Location: {location}

-
-
- {bio && ( - -

Bio

-

{bio}

-
- )} - + + Hireable:{' '} + {hireable ? ( + + ) : ( + + )} +
+
+ +

{name}

+

Location: {location}

+
+
+ {bio && ( + +

Bio

+

{bio}

+
+ )} +
Visit Github - -
    -
  • - {login && ( - - Username: {login} - - )} -
  • + +
      +
    • + {login && ( + + Username: {login} + + )} +
    • -
    • - {company && ( - - Company: {company} - - )} -
    • +
    • + {company && ( + + Company: {company} + + )} +
    • -
    • - {blog && ( - - Website: {blog} - - )} -
    • -
    -
+
  • + {blog && ( + + Website: {blog} + + )} +
  • +
    -
    -
    Followers: {followers}
    -
    Following: {following}
    -
    Public Repos: {public_repos}
    -
    Public Gists: {public_gists}
    -
    - - - ); - } -} +
    +
    +
    Followers: {followers}
    +
    Following: {following}
    +
    Public Repos: {public_repos}
    +
    Public Gists: {public_gists}
    +
    + + + ); +}; + +User.propTypes = { + 'loading': PropTypes.bool, + 'user': PropTypes.object.isRequired, + 'getUser': PropTypes.func.isRequired, + 'getUserRepos': PropTypes.func.isRequired, + 'repos': PropTypes.array.isRequired +}; export default User;