WIP General Search.

This commit is contained in:
elforjani3
2020-04-13 21:30:26 +02:00
9 changed files with 99 additions and 86 deletions

View File

@@ -2,32 +2,14 @@ import t from 'store/types';
import { createReducer } from '@reduxjs/toolkit';
const initialState = {
searches: {},
searchTitle: 'Title',
isOpen: false,
};
export default createReducer(initialState, {
[t.SEARCH_SUCCESS]: (state, action) => {
const _result = {};
action.searches.forEach((search) => {
_result[search.id] = search;
});
state.searches = {
...state.searches,
..._result,
};
[t.OPEN_SEARCH]: (state, action) => {
state.isOpen = true;
},
[t.CLOSE_SEARCH]: (state, action) => {
state.isOpen = false;
},
});
// return state = action.result;
// if (typeof state === 'undefined') {
// return initialState;
// }
// state.search[action.name] = {
// isOpen: true,
// payload: action.payload || {},
// };