1234567891011121314151617181920212223242526272829 |
- import { createReducer } from '@reduxjs/toolkit';
- import {
- actionCategoriesSuccess,
- actionCategoriesReject,
- actionCategorySuccess,
- actionCategoryReject,
- } from '../action';
- const initialState = { categories: [], category: {} };
- const reducerCategories = createReducer(initialState, {
- [actionCategoriesSuccess]: (state, { payload: categories }) => {
- const category = state.category;
- return { categories, category };
- },
- [actionCategoriesReject]: (state, _) => {
- return state;
- },
- [actionCategorySuccess]: (state, { payload: category }) => {
- const categories = state.category;
- return { categories, category };
- },
- [actionCategoryReject]: (state, _) => {
- return state;
- },
- });
- export default reducerCategories;
|