mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
fix: credit & vendor reducer.
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import t from 'store/types';
|
||||
|
||||
export const setCreditNotesTableState = (queries) => {
|
||||
export const setCreditNoteTableState = (queries) => {
|
||||
return {
|
||||
type: t.CREDIT_NOTES_TABLE_STATE_SET,
|
||||
payload: { queries },
|
||||
};
|
||||
};
|
||||
|
||||
export const resetCreditNotesTableState = () => {
|
||||
export const resetCreditNoteTableState = () => {
|
||||
return {
|
||||
type: t.CREDIT_NOTES_TABLE_STATE_RESET,
|
||||
};
|
||||
};
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
@@ -15,7 +15,7 @@ const initialState = {
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:creditNotes';
|
||||
const STORAGE_KEY = 'bigcapital:credit_notes';
|
||||
|
||||
const CONFIG = {
|
||||
key: STORAGE_KEY,
|
||||
29
src/store/CreditNote/creditNote.selector.js
Normal file
29
src/store/CreditNote/creditNote.selector.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { isEqual } from 'lodash';
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './creditNote.reducer';
|
||||
|
||||
const creditsTableStateSelector = (state) => state.creditNotes.tableState;
|
||||
|
||||
/**
|
||||
* Retrieve credit notes table state.
|
||||
*/
|
||||
export const getCreditNotesTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
creditsTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve credit notes table state.
|
||||
*/
|
||||
export const isCreditNotesTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(creditsTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
export default {
|
||||
CREDIT_NOTES_TABLE_STATE_SET: 'CREDIT_NOTE/TABLE_STATE_SET',
|
||||
CREDIT_NOTES_TABLE_STATE_SET: 'CREDIT_NOTES/TABLE_STATE_SET',
|
||||
CREDIT_NOTES_TABLE_STATE_RESET: 'CREDIT_NOTE/TABLE_STATE_RESET',
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
import { isEqual } from 'lodash';
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './creditNotes.reducer';
|
||||
|
||||
const creditNotesTableStateSelector = (state) => state.creditNotes.tableState;
|
||||
|
||||
/**
|
||||
* Retrieve credit note table state.
|
||||
*/
|
||||
export const getCreditNoteTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
creditNotesTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve Credit note table state.
|
||||
*/
|
||||
export const isCreditNoteTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(creditNotesTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
@@ -15,7 +15,7 @@ const initialState = {
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:vendorsCreditNotes';
|
||||
const STORAGE_KEY = 'bigcapital:vendor_credits';
|
||||
|
||||
const CONFIG = {
|
||||
key: STORAGE_KEY,
|
||||
@@ -24,7 +24,7 @@ const CONFIG = {
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('VENDORS_CREDIT_NOTES', defaultTableQuery),
|
||||
...createTableStateReducers('VENDOR_CREDITS', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
16
src/store/VendorCredit/vendorCredit.actions.js
Normal file
16
src/store/VendorCredit/vendorCredit.actions.js
Normal file
@@ -0,0 +1,16 @@
|
||||
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 = () => {};
|
||||
31
src/store/VendorCredit/vendorCredit.selector.js
Normal file
31
src/store/VendorCredit/vendorCredit.selector.js
Normal file
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
});
|
||||
4
src/store/VendorCredit/vendorCredit.type.js
Normal file
4
src/store/VendorCredit/vendorCredit.type.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export default {
|
||||
VENDOR_CREDITS_TABLE_STATE_SET: 'VENDOR_CREDITS/TABLE_STATE_SET',
|
||||
VENDOR_CREDITS_NOTES_TABLE_STATE_RESET: 'VENDOR_CREDITS/TABLE_STATE_RESET',
|
||||
};
|
||||
@@ -31,9 +31,9 @@ import paymentMades from './PaymentMades/paymentMades.reducer';
|
||||
import organizations from './organizations/organizations.reducers';
|
||||
import subscriptions from './subscription/subscription.reducer';
|
||||
import inventoryAdjustments from './inventoryAdjustments/inventoryAdjustment.reducer';
|
||||
import creditNotes from './CreditNotes/creditNotes.reducer'
|
||||
import vendorsCreditNotes from './vendorsCreditNotes/vendorsCreditNotes.reducer'
|
||||
import plans from './plans/plans.reducer';
|
||||
import creditNotes from './CreditNote/creditNote.reducer';
|
||||
import vendorCredit from './VendorCredit/VendorCredit.reducer';
|
||||
|
||||
const appReducer = combineReducers({
|
||||
authentication,
|
||||
@@ -65,9 +65,9 @@ const appReducer = combineReducers({
|
||||
paymentReceives,
|
||||
paymentMades,
|
||||
inventoryAdjustments,
|
||||
plans,
|
||||
creditNotes,
|
||||
vendorsCreditNotes,
|
||||
plans
|
||||
vendorCredit,
|
||||
});
|
||||
|
||||
// Reset the state of a redux store
|
||||
@@ -75,7 +75,7 @@ const rootReducer = (state, action) => {
|
||||
if (action.type === types.RESET) {
|
||||
state = undefined;
|
||||
}
|
||||
return appReducer(state, action)
|
||||
}
|
||||
return appReducer(state, action);
|
||||
};
|
||||
|
||||
export default rootReducer;
|
||||
export default rootReducer;
|
||||
|
||||
@@ -28,8 +28,8 @@ import paymentMades from './PaymentMades/paymentMades.type';
|
||||
import organizations from './organizations/organizations.types';
|
||||
import subscription from './subscription/subscription.types';
|
||||
import inventoryAdjustments from './inventoryAdjustments/inventoryAdjustment.type';
|
||||
import creditNotes from './CreditNotes/creditNotes.type';
|
||||
import vendorsCreditNotes from './vendorsCreditNotes/vendorsCreditNotes.type';
|
||||
import creditNote from './CreditNote/creditNote.type';
|
||||
import vendorCredit from './VendorCredit/vendorCredit.type';
|
||||
import plans from './plans/plans.types';
|
||||
|
||||
export default {
|
||||
@@ -63,7 +63,7 @@ export default {
|
||||
...organizations,
|
||||
...subscription,
|
||||
...inventoryAdjustments,
|
||||
...creditNotes,
|
||||
...vendorsCreditNotes,
|
||||
...plans,
|
||||
...creditNote,
|
||||
...vendorCredit
|
||||
};
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import t from 'store/types';
|
||||
|
||||
export const setVendorsCreditNoteTableState = (queries) => {
|
||||
return {
|
||||
type: t.VENDORS_CREDIT_NOTE_TABLE_STATE_SET,
|
||||
payload: { queries },
|
||||
};
|
||||
};
|
||||
|
||||
export const resetVendorsCreditNoteTableState = () => {
|
||||
return {
|
||||
type: t.VENDORS_CREDIT_NOTE_TABLE_STATE_RESET,
|
||||
};
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import { isEqual } from 'lodash';
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
import { defaultTableQuery } from './vendorsCreditNotes.reducer';
|
||||
|
||||
const VendorsCreditNoteTableStateSelector = (state) =>
|
||||
state.vendorsCreditNotes.tableState;
|
||||
|
||||
export const getVendorsCreditNoteTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
VendorsCreditNoteTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const isVendorsCreditNoteTableStateChangedFactory = () =>
|
||||
createDeepEqualSelector(VendorsCreditNoteTableStateSelector, (tableState) => {
|
||||
return !isEqual(tableState, defaultTableQuery);
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
VENDORS_CREDIT_NOTE_TABLE_STATE_SET: 'VENDORS_CREDIT_NOTE/TABLES_STATE_SET',
|
||||
VENDORS_CREDIT_NOTE_TABLE_STATE_RESET:
|
||||
'VENDORS_CREDIT_NOTE/TABLE_STATE/RESET',
|
||||
};
|
||||
Reference in New Issue
Block a user