Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
feat(add notes to store!): add notes with id to store
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Jul 1, 2019
1 parent 6f8a4eb commit 82714d7
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/features/tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,45 @@ class TooltipControls extends React.Component {
constructor(props){
super(props)
this.state = {
title: "Title",
label:"Labels",
height:"200px",
width:"300px",
position: [200,200],
note: {
title: '',
labels: [],
content:""
id:'',
note:{
title: '',
labels: [],
content:""
}
}
}
}

handleChangeTitle = (event) => {
var note = {...this.state.note}
note.title = event.target.value
note.note.title = event.target.value
this.setState({note});
}

handleChangeContent = (event) => {
var note = {...this.state.note}
note.content = event.target.value
note.note.content = event.target.value
this.setState({note});
}

saveNote = () => {
console.log(this.state.note)
saveNote = async () => {
if(typeof (this.props.data.CRVIZ._SEARCH_KEY) !== 'undefined'){
var note = {...this.state.note}
note.id = await this.props.data.CRVIZ._SEARCH_KEY
this.setState({note});

this.props.addNote(this.state.note);
console.log(this.props.notes)
}
else{
console.log('else')
}
}

componentDidUpdate(prevProps) {
Expand Down Expand Up @@ -105,10 +117,10 @@ class TooltipControls extends React.Component {
}
<div>
<div>
<b><h1><input style={inputStyle} type="text" value={this.state.note.title} onChange={this.handleChangeTitle} placeholder="Title"/></h1></b>
<b><h1><input style={inputStyle} type="text" value={this.state.note.note.title} onChange={this.handleChangeTitle} placeholder="Title"/></h1></b>
<h6>{this.state.label}</h6>
</div>
<p><input style={inputStyle} type="text" value={this.state.note.content} onChange={this.handleChangeContent} placeholder="Take a note..."/></p>
<p><input style={inputStyle} type="text" value={this.state.note.note.content} onChange={this.handleChangeContent} placeholder="Take a note..."/></p>
<div >
<FontAwesomeIcon style={{margin:"10px"}} icon={faTags} />
<FontAwesomeIcon style={{color:"#47cf38", margin:"10px"}} icon={faSave} onClick={this.saveNote}/>
Expand Down

0 comments on commit 82714d7

Please sign in to comment.