BIG-5: feat switching between compact and medium table row size.

This commit is contained in:
a.bouhuolia
2021-09-23 10:37:54 +02:00
parent 9b7382e222
commit e949b1b0c7
13 changed files with 190 additions and 55 deletions

View File

@@ -1,5 +1,8 @@
import { camelCase } from 'lodash';
import { createReducer } from '@reduxjs/toolkit';
import storage from 'redux-persist/lib/storage';
import { persistReducer, purgeStoredState } from 'redux-persist';
import t from 'store/types';
const initialState = {
@@ -11,10 +14,21 @@ const initialState = {
bills: {},
billPayments: {},
salesEstimates: {},
items: {
tableSize: 'medium',
},
},
};
export default createReducer(initialState, {
const STORAGE_KEY = 'bigcapital:settings';
const PRESIST_CONFIG = {
key: STORAGE_KEY,
whitelist: ['data'],
storage,
};
const reducerInstance = createReducer(initialState, {
[t.SETTING_SET]: (state, action) => {
const { options } = action;
const _data = {
@@ -32,4 +46,19 @@ export default createReducer(initialState, {
});
state.data = _data;
},
[t.SETTING_ADD]: (state, action) => {
const { group, key, value } = action.payload;
const newData = {
...state.data,
[group]: {
...state.data[group],
[key]: value,
},
};
state.data = newData;
},
});
export default persistReducer(PRESIST_CONFIG, reducerInstance);