24 lines
638 B
JavaScript
24 lines
638 B
JavaScript
export const initialState = {
|
|
searchQuery: '',
|
|
filters: {
|
|
diet: '',
|
|
cuisine: 'indian',
|
|
maxTime: '',
|
|
},
|
|
selectedRecipe: null,
|
|
};
|
|
|
|
export const recipeReducer = (state, action) => {
|
|
switch (action.type) {
|
|
case 'SET_SEARCH':
|
|
return { ...state, searchQuery: action.payload };
|
|
case 'SET_FILTER':
|
|
return {
|
|
...state, filters: { ...state.filter, [action.field]: action.payload },
|
|
};
|
|
case 'SET_SELECTED_RECIPE':
|
|
return { ...state, selectedRecipe: action.payload };
|
|
default:
|
|
return state;
|
|
}
|
|
}; |