add Profile

This commit is contained in:
data 2019-06-21 09:15:34 -04:00
parent dce416d6db
commit e53e0f038d
5 changed files with 19 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -1,5 +1,5 @@
import React from 'react' import React from 'react'
import { About, Tasks, Navbar } from './components' import { About, Tasks, Profile, Navbar } from './components'
const defaultState = { user: {}, loading: true, tasks: [], search: '', newTask: '' } const defaultState = { user: {}, loading: true, tasks: [], search: '', newTask: '' }
@ -65,6 +65,9 @@ class App extends React.Component {
renderError() { renderError() {
return <div>Something went wrong. Please try again.</div> return <div>Something went wrong. Please try again.</div>
} }
renderProfile() {
return <Profile {...this.state} />
}
renderAbout() { renderAbout() {
return <About {...this.state} /> return <About {...this.state} />
} }
@ -80,6 +83,7 @@ class App extends React.Component {
const renderComponent = () => this.state.loading ? this.renderLoading() const renderComponent = () => this.state.loading ? this.renderLoading()
: this.state.component === 'tasks' ? this.renderTasks(filtered, completed) : this.state.component === 'tasks' ? this.renderTasks(filtered, completed)
: this.state.component === 'about' ? this.renderAbout() : this.state.component === 'about' ? this.renderAbout()
: this.state.component === 'profile' ? this.renderProfile()
: this.renderError() : this.renderError()
return (<div> return (<div>

View File

@ -4,5 +4,6 @@
export { default as Navbar } from './navbar' export { default as Navbar } from './navbar'
export { default as About } from './about' export { default as About } from './about'
export { default as Tasks } from './tasks' export { default as Tasks } from './tasks'
export { default as Profile } from './profile'
// export {default as CreateASign} from ./create-a-sign.js // export {default as CreateASign} from ./create-a-sign.js
// etc // etc

View File

@ -12,7 +12,7 @@ function Navbar(props) {
<div className={`nav-item mr-3 ${ props.component === 'about' ? "active" : 'disable'}`} onClick={() => props.navigate("about") }>About</div> <div className={`nav-item mr-3 ${ props.component === 'about' ? "active" : 'disable'}`} onClick={() => props.navigate("about") }>About</div>
<div className="ml-auto"> <div className="ml-auto>" onClick={() => props.navigate("profile") }>
<img className="rounded-circle mr-1" alt={props.user.name} <img className="rounded-circle mr-1" alt={props.user.name}
width="16px" height="16px" src="/img/default-user-image.png" /> width="16px" height="16px" src="/img/default-user-image.png" />
{`Hello, ${props.user.name}!`} {`Hello, ${props.user.name}!`}

View File

@ -0,0 +1,9 @@
import React from 'react'
function Profile(props) {
return (
<div>You are { props.user.name }.</div>
)
}
export default Profile