End of chapter 27

This commit is contained in:
Martin Donnelly 2019-10-10 15:33:52 +01:00
parent 57d4d8c1ef
commit c522bec270
3 changed files with 115 additions and 109 deletions

View File

@ -1,6 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="Eslint" enabled="true" level="ERROR" enabled_by_default="true" />
</profile>
</component>

View File

@ -2,8 +2,9 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="5be46653-49b7-409a-9549-21ca1be137cc" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/users/Search.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/users/Search.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/users/User.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/users/User.js" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -53,7 +54,7 @@
<property name="node.js.path.for.package.jscs" value="project" />
<property name="node.js.path.for.package.standard" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="$USER_HOME$/.nvm/versions/node/v10.16.2/lib/node_modules/eslint" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.jscs" value="$USER_HOME$/.nvm/versions/node/v8.1.3/lib/node_modules/jscs" />
<property name="node.js.selected.package.standard" value="$USER_HOME$/.nvm/versions/node/v8.1.3/lib/node_modules/eslint" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
@ -62,7 +63,7 @@
<property name="nodejs_package_manager_path" value="npm" />
<property name="prettierjs.PrettierConfiguration.NodeInterpreter" value="project" />
<property name="prettierjs.PrettierConfiguration.Package" value="$USER_HOME$/.nvm/versions/node/v8.11.3/lib/node_modules/prettier" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
<property name="settings.editor.selected.configurable" value="settings.javascript.linters.eslint" />
<property name="show.migrate.to.gradle.popup" value="false" />
</component>
<component name="RecentsManager">
@ -115,7 +116,7 @@
<workItem from="1570713507620" duration="154000" />
<workItem from="1570713697039" duration="68000" />
<workItem from="1570713775683" duration="2307000" />
<workItem from="1570716281021" duration="617000" />
<workItem from="1570716281021" duration="1452000" />
</task>
<task id="LOCAL-00001" summary="End of Chapter 14">
<created>1569512995385</created>
@ -208,7 +209,14 @@
<option name="project" value="LOCAL" />
<updated>1570715593335</updated>
</task>
<option name="localTasksCounter" value="14" />
<task id="LOCAL-00014" summary="End of chapter 26">
<created>1570717008344</created>
<option name="number" value="00014" />
<option name="presentableId" value="LOCAL-00014" />
<option name="project" value="LOCAL" />
<updated>1570717008344</updated>
</task>
<option name="localTasksCounter" value="15" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -241,6 +249,7 @@
<MESSAGE value="End of chapter 22" />
<MESSAGE value="End of chapter 23" />
<MESSAGE value="End of chapter 24" />
<option name="LAST_COMMIT_MESSAGE" value="End of chapter 24" />
<MESSAGE value="End of chapter 26" />
<option name="LAST_COMMIT_MESSAGE" value="End of chapter 26" />
</component>
</project>

View File

@ -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 <Spinner />;
const { loading, repos } = this.props;
if (loading) return <Spinner />;
return (
<Fragment>
{name}
<Link to="/" className="btn btn-light">
return (
<Fragment>
{name}
<Link to="/" className="btn btn-light">
Back to search
</Link>
Hireable:{" "}
{hireable ? (
<i className="fas fa-check text-success" />
) : (
<i className="fas fa-times-circle text-danger" />
)}
<div className="card grid-2">
<div className="all-center">
<img
src={avatar_url}
className="round-img"
alt=""
style={{ width: "150px" }}
/>
<h1>{name}</h1>
<p>Location: {location}</p>
</div>
<div>
{bio && (
<Fragment>
<h3>Bio</h3>
<p>{bio}</p>
</Fragment>
)}
<a href={html_url} className="btn btn-dark my-1">
</Link>
Hireable:{' '}
{hireable ? (
<i className="fas fa-check text-success" />
) : (
<i className="fas fa-times-circle text-danger" />
)}
<div className="card grid-2">
<div className="all-center">
<img
src={avatar_url}
className="round-img"
alt=""
style={{ 'width': '150px' }}
/>
<h1>{name}</h1>
<p>Location: {location}</p>
</div>
<div>
{bio && (
<Fragment>
<h3>Bio</h3>
<p>{bio}</p>
</Fragment>
)}
<a href={html_url} className="btn btn-dark my-1">
Visit Github
</a>
<ul>
<li>
{login && (
<Fragment>
<strong>Username: </strong> {login}
</Fragment>
)}
</li>
</a>
<ul>
<li>
{login && (
<Fragment>
<strong>Username: </strong> {login}
</Fragment>
)}
</li>
<li>
{company && (
<Fragment>
<strong>Company: </strong> {company}
</Fragment>
)}
</li>
<li>
{company && (
<Fragment>
<strong>Company: </strong> {company}
</Fragment>
)}
</li>
<li>
{blog && (
<Fragment>
<strong>Website: </strong> {blog}
</Fragment>
)}
</li>
</ul>
</div>
<li>
{blog && (
<Fragment>
<strong>Website: </strong> {blog}
</Fragment>
)}
</li>
</ul>
</div>
<div className="card text-center">
<div className="badge badge-primary">Followers: {followers}</div>
<div className="badge badge-success">Following: {following}</div>
<div className="badge badge-light">Public Repos: {public_repos}</div>
<div className="badge badge-dark">Public Gists: {public_gists}</div>
</div>
<Repos repos={repos} />
</Fragment>
);
}
}
</div>
<div className="card text-center">
<div className="badge badge-primary">Followers: {followers}</div>
<div className="badge badge-success">Following: {following}</div>
<div className="badge badge-light">Public Repos: {public_repos}</div>
<div className="badge badge-dark">Public Gists: {public_gists}</div>
</div>
<Repos repos={repos} />
</Fragment>
);
};
User.propTypes = {
'loading': PropTypes.bool,
'user': PropTypes.object.isRequired,
'getUser': PropTypes.func.isRequired,
'getUserRepos': PropTypes.func.isRequired,
'repos': PropTypes.array.isRequired
};
export default User;