-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
622814c
commit 5bd5a14
Showing
3 changed files
with
143 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
'use strict' | ||
|
||
// Packages | ||
import { Component } from 'react' | ||
import Link from 'next/link' | ||
|
||
// Layouts | ||
import Page from './../layouts/page' | ||
|
||
// Components | ||
import Row from './../components/row' | ||
import Hero from './../components/hero' | ||
import Input from './../components/input' | ||
import Button from './../components/button' | ||
|
||
// Services | ||
import { getUser } from './../services/api' | ||
|
||
class Task extends Component { | ||
constructor() { | ||
super() | ||
|
||
this.state = { title: '', description: '' } | ||
} | ||
|
||
componentDidMount() { | ||
const { url: { query: { id } } } = this.props | ||
const { user } = getUser() | ||
const { title, description } = user.tasks.filter(task => task.id === id)[0] | ||
|
||
if (title) { | ||
return this.setState({ title, description }) | ||
} | ||
} | ||
|
||
render() { | ||
const { title, description } = this.state | ||
const { url: { query: { id } } } = this.props | ||
|
||
return ( | ||
<Page> | ||
<Row> | ||
<section> | ||
<Hero type="Task details" /> | ||
|
||
<form> | ||
<fieldset> | ||
<Input | ||
label="Title" | ||
name="title" | ||
placeholder={title} | ||
size="large" | ||
autoFocus={true} | ||
onChange={this.inputChange} | ||
value={title} | ||
inputRef="title" | ||
readOnly={true} | ||
/> | ||
|
||
<Input | ||
label="Description" | ||
name="description" | ||
placeholder={description} | ||
multiline={true} | ||
onChange={this.inputChange} | ||
value={description} | ||
inputRef="description" | ||
readOnly={true} | ||
/> | ||
</fieldset> | ||
|
||
<footer> | ||
<Link href="/start" prefetch> | ||
<span>Back</span> | ||
</Link> | ||
|
||
<Link href={`/edit?id=${id}`} prefetch> | ||
<Button>Edit task</Button> | ||
</Link> | ||
</footer> | ||
</form> | ||
</section> | ||
</Row> | ||
|
||
<style jsx>{` | ||
section { | ||
display: flex; | ||
flex-direction: column; | ||
jutify-content: space-between; | ||
min-height: 500px; | ||
} | ||
form { | ||
height: 414px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
} | ||
span { | ||
display: block; | ||
width: 100%; | ||
color: #aaa; | ||
height: 36px; | ||
font-weight: 600; | ||
font-size: 10px; | ||
cursor: pointer; | ||
text-transform: uppercase; | ||
letter-spacing: 2px; | ||
text-align: center; | ||
transition: 0.2s all; | ||
} | ||
span:hover { | ||
color: white; | ||
} | ||
`}</style> | ||
</Page> | ||
) | ||
} | ||
} | ||
|
||
export default Task |