feature: edit task
This commit is contained in:
parent
6433c4c72a
commit
300f44503b
12 changed files with 253 additions and 151 deletions
|
|
@ -2,21 +2,40 @@ import Emoji from "react-emoji-render";
|
|||
import * as React from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
function RewardItem(props: any) {
|
||||
return (
|
||||
<div className="reward-item" id={props.id}>
|
||||
<button className="reward-click" id={props.id} onClick={props.onChange}>-{props.reward_value}</button>
|
||||
<div>
|
||||
<p className="reward-text"><Emoji text={props.reward_text}></Emoji></p>
|
||||
<ReactMarkdown children={props.reward_notes} />
|
||||
const [state, setState] = React.useState('view')
|
||||
const [title, setTitle] = React.useState('')
|
||||
const [notes, setNotes] = React.useState('')
|
||||
const [coin, setCoin] = React.useState(0)
|
||||
if (state === 'view') {
|
||||
return (
|
||||
<div className="reward-item" id={props.id}>
|
||||
<button className="reward-click" id={props.id} onClick={props.onChange}>-{props.reward_value}</button>
|
||||
<div>
|
||||
<p className="reward-text"><Emoji text={props.reward_text}></Emoji></p>
|
||||
<ReactMarkdown children={props.reward_notes} />
|
||||
</div>
|
||||
<button className="task-operation" >
|
||||
<span className="material-icons md-24" id={props.id} onClick={() => setState('edit')}>create</span>
|
||||
</button>
|
||||
<button className="task-operation">
|
||||
<span className="material-icons md-24" id={props.id} onClick={props.onChange} title="delete">clear</span>
|
||||
</button>
|
||||
</div>
|
||||
<button className="task-operation" >
|
||||
<span className="material-icons md-24" id={props.id} onClick={props.onChange}>create</span>
|
||||
</button>
|
||||
<button className="task-operation">
|
||||
<span className="material-icons md-24" id={props.id} onClick={props.onChange}>clear</span>
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<div className="edit-reward-item edit-item">
|
||||
<input type="text" onChange={event => setTitle(event.target.value)} defaultValue={props.reward_text}></input>
|
||||
<input type="text" onChange={event => setNotes(event.target.value)} defaultValue={props.reward_notes}></input>
|
||||
<input type="text" onChange={event => setNotes(event.target.value)} defaultValue={props.reward_value}></input>
|
||||
<div className="edit-reward-button edit-button">
|
||||
<button className="task-operation" ><span className="material-icons md-24" id={props.id} onClick={function (e) { props.onChange(e); setState('view') }} title="submit" data-title={title} data-notes={notes} data-coin={coin}>check</span></button>
|
||||
<button className="task-operation"><span className="material-icons md-24" id={props.id} onClick={() => setState('view')} title="cancel">clear</span></button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export default RewardItem
|
||||
Loading…
Add table
Add a link
Reference in a new issue