feat: search bar working, still in progress

This commit is contained in:
Daniel Avila 2023-03-18 01:40:49 -04:00
parent 610cba4a60
commit 0f54ffd8b4
10 changed files with 147 additions and 24 deletions

View file

@ -0,0 +1,30 @@
import { createSlice } from '@reduxjs/toolkit';
const initialState = {
search: false,
query: '',
};
const currentSlice = createSlice({
name: 'search',
initialState,
reducers: {
setSearchState: (state, action) => {
state.search = action.payload;
},
setQuery: (state, action) => {
const q = action.payload;
state.query = q;
if (!q || q === '') {
state.search = false;
} else {
state.search = true;
}
},
}
});
export const { setSearchState, setQuery } = currentSlice.actions;
export default currentSlice.reducer;