mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
Merge branch 'master' of https://github.com/abouolia/Ratteb
# Conflicts: # client/src/style/App.scss
This commit is contained in:
@@ -4,10 +4,11 @@ import t from 'store/types';
|
||||
export const submitInventoryAdjustment = ({ form }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.post('inventory_adjustments', form).then((response) => {
|
||||
resolve(response);
|
||||
}),
|
||||
caches((error) => {
|
||||
ApiService.post('inventory_adjustments/quick', form)
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
|
||||
@@ -51,7 +52,7 @@ export const fetchInventoryAdjustmentsTable = ({ query } = {}) => {
|
||||
dispatch({
|
||||
type: t.INVENTORY_ADJUSTMENTS_PAGE_SET,
|
||||
payload: {
|
||||
inventory_adjustments: response.data,
|
||||
inventory_adjustments: response.data.inventoy_adjustments,
|
||||
pagination: response.data.pagination,
|
||||
customViewId:
|
||||
response.data?.filter_meta?.view?.custom_view_id || -1,
|
||||
@@ -60,7 +61,7 @@ export const fetchInventoryAdjustmentsTable = ({ query } = {}) => {
|
||||
dispatch({
|
||||
type: t.INVENTORY_ADJUSTMENT_ITEMS_SET,
|
||||
payload: {
|
||||
inventory_adjustment: response.data,
|
||||
inventory_adjustment: response.data.inventoy_adjustments,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
|
||||
@@ -14,9 +14,6 @@ const initialState = {
|
||||
page_size: 12,
|
||||
page: 1,
|
||||
},
|
||||
paginationMeta: {
|
||||
total: 0,
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
@@ -37,7 +34,6 @@ export default createReducer(initialState, {
|
||||
|
||||
const viewId = customViewId || -1;
|
||||
const view = state.views[viewId] || {};
|
||||
|
||||
state.views[viewId] = {
|
||||
...view,
|
||||
pages: {
|
||||
@@ -49,7 +45,6 @@ export default createReducer(initialState, {
|
||||
};
|
||||
},
|
||||
|
||||
//useless
|
||||
[t.INVENTORY_ADJUSTMENT_ITEMS_SET]: (state, action) => {
|
||||
const { inventory_adjustment } = action.payload;
|
||||
const _inventory_adjustment = {};
|
||||
|
||||
@@ -5,3 +5,55 @@ import {
|
||||
defaultPaginationMeta,
|
||||
} from 'store/selectors';
|
||||
|
||||
const inventoryAdjustmentTableQuery = (state) =>
|
||||
state.inventoryAdjustments.tableQuery;
|
||||
|
||||
const inventoryAdjustmentsPaginationSelector = (state, props) => {
|
||||
const viewId = state.inventoryAdjustments.currentViewId;
|
||||
return state.inventoryAdjustments.views?.[viewId];
|
||||
};
|
||||
|
||||
const inventoryAdjustmentItemsSelector = (state) =>
|
||||
state.inventoryAdjustments.items;
|
||||
|
||||
const inventoryAdjustmentCurrentPageSelector = (state, props) => {
|
||||
const currentViewId = state.inventoryAdjustments.currentViewId;
|
||||
const currentView = state.inventoryAdjustments.views?.[currentViewId];
|
||||
const currentPageId = currentView?.paginationMeta?.page;
|
||||
|
||||
return currentView?.pages?.[currentPageId];
|
||||
};
|
||||
|
||||
const getinventoryAdjustmentCurrentViewIdSelector = (state) =>
|
||||
state.inventoryAdjustments.currentViewId;
|
||||
|
||||
export const getInvoiceTableQueryFactory = () =>
|
||||
createSelector(
|
||||
paginationLocationQuery,
|
||||
inventoryAdjustmentTableQuery,
|
||||
(locationQuery, tableQuery) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableQuery,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const getInventoryAdjustmentCurrentPageFactory = () =>
|
||||
createSelector(
|
||||
inventoryAdjustmentCurrentPageSelector,
|
||||
inventoryAdjustmentItemsSelector,
|
||||
(currentPage, items) => {
|
||||
return typeof currentPage === 'object'
|
||||
? pickItemsFromIds(items, currentPage.ids) || []
|
||||
: [];
|
||||
},
|
||||
);
|
||||
|
||||
export const getInventoryAdjustmentPaginationMetaFactory = () =>
|
||||
createSelector(inventoryAdjustmentsPaginationSelector, (Page) => {
|
||||
return {
|
||||
...defaultPaginationMeta(),
|
||||
...(Page?.paginationMeta || {}),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ export default {
|
||||
|
||||
|
||||
INVENTORY_ADJUSTMENTS_TABLE_QUERIES_ADD:
|
||||
'INVENTORY_ADJUSTMENTS_TABLE_QUERIES_ADD',
|
||||
'INVENTORY_ADJUSTMENTS/TABLE_QUERIES_ADD',
|
||||
INVENTORY_ADJUSTMENTS_SET_CURRENT_VIEW:
|
||||
'INVENTORY_ADJUSTMENTS_SET_CURRENT_VIEW',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user