ql
1import { createSlice, PayloadAction } from '@reduxjs/toolkit';
2
3export interface SearchState {
4query: string;
5currentPage: number;
6}
7
8const initialState: SearchState = {
9query: '',
10currentPage: 1
11};
12
13const searchSlice = createSlice({
14name: 'search',
15initialState,
16reducers: {
17setQuery(state, action: PayloadAction<string>) {
18state.query = action.payload;
19},
20setCurrentPage(state, action: PayloadAction<number>) {
21state.currentPage = action.payload;
22}
23}
24});
25
26export const { setQuery, setCurrentPage } = searchSlice.actions;
27export default searchSlice.reducer;
28