evoleasing-account/reducers/dealsReducer.js
2023-08-28 10:08:19 +03:00

104 lines
1.7 KiB
JavaScript

import { HYDRATE } from 'next-redux-wrapper';
import * as actionTypes from '../constants/actionTypes';
import initialState from "./initialState";
const dealsReducer = (state = initialState.deals, action) =>
{
switch (action.type)
{
case actionTypes.DEALS_LOADED:
{
return {
...state,
loaded: action.data.loaded,
};
}
case actionTypes.DEALS_LIST:
{
return {
...state,
list: action.data.list,
};
}
case actionTypes.DEAL_LOADED:
{
return {
...state,
deal: { ...state.deal, ...{ loaded: action.data.loaded, } },
};
}
case actionTypes.DEAL_OFFERS_LIST:
{
return {
...state,
deal: { ...state.deal, ...{ offers: action.data.offers, } },
};
}
case actionTypes.DEAL_DOCUMENTS_LIST:
{
return {
...state,
deal: { ...state.deal, ...{ documents: action.data.documents, } },
};
}
case actionTypes.DEAL_CONTRACTS_LIST:
{
return {
...state,
deal: { ...state.deal, ...{ contracts: action.data.contracts, } },
};
}
case actionTypes.DEALS_RESET:
{
return {
loaded: false,
list: undefined,
deal: {
loaded: false,
offers: {
list: undefined,
filtered: undefined,
},
documents: {
list: undefined,
},
contracts: {
list: undefined,
},
},
};
}
case actionTypes.DEAL_RESET:
{
return {
deal: {
loaded: false,
offers: {
list: undefined,
filtered: undefined,
},
documents: {
list: undefined,
},
contracts: {
list: undefined,
},
},
};
}
default: {
return state;
}
}
};
export default dealsReducer;