mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
re-structure to monorepo.
This commit is contained in:
15
packages/webapp/src/store/vendors/vendors.actions.tsx
vendored
Normal file
15
packages/webapp/src/store/vendors/vendors.actions.tsx
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// @ts-nocheck
|
||||
import t from '@/store/types';
|
||||
|
||||
export const setVendorsTableState = (queries) => {
|
||||
return {
|
||||
type: t.VENDORS_TABLE_STATE_SET,
|
||||
payload: { queries },
|
||||
};
|
||||
}
|
||||
|
||||
export const resetVendorsTableState = () => {
|
||||
return {
|
||||
type: t.VENDORS_TABLE_STATE_RESET,
|
||||
}
|
||||
}
|
||||
36
packages/webapp/src/store/vendors/vendors.reducer.tsx
vendored
Normal file
36
packages/webapp/src/store/vendors/vendors.reducer.tsx
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// @ts-nocheck
|
||||
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 t from '@/store/types';
|
||||
|
||||
export const defaultTableQueryState = {
|
||||
pageSize: 20,
|
||||
pageIndex: 0,
|
||||
inactiveMode: false,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: defaultTableQueryState,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:vendors';
|
||||
|
||||
const CONFIG = {
|
||||
key: STORAGE_KEY,
|
||||
whitelist: [],
|
||||
storage,
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('VENDORS', defaultTableQueryState),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
},
|
||||
});
|
||||
|
||||
export default persistReducer(CONFIG, reducerInstance);
|
||||
28
packages/webapp/src/store/vendors/vendors.selectors.tsx
vendored
Normal file
28
packages/webapp/src/store/vendors/vendors.selectors.tsx
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// @ts-nocheck
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { createDeepEqualSelector } from '@/utils';
|
||||
import { paginationLocationQuery } from '@/store/selectors';
|
||||
import { defaultTableQueryState } from './vendors.reducer';
|
||||
|
||||
const vendorsTableStateSelector = (state) => state.vendors.tableState;
|
||||
|
||||
/**
|
||||
* Retrieve vendors table state.
|
||||
*/
|
||||
export const getVendorsTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
vendorsTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const vendorsTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(vendorsTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQueryState);
|
||||
});
|
||||
6
packages/webapp/src/store/vendors/vendors.types.tsx
vendored
Normal file
6
packages/webapp/src/store/vendors/vendors.types.tsx
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// @ts-nocheck
|
||||
export default {
|
||||
VENDORS_TABLE_STATE_SET: 'VENDORS/TABLE_STATE_SET',
|
||||
VENDORS_TABLE_STATE_RESET: 'VENDORS/TABLE_STATE_RESET',
|
||||
VENDORS_SELECTED_ROWS_SET: 'VENDORS/SELECTED_ROWS_SET',
|
||||
};
|
||||
Reference in New Issue
Block a user