From 4285674ab37c74a24b265ace4d15d4848457d375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= Date: Mon, 29 May 2023 12:42:46 -0600 Subject: Pagination now works on to do's list. Only 10 to dos will be shown at a time. You can sort by priority or due date and it should work on all of our to dos. Edit and delete also works. --- src/features/todo/reducer.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/features') diff --git a/src/features/todo/reducer.js b/src/features/todo/reducer.js index 210fb05..8a2e9b8 100644 --- a/src/features/todo/reducer.js +++ b/src/features/todo/reducer.js @@ -14,6 +14,8 @@ export const todo_slice = createSlice({ priority: "All", state: "All", }, + + page_selected: 1, }, reducers: { @@ -128,6 +130,14 @@ export const todo_slice = createSlice({ state: action.payload.state, }; }, + + empty_todos: (state) => { + state.todos = []; + }, + + change_page: (state, action) => { + state.page_selected = action.payload.page; + }, }, }); @@ -140,6 +150,8 @@ export const { edit_todo, set_sort_todo, set_filters, + empty_todos, + change_page, } = todo_slice.actions; export const select_todos = (state) => state.todo_list.todos; @@ -148,5 +160,6 @@ export const select_current_sorting = (state) => state.todo_list.current_sorting; export const select_current_filters = (state) => state.todo_list.current_filters; +export const select_current_page = (state) => state.todo_list.page_selected; export default todo_slice.reducer; -- cgit v1.2.3