Unverified Commit 92f9dca1 authored by Daniel's avatar Daniel Committed by GitHub

Fix navbar and footer state bugs (#112)

* Fix navbar and footer state bugs
parent 805d5b48
...@@ -19,17 +19,9 @@ interface DispatchFromProps { ...@@ -19,17 +19,9 @@ interface DispatchFromProps {
export type FooterProps = StateFromProps & DispatchFromProps; export type FooterProps = StateFromProps & DispatchFromProps;
interface FooterState { export class Footer extends React.Component<FooterProps> {
lastIndexed: number;
}
export class Footer extends React.Component<FooterProps, FooterState> {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {
lastIndexed: this.props.lastIndexed,
};
} }
componentDidMount() { componentDidMount() {
...@@ -38,12 +30,12 @@ export class Footer extends React.Component<FooterProps, FooterState> { ...@@ -38,12 +30,12 @@ export class Footer extends React.Component<FooterProps, FooterState> {
generateDateTimeString = () => { generateDateTimeString = () => {
// 'moment.local' will utilize the client's local timezone. // 'moment.local' will utilize the client's local timezone.
return moment.unix(this.state.lastIndexed).local().format('MMMM Do YYYY [at] h:mm:ss a'); return moment.unix(this.props.lastIndexed).local().format('MMMM Do YYYY [at] h:mm:ss a');
} };
render() { render() {
let content; let content;
if (this.state.lastIndexed !== null) { if (this.props.lastIndexed !== null) {
content = <div>{`Amundsen was last indexed on ${this.generateDateTimeString()}`}</div>; content = <div>{`Amundsen was last indexed on ${this.generateDateTimeString()}`}</div>;
} }
return ( return (
......
...@@ -24,18 +24,9 @@ interface DispatchFromProps { ...@@ -24,18 +24,9 @@ interface DispatchFromProps {
export type NavBarProps = StateFromProps & DispatchFromProps; export type NavBarProps = StateFromProps & DispatchFromProps;
// State export class NavBar extends React.Component<NavBarProps> {
interface NavBarState {
loggedInUser: LoggedInUser;
}
export class NavBar extends React.Component<NavBarProps, NavBarState> {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {
loggedInUser: this.props.loggedInUser,
};
} }
componentDidMount() { componentDidMount() {
...@@ -69,9 +60,9 @@ export class NavBar extends React.Component<NavBarProps, NavBarState> { ...@@ -69,9 +60,9 @@ export class NavBar extends React.Component<NavBarProps, NavBarState> {
{this.generateNavLinks(AppConfig.navLinks)} {this.generateNavLinks(AppConfig.navLinks)}
{ {
// TODO PEOPLE - Add link to user profile // TODO PEOPLE - Add link to user profile
this.state.loggedInUser && this.props.loggedInUser &&
<div id="nav-bar-avatar"> <div id="nav-bar-avatar">
<Avatar name={this.state.loggedInUser.display_name} size={32} round={true} /> <Avatar name={this.props.loggedInUser.display_name} size={32} round={true} />
</div> </div>
} }
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment