Refactored /me-Resource

This commit is contained in:
Philipp Czora
2018-07-24 13:02:50 +02:00
parent f1f91e8d52
commit 3afd560028
7 changed files with 190 additions and 68 deletions

View File

@@ -17,7 +17,8 @@ type Props = {
error: Error,
loading: boolean,
authenticated?: boolean,
fetchMe: () => void
fetchMe: () => void,
displayName: string
};
class App extends Component<Props> {
@@ -26,7 +27,7 @@ class App extends Component<Props> {
}
render() {
const { entry, loading, error, authenticated } = this.props;
const { me, loading, error, authenticated, displayName } = this.props;
let content;
const navigation = authenticated ? <PrimaryNavigation /> : "";
@@ -48,7 +49,7 @@ class App extends Component<Props> {
<div className="App">
<Header>{navigation}</Header>
{content}
<Footer me={entry} />
<Footer me={displayName} />
</div>
);
}
@@ -62,10 +63,17 @@ const mapDispatchToProps = (dispatch: any) => {
const mapStateToProps = state => {
let mapped = state.auth.me || {};
let displayName;
if (state.auth.login) {
mapped.authenticated = state.auth.login.authenticated;
}
return mapped;
if (state.auth.me && state.auth.me.entry) {
displayName = state.auth.me.entry.entity.displayName;
}
return {
...mapped,
displayName
};
};
export default withRouter(