mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-18 05:09:23 +00:00
add decks slice
This commit is contained in:
42
src/services/decks/decks.slice.ts
Normal file
42
src/services/decks/decks.slice.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
|
||||
export const decksSlice = createSlice({
|
||||
name: 'decks',
|
||||
initialState: {
|
||||
currentPage: 1,
|
||||
perPage: 10,
|
||||
search: '',
|
||||
authorId: '',
|
||||
minCards: 0,
|
||||
maxCards: null as number | null,
|
||||
},
|
||||
reducers: {
|
||||
setCurrentPage: (state, action: PayloadAction<number>) => {
|
||||
state.currentPage = action.payload
|
||||
},
|
||||
setPerPage: (state, action: PayloadAction<number>) => {
|
||||
state.perPage = action.payload
|
||||
},
|
||||
setSearch: (state, action: PayloadAction<string>) => {
|
||||
state.search = action.payload
|
||||
},
|
||||
setAuthorId: (state, action: PayloadAction<string>) => {
|
||||
state.authorId = action.payload
|
||||
},
|
||||
setMinCards: (state, action: PayloadAction<number>) => {
|
||||
state.minCards = action.payload
|
||||
},
|
||||
setMaxCards: (state, action: PayloadAction<number>) => {
|
||||
state.maxCards = action.payload
|
||||
},
|
||||
resetFilters: state => {
|
||||
state.search = ''
|
||||
state.authorId = ''
|
||||
state.minCards = 0
|
||||
state.maxCards = null
|
||||
},
|
||||
resetCurrentPage: state => {
|
||||
state.currentPage = 1
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user