This file contains hidden or 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
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(MaterialApp(home: MyApp())); | |
| } | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( |
This file contains hidden or 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
| updateTodoMutation (state, todo) { | |
| let index = state.todos.findIndex(element => element.id === todo.id) | |
| state.todos[index] = todo | |
| } |
This file contains hidden or 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
| async updateTodo (todo) { | |
| const updatedTodoHash = { is_completed: todo.is_completed } | |
| const response = await axios.put('todos/' + todo.id, updatedTodoHash) | |
| return response.data | |
| } |
This file contains hidden or 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
| updateTodoAction ({ commit }, todo) { | |
| return new Promise((resolve, reject) => { | |
| ApiHelper.updateTodo(todo) | |
| .then(response => { | |
| commit('updateTodoMutation', response) | |
| resolve(response) | |
| }) | |
| .catch(error => { | |
| reject(error) | |
| }) |
This file contains hidden or 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
| updateTodo(todo) { | |
| this.updateTodoAction(todo) | |
| .then(() => SweetAlert.successfulLogin()) | |
| .catch(() => SweetAlert.failureLogin()) | |
| } |
This file contains hidden or 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
| <v-checkbox | |
| v-model="task.is_completed" | |
| color="info darken-3" | |
| @change="updateTodo(task)" | |
| > |
This file contains hidden or 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
| saveTodoMutation (state, todo) { | |
| state.todos = [...state.todos, todo] | |
| } |
This file contains hidden or 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
| saveTodoAction ({ commit }, todoData) { | |
| return new Promise((resolve, reject) => { | |
| ApiHelper.todo(todoData) | |
| .then(response => { | |
| commit('saveTodoMutation', response) | |
| resolve(response) | |
| }) | |
| .catch(error => { | |
| reject(error) | |
| }) |
This file contains hidden or 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
| createTodo () { | |
| const todoData = { 'title': this.task } | |
| this.saveTodoAction(todoData) | |
| .then(() => { | |
| this.task = '' | |
| SweetAlert.successfulLogin() | |
| }) | |
| .catch(() => { | |
| SweetAlert.failureLogin() | |
| }) |
This file contains hidden or 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
| async todo (todoData) { | |
| const response = await axios.post('todos', todoData) | |
| return response.data | |
| } |