1234567891011121314151617181920212223242526272829 |
- import { createReducer } from '@reduxjs/toolkit';
- import {
- actionGoodsSuccess,
- actionGoodsReject,
- actionGoodSuccess,
- actionGoodReject,
- } from '../action';
- const initialState = { goods: [], good: {} };
- const reducerGoods = createReducer(initialState, {
- [actionGoodsSuccess]: (state, { payload: goods }) => {
- const good = state.good;
- return { goods, good };
- },
- [actionGoodsReject]: (state, _) => {
- return state;
- },
- [actionGoodSuccess]: (state, { payload: good }) => {
- const goods = state.goods;
- return { goods, good };
- },
- [actionGoodReject]: (state, _) => {
- return state;
- },
- });
- export default reducerGoods;
|