import {createSlice} from "@reduxjs/toolkit"; import {HYDRATE} from "next-redux-wrapper"; import {AppState} from "./store"; export interface ShopSearchState { results: object[]; } // Initial state const initialState: ShopSearchState = { results: [], }; // Actual Slice // @ts-ignore export const shopSearchSlice = createSlice({ name: "shopSearch", initialState, reducers: { // Action to set the authentication status setShopSearchState(state, action) { // @ts-ignore state.results = action.payload; }, // Special reducer for hydrating the state. Special case for next-redux-wrapper extraReducers: { // @ts-ignore [HYDRATE]: (state, action) => { return { ...state, // @ts-ignore ...action.payload.shopSearch, }; }, }, }, }); export const {setShopSearchState} = shopSearchSlice.actions; export const selectShopSearchState = (state: AppState) => state.blogSearch; export default shopSearchSlice.reducer;