Skip to content

Commit

Permalink
Make some ambiguous improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
binarymason committed May 14, 2017
1 parent 91e8eab commit 014ffef
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/containers/ChallengesContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ReposList from '../components/ReposList';
class ChallengesContainer extends Component {
componentDidMount() {
if (this.props.isAuthenticated) {
this.props.fetchChallenges('');
this.props.fetchRepos();
}
}
Expand All @@ -23,17 +22,22 @@ class ChallengesContainer extends Component {
<h2>Challenges</h2>
<ReposList repos={repos} changeRepo={changeRepo} />
</div>
<div className="container challengesContainer">
<ChallengesList challenges={challenges} />
</div>
{
challenges.length > 0 ? (
<div className="container challengesContainer">
<ChallengesList challenges={challenges} />
</div>
) : (
<h3 style={{ textAlign: 'center' }}>Click on a repo above to start!</h3>
)
}
</div>
);
}
}

ChallengesContainer.propTypes = {
challenges: React.PropTypes.arrayOf(React.PropTypes.shape),
fetchChallenges: React.PropTypes.func.isRequired,
fetchRepos: React.PropTypes.func.isRequired,
isAuthenticated: React.PropTypes.bool.isRequired,
changeRepo: React.PropTypes.func.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions src/containers/NavContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ const NavContainer = props => (
{
props.isAuthenticated &&
<li className="nav-item">
<Link to={`/users/${window.localStorage.getItem('id')}`}>Account</Link>
<Link to="/settings">Account</Link>
</li>
}
{
props.isAuthenticated &&
<li className="nav-item">
<Link to="/settings" className="accountLink">
<Link to={`/users/${window.localStorage.getItem('id')}`} className="accountLink">
<Avatar picture={props.picture} credibility={props.credibility} />
</Link>
</li>
Expand Down
7 changes: 6 additions & 1 deletion src/reducers/account-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ const createSession = (info, state) => {
};
};

const destroySesion = () => {
window.localStorage.clear();
return { ...INITIAL_STATE, isAuthenticated: false };
};

export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case types.CREATE_SESSION:
return createSession(action.payload, state);
case types.DESTROY_SESSION:
return INITIAL_STATE;
return destroySesion();
case types.FETCH_ACCOUNT:
return { ...state, account: action.payload, successfulUpdate: false, responseStatus: 200 };
case types.UPDATE_FIELD:
Expand Down
1 change: 0 additions & 1 deletion src/reducers/challenges-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as types from '../actions/action-types';

const INITIAL_STATE = {
challenges: [],
selectedChallenge: {},
};

export default (state = INITIAL_STATE, action) => {
Expand Down

0 comments on commit 014ffef

Please sign in to comment.