add Profile
This commit is contained in:
parent
dce416d6db
commit
e53e0f038d
BIN
public/img/default-user-image.png
Normal file
BIN
public/img/default-user-image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
12
src/App.js
12
src/App.js
@ -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} />
|
||||||
}
|
}
|
||||||
@ -78,9 +81,10 @@ class App extends React.Component {
|
|||||||
const filtered = this.state.tasks.filter(task => task.completed !== true && this.state.search === task.desc.slice(0, this.state.search.length))
|
const filtered = this.state.tasks.filter(task => task.completed !== true && this.state.search === task.desc.slice(0, this.state.search.length))
|
||||||
|
|
||||||
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.renderError()
|
: this.state.component === 'profile' ? this.renderProfile()
|
||||||
|
: this.renderError()
|
||||||
|
|
||||||
return (<div>
|
return (<div>
|
||||||
<Navbar handleChange={this.handleChange} navigate={this.navigate} {...this.state} />
|
<Navbar handleChange={this.handleChange} navigate={this.navigate} {...this.state} />
|
||||||
|
@ -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
|
||||||
|
@ -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}!`}
|
||||||
|
9
src/components/profile.js
Normal file
9
src/components/profile.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
function Profile(props) {
|
||||||
|
return (
|
||||||
|
<div>You are { props.user.name }.</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Profile
|
Loading…
Reference in New Issue
Block a user