Skip to content

Commit

Permalink
Create action creators
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimkorr committed May 3, 2021
1 parent 0a4feff commit b86d957
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/store/todo-actions.js
Original file line number Diff line number Diff line change
@@ -1,4 1,46 @@
import { v4 as uuid } from 'uuid'

export const ADD_TODO = 'ADD_TODO'
export const UPDATE_TODO_TEXT = 'UPDATE_TODO_TEXT'
export const UPDATE_TODO_DONE = 'UPDATE_TODO_DONE'
export const DELETE_TODO = 'DELETE_TODO'

export const addTodo = (text) => {
return {
type: ADD_TODO,
payload: {
id: uuid(),
text,
done: false,
},
}
}

export const updateTodoText = (id, text) => {
return {
type: UPDATE_TODO_TEXT,
payload: {
id,
text,
},
}
}

export const updateTodoDone = (id, done) => {
return {
type: UPDATE_TODO_DONE,
payload: {
id,
done,
},
}
}

export const deleteTodo = (id) => {
return {
type: DELETE_TODO,
payload: {
id,
},
}
}

0 comments on commit b86d957

Please sign in to comment.