mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: style read-only drawers.
fix: empty state in resources tables.
This commit is contained in:
@@ -7,4 +7,9 @@ export const setBillsTableState = (queries) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
export const resetBillsTableState = () => {
|
||||
return {
|
||||
type: t.BILLS_TABLE_STATE_RESET,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -4,12 +4,15 @@ import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: []
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:bills';
|
||||
@@ -21,14 +24,11 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('BILLS'),
|
||||
...createTableStateReducers('BILLS', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default persistReducer(
|
||||
CONFIG,
|
||||
reducerInstance,
|
||||
);
|
||||
export default persistReducer(CONFIG, reducerInstance);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './bills.reducer';
|
||||
|
||||
const billsTableStateSelector = (state) => state.bills.tableState;
|
||||
|
||||
@@ -15,3 +18,8 @@ export const getBillsTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const billsTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(billsTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
export default {
|
||||
BILLS_TABLE_STATE_SET: 'BILLS/TABLE_STATE_SET',
|
||||
BILLS_TABLE_STATE_RESET: 'BILLS/TABLE_STATE_RESET',
|
||||
};
|
||||
@@ -7,4 +7,8 @@ export const setEstimatesTableState = (queries) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
export const resetEstimatesTableState = () => {
|
||||
return {
|
||||
type: t.ESTIMATES_TABLE_STATE_RESET,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,12 +6,15 @@ import {
|
||||
} from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:estimates';
|
||||
@@ -23,7 +26,7 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('ESTIMATES'),
|
||||
...createTableStateReducers('ESTIMATES', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { isEqual } from 'lodash';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { defaultTableQuery } from './estimates.reducer';
|
||||
|
||||
const estimatesTableState = (state) => state.salesEstimates.tableState;
|
||||
|
||||
|
||||
// Retrieve estimates table query.
|
||||
export const getEstimatesTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
@@ -15,3 +17,8 @@ export const getEstimatesTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const isEstimatesTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(estimatesTableState, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export default {
|
||||
ESTIMATES_TABLE_STATE_SET: 'ESTIMATES/TABLE_STATE_SET',
|
||||
ESTIMATES_TABLE_STATE_RESET: 'ESTIMATES/TABLE_STATE_RESET',
|
||||
};
|
||||
|
||||
@@ -7,4 +7,10 @@ export const setInvoicesTableState = (queries) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const resetInvoicesTableState= () => {
|
||||
return {
|
||||
type: t.INVOICES_TABLE_STATE_RESET,
|
||||
};
|
||||
}
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
|
||||
@@ -6,12 +6,15 @@ import {
|
||||
} from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: []
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:invoices';
|
||||
@@ -23,7 +26,7 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('INVOICES'),
|
||||
...createTableStateReducers('INVOICES', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { isEqual } from 'lodash';
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './invoices.reducer';
|
||||
|
||||
const invoicesTableStateSelector = (state) => state.salesInvoices.tableState;
|
||||
|
||||
@@ -17,3 +19,14 @@ export const getInvoicesTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve invoices table state.
|
||||
*/
|
||||
export const isInvoicesTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
invoicesTableStateSelector,
|
||||
(tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
export default {
|
||||
INVOICES_TABLE_STATE_SET: 'INVOICES/TABLE_STATE_SET',
|
||||
INVOICES_TABLE_STATE_RESET: 'INVOICES/TABLE_STATE_RESET',
|
||||
};
|
||||
@@ -7,4 +7,10 @@ export const setPaymentMadesTableState = (queries) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
export const resetPaymentMadesTableState = (queries) => {
|
||||
return {
|
||||
type: t.PAYMENT_MADES_TABLE_STATE_RESET,
|
||||
payload: { queries },
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer, purgeStoredState } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
sortBy: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
sortBy: [],
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:paymentMades';
|
||||
|
||||
const CONFIG = {
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
whitelist: [],
|
||||
storage,
|
||||
}
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('PAYMENT_MADES'),
|
||||
...createTableStateReducers('PAYMENT_MADES', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './paymentMades.reducer';
|
||||
|
||||
const paymentMadesTableStateSelector = (state) => state.paymentMades.tableState;
|
||||
|
||||
@@ -15,3 +18,8 @@ export const getPaymentMadesTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const paymentsTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(paymentMadesTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export default {
|
||||
PAYMENT_MADES_TABLE_STATE_SET: 'PAYMENT_MADES/TABLE_STATE_SET',
|
||||
PAYMENT_MADES_TABLE_STATE_RESET: 'PAYMENT_MADES/TABLE_STATE_RESET',
|
||||
};
|
||||
|
||||
@@ -7,4 +7,8 @@ export const setPaymentReceivesTableState = (queries) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
export const resetPaymentReceivesTableState = () => {
|
||||
return {
|
||||
type: t.PAYMENT_RECEIVES_TABLE_STATE_RESET
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,12 +6,15 @@ import {
|
||||
} from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:paymentReceives';
|
||||
@@ -23,7 +26,7 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('PAYMENT_RECEIVES'),
|
||||
...createTableStateReducers('PAYMENT_RECEIVES', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import {
|
||||
paginationLocationQuery,
|
||||
} from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './paymentReceives.reducer';
|
||||
|
||||
const paymentReceiveTableState = (state) => state.paymentReceives.tableState;
|
||||
|
||||
@@ -15,4 +19,8 @@ export const getPaymentReceiveTableStateFactory = () => createSelector(
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
);
|
||||
export const paymentsTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(paymentReceiveTableState, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export default {
|
||||
PAYMENT_RECEIVES_TABLE_STATE_SET: 'PAYMENT_RECEIVES/TABLE_STATE_SET',
|
||||
PAYMENT_RECEIVES_TABLE_STATE_RESET: 'PAYMENT_RECEIVES/TABLE_STATE_RESET',
|
||||
};
|
||||
|
||||
@@ -4,12 +4,15 @@ import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:accounts';
|
||||
@@ -21,7 +24,7 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('ACCOUNTS'),
|
||||
...createTableStateReducers('ACCOUNTS', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './accounts.reducer';
|
||||
|
||||
// Accounts table state selector
|
||||
const accountsTableStateSelector = (state, props) => state.accounts.tableState;
|
||||
@@ -16,3 +19,8 @@ export const getAccountsTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const accountsTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(accountsTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
export default {
|
||||
ACCOUNTS_TABLE_STATE_SET: 'ACCOUNTS/TABLE_STATE_SET',
|
||||
ACCOUNTS_TABLE_STATE_RESET: 'ACCOUNTS/TABLE_STATE_RESET',
|
||||
};
|
||||
@@ -3,26 +3,31 @@ import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
|
||||
// Default table query state.
|
||||
export const defaultTableQueryState = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
inactiveMode: false,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
// initial data.
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
inactiveMode: false,
|
||||
filterRoles: []
|
||||
},
|
||||
tableState: defaultTableQueryState,
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('CUSTOMERS'),
|
||||
...createTableStateReducers('CUSTOMERS', defaultTableQueryState),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:estimates';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: [],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: [],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQueryState } from './customers.reducer';
|
||||
|
||||
const customerTableStateSelector = (state) => state.customers.tableState;
|
||||
|
||||
@@ -14,3 +17,9 @@ export const getCustomersTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const customersTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(customerTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQueryState);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export default {
|
||||
CUSTOMERS_TABLE_STATE_SET: 'CUSTOMERS/TABLE_STATE_SET'
|
||||
CUSTOMERS_TABLE_STATE_SET: 'CUSTOMERS/TABLE_STATE_SET',
|
||||
CUSTOMERS_TABLE_STATE_RESET: 'CUSTOMERS/TABLE_STATE_RESET'
|
||||
};
|
||||
|
||||
@@ -11,4 +11,9 @@ export const setExpensesTableState = (queries) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
export const resetExpensesTableState = () => {
|
||||
return {
|
||||
type: t.EXPENSES_TABLE_STATE_RESET,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -4,12 +4,17 @@ import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
// Default table query.
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
// Initial state.
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:expenses';
|
||||
@@ -21,7 +26,7 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('EXPENSES'),
|
||||
...createTableStateReducers('EXPENSES', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { defaultTableQuery } from './expenses.reducer';
|
||||
|
||||
// Items table state selectors.
|
||||
const itemsTableStateSelector = (state) => state.expenses.tableState;
|
||||
const expensesTableStateSelector = (state) => state.expenses.tableState;
|
||||
|
||||
// Retrive expenses table query.
|
||||
export const getExpensesTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
itemsTableStateSelector,
|
||||
expensesTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
@@ -16,3 +19,8 @@ export const getExpensesTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const expensesTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(expensesTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export default {
|
||||
EXPENSES_TABLE_STATE_SET: 'EXPENSES/TABLE_STATE_SET',
|
||||
EXPENSES_TABLE_STATE_RESET: 'EXPENSES/TABLE_STATE_RESET',
|
||||
};
|
||||
|
||||
@@ -7,4 +7,11 @@ export const setItemsTableState = (queries) => {
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
export const resetItemsTableState = () => {
|
||||
return {
|
||||
type: t.ITEMS_TABLE_STATE_RESET,
|
||||
};
|
||||
}
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
|
||||
@@ -4,13 +4,16 @@ import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
inactiveMode: false,
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
inactiveMode: false,
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
selectedRows: [],
|
||||
};
|
||||
|
||||
@@ -18,12 +21,12 @@ const STORAGE_KEY = 'bigcapital:items';
|
||||
|
||||
const CONFIG = {
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
whitelist: [],
|
||||
storage,
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('ITEMS'),
|
||||
...createTableStateReducers('ITEMS', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './items.reducer';
|
||||
|
||||
const itemsTableStateSelector = (state) => state.items.tableState;
|
||||
|
||||
@@ -15,3 +18,8 @@ export const getItemsTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const isItemsTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(itemsTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
export default {
|
||||
ITEMS_TABLE_STATE_SET: 'ITEMS/TABLE_STATE_SET',
|
||||
ITEMS_TABLE_STATE_RESET: 'ITEMS/TABLE_STATE_RESET',
|
||||
};
|
||||
@@ -4,12 +4,15 @@ import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
}
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:manualJournals';
|
||||
@@ -21,7 +24,7 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('MANUAL_JOURNALS'),
|
||||
...createTableStateReducers('MANUAL_JOURNALS', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './manualJournals.reducers';
|
||||
|
||||
const manualJournalsTableState = (state) => state.manualJournals.tableState;
|
||||
|
||||
@@ -15,3 +18,8 @@ export const getManualJournalsTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const manualJournalTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(manualJournalsTableState, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export default {
|
||||
MANUAL_JOURNALS_TABLE_STATE_SET: 'MANUAL_JOURNALS/TABLE_STATE_SET',
|
||||
MANUAL_JOURNALS_TABLE_STATE_RESET: 'MANUAL_JOURNALS/TABLE_STATE_RESET',
|
||||
};
|
||||
|
||||
@@ -7,4 +7,8 @@ export const setReceiptsTableState = (queries) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
export const resetReceiptsTableState = () => {
|
||||
return {
|
||||
type: t.RECEIPTS_TABLE_STATE_RESET,
|
||||
};
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer, purgeStoredState } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQuery = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
filterRoles: []
|
||||
},
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:receipts';
|
||||
@@ -23,14 +24,11 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('RECEIPTS'),
|
||||
...createTableStateReducers('RECEIPTS', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
},
|
||||
});
|
||||
|
||||
export default persistReducer(
|
||||
CONFIG,
|
||||
reducerInstance,
|
||||
);
|
||||
export default persistReducer(CONFIG, reducerInstance);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './receipts.reducer';
|
||||
|
||||
const receiptTableStateSelector = (state) => state.salesReceipts.tableState;
|
||||
|
||||
@@ -15,3 +18,8 @@ export const getReceiptsTableStateFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const receiptsTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(receiptTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
export default {
|
||||
RECEIPTS_TABLE_STATE_SET: 'RECEIPTS/TABLE_STATE_SET',
|
||||
RECEIPTS_TABLE_STATE_RESET: 'RECEIPTS/TABLE_STATE_RESET',
|
||||
};
|
||||
@@ -1,9 +1,10 @@
|
||||
|
||||
const TYPES = {
|
||||
TABLE_STATE_SET: 'TABLE_STATE_SET',
|
||||
TABLE_STATE_RESET: 'TABLE_STATE_RESET'
|
||||
};
|
||||
|
||||
export const createTableStateReducers = (RESOURCE_NAME) => ({
|
||||
export const createTableStateReducers = (RESOURCE_NAME, defaultTableQuery) => ({
|
||||
/**
|
||||
* Resource table state set.
|
||||
*/
|
||||
@@ -15,4 +16,10 @@ export const createTableStateReducers = (RESOURCE_NAME) => ({
|
||||
...queries,
|
||||
};
|
||||
},
|
||||
|
||||
[`${RESOURCE_NAME}/${TYPES.TABLE_STATE_RESET}`]: (state, action) => {
|
||||
state.tableState = {
|
||||
...defaultTableQuery,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
19
client/src/store/vendors/vendors.reducer.js
vendored
19
client/src/store/vendors/vendors.reducer.js
vendored
@@ -4,13 +4,16 @@ import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQueryState = {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
inactiveMode: false,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
pageIndex: 0,
|
||||
inactiveMode: false,
|
||||
filterRoles: [],
|
||||
},
|
||||
tableState: defaultTableQueryState,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:vendors';
|
||||
@@ -22,11 +25,11 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('VENDORS'),
|
||||
...createTableStateReducers('VENDORS', defaultTableQueryState),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default persistReducer(CONFIG, reducerInstance);
|
||||
|
||||
12
client/src/store/vendors/vendors.selectors.js
vendored
12
client/src/store/vendors/vendors.selectors.js
vendored
@@ -1,7 +1,8 @@
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import {
|
||||
paginationLocationQuery,
|
||||
} from 'store/selectors';
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { defaultTableQueryState } from './vendors.reducer';
|
||||
|
||||
const vendorsTableStateSelector = (state) => state.vendors.tableState;
|
||||
|
||||
@@ -20,4 +21,7 @@ export const getVendorsTableStateFactory = () =>
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
export const vendorsTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(vendorsTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQueryState);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user