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

@@ -125,3 +125,23 @@ export function closeSidebarSubmenu() {
type: t.SIDEBAR_SUBMENU_CLOSE,
};
}
export function addAutofill(autofillRef: number, payload: any) {
return {
type: t.ADD_AUTOFILL_REF,
payload: { ref: autofillRef, payload }
}
}
export function removeAutofill(autofillRef: number) {
return {
type: t.REMOVE_AUTOFILL_REF,
payload: { ref: autofillRef}
}
}
export function resetAutofill() {
return {
type: t.RESET_AUTOFILL_REF,
}
}

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);

View File

@@ -21,4 +21,7 @@ export default {
SPLASH_START_LOADING: 'SPLASH_START_LOADING',
SPLASH_STOP_LOADING: 'SPLASH_STOP_LOADING',
SET_FEATURE_DASHBOARD_META: 'SET_FEATURE_DASHBOARD_META',
ADD_AUTOFILL_REF: 'ADD_AUTOFILL_REF',
REMOVE_AUTOFILL_REF: 'REMOVE_AUTOFILL_REF',
RESET_AUTOFILL_REF: 'RESET_AUTOFILL_REF'
};