mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
re-structure to monorepo.
This commit is contained in:
18
packages/webapp/src/store/customers/customers.actions.tsx
Normal file
18
packages/webapp/src/store/customers/customers.actions.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
// @ts-nocheck
|
||||
import t from '@/store/types';
|
||||
|
||||
/**
|
||||
* Sets the customers table state.
|
||||
*/
|
||||
export const setCustomersTableState = (queries) => {
|
||||
return {
|
||||
type: t.CUSTOMERS_TABLE_STATE_SET,
|
||||
payload: { queries },
|
||||
};
|
||||
};
|
||||
|
||||
export const resetCustomersTableState = () => {
|
||||
return {
|
||||
type: t.CUSTOMERS_TABLE_STATE_RESET,
|
||||
};
|
||||
}
|
||||
34
packages/webapp/src/store/customers/customers.reducer.tsx
Normal file
34
packages/webapp/src/store/customers/customers.reducer.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
// @ts-nocheck
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
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: 20,
|
||||
pageIndex: 0,
|
||||
inactiveMode: false,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
// initial data.
|
||||
const initialState = {
|
||||
tableState: defaultTableQueryState,
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('CUSTOMERS', defaultTableQueryState),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:estimates';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: [],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
26
packages/webapp/src/store/customers/customers.selectors.tsx
Normal file
26
packages/webapp/src/store/customers/customers.selectors.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
// @ts-nocheck
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { paginationLocationQuery } from '@/store/selectors';
|
||||
import { createDeepEqualSelector } from '@/utils';
|
||||
import { defaultTableQueryState } from './customers.reducer';
|
||||
|
||||
const customerTableStateSelector = (state) => state.customers.tableState;
|
||||
|
||||
export const getCustomersTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
customerTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const customersTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(customerTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQueryState);
|
||||
});
|
||||
|
||||
5
packages/webapp/src/store/customers/customers.type.tsx
Normal file
5
packages/webapp/src/store/customers/customers.type.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
// @ts-nocheck
|
||||
export default {
|
||||
CUSTOMERS_TABLE_STATE_SET: 'CUSTOMERS/TABLE_STATE_SET',
|
||||
CUSTOMERS_TABLE_STATE_RESET: 'CUSTOMERS/TABLE_STATE_RESET'
|
||||
};
|
||||
Reference in New Issue
Block a user