You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
955 B
JavaScript
21 lines
955 B
JavaScript
import api from '../api.js';
|
|
//import api from '../api-stub.js';
|
|
|
|
const edit_handler = function(note_state, dispatch){
|
|
dispatch({type: 'update-note-editing', note_id: note_state.note.id, is_editing: true});
|
|
};
|
|
const cancel_handler = function(note_state, dispatch){
|
|
dispatch({type: 'update-note-editing', note_id: note_state.note.id, is_editing: false});
|
|
};
|
|
const text_change_handler = function(note_state, dispatch, e){
|
|
note_state.temp_text = e.target.value;
|
|
};
|
|
const save_handler = function(note_state, dispatch){
|
|
// TODO: consolidate: this will cause two redraws:
|
|
dispatch({type: 'update-note-text', note_id: note_state.note.id, text: note_state.temp_text});
|
|
//note.text = temp_text;
|
|
dispatch({type: 'update-note-editing', note_id: note_state.note.id, is_editing: false});
|
|
api.post('/save', {note_id: note_state.note.id, text: note_state.temp_text})
|
|
};
|
|
|
|
export { edit_handler, cancel_handler, text_change_handler, save_handler }; |