fix: autofill the quick created customer/vendor

This commit is contained in:
Ahmed Bouhuolia
2024-08-13 23:55:53 +02:00
parent ec2b7e332e
commit d2193fdac0
14 changed files with 212 additions and 35 deletions

View File

@@ -1,11 +1,10 @@
// @ts-nocheck
import { createReducer } from '@reduxjs/toolkit';
import { isUndefined, isNumber } from 'lodash';
import { isUndefined, isNumber, omit } from 'lodash';
import t from '@/store/types';
import { persistReducer, purgeStoredState } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
const initialState = {
pageTitle: '',
pageSubtitle: '',
@@ -23,6 +22,7 @@ const initialState = {
appIntlIsLoading: true,
sidebarSubmenu: { isOpen: false, submenuId: null },
features: {},
autofill: {},
};
const STORAGE_KEY = 'bigcapital:dashboard';
@@ -143,6 +143,18 @@ const reducerInstance = createReducer(initialState, {
[t.RESET]: () => {
purgeStoredState(CONFIG);
},
[t.ADD_AUTOFILL_REF]: (state, action) => {
state.autofill[action.payload.ref] = action.payload.payload || null;
},
[t.REMOVE_AUTOFILL_REF]: (state, action) => {
state.autofill = omit(state.autofill, [action.payload.ref]);
},
[t.RESET_AUTOFILL_REF]: (state, action) => {
state.autofill = {};
},
});
export default persistReducer(CONFIG, reducerInstance);