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:
@@ -0,0 +1,35 @@
|
||||
// @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 defaultTableQuery = {
|
||||
pageSize: 20,
|
||||
pageIndex: 0,
|
||||
filterRoles: [],
|
||||
viewSlug: null,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:vendor_credits';
|
||||
|
||||
const CONFIG = {
|
||||
key: STORAGE_KEY,
|
||||
whitelist: [],
|
||||
storage,
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('VENDOR_CREDITS', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
},
|
||||
});
|
||||
|
||||
export default persistReducer(CONFIG, reducerInstance);
|
||||
@@ -0,0 +1,17 @@
|
||||
// @ts-nocheck
|
||||
import t from '@/store/types';
|
||||
|
||||
export const setVendorCreditTableState = (queries) => {
|
||||
return {
|
||||
type: t.VENDOR_CREDITS_TABLE_STATE_SET,
|
||||
payload: { queries },
|
||||
};
|
||||
};
|
||||
|
||||
export const resetVendorCreditTableState = () => {
|
||||
return {
|
||||
type: t.VENDOR_CREDITS_NOTES_TABLE_STATE_RESET,
|
||||
};
|
||||
};
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
@@ -0,0 +1,32 @@
|
||||
// @ts-nocheck
|
||||
import { isEqual } from 'lodash';
|
||||
import { paginationLocationQuery } from '@/store/selectors';
|
||||
import { createDeepEqualSelector } from '@/utils';
|
||||
import { defaultTableQuery } from './VendorCredit.reducer';
|
||||
|
||||
const vendorCreditsTableStateSelector = (state) => {
|
||||
return state.vendorCredit.tableState;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve vendor credit table state.
|
||||
*/
|
||||
export const getVendorCreditTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
vendorCreditsTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve vendor credit table state.
|
||||
*/
|
||||
export const isVendorCreditTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(vendorCreditsTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
// @ts-nocheck
|
||||
export default {
|
||||
VENDOR_CREDITS_TABLE_STATE_SET: 'VENDOR_CREDITS/TABLE_STATE_SET',
|
||||
VENDOR_CREDITS_NOTES_TABLE_STATE_RESET: 'VENDOR_CREDITS/TABLE_STATE_RESET',
|
||||
};
|
||||
Reference in New Issue
Block a user