mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
feat: Receivable aging summary front-end.
This commit is contained in:
@@ -3,9 +3,6 @@ import t from 'store/types';
|
||||
|
||||
export const fetchResourceColumns = ({ resourceSlug }) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
ApiService.get(`resources/${resourceSlug}/columns`).then((response) => {
|
||||
dispatch({
|
||||
type: t.RESOURCE_COLUMNS_SET,
|
||||
@@ -22,9 +19,6 @@ export const fetchResourceColumns = ({ resourceSlug }) => {
|
||||
|
||||
export const fetchResourceFields = ({ resourceSlug }) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
ApiService.get(`resources/${resourceSlug}/fields`).then((response) => {
|
||||
dispatch({
|
||||
type: t.RESOURCE_FIELDS_SET,
|
||||
@@ -37,4 +31,19 @@ export const fetchResourceFields = ({ resourceSlug }) => {
|
||||
resolve(response);
|
||||
}).catch((error) => { reject(error); });
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchResourceData = ({ resourceSlug }) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.get(`/resources/${resourceSlug}/data`).then((response) => {
|
||||
dispatch({
|
||||
type: t.RESOURCE_DATA_SET,
|
||||
payload: {
|
||||
data: response.data.data,
|
||||
resource_key: resourceSlug,
|
||||
},
|
||||
});
|
||||
resolve(response);
|
||||
}).catch(error => { reject(error); });
|
||||
});
|
||||
};
|
||||
@@ -3,6 +3,7 @@ import t from 'store/types';
|
||||
import { pickItemsFromIds } from 'store/selectors'
|
||||
|
||||
const initialState = {
|
||||
data: {},
|
||||
fields: {},
|
||||
columns: {},
|
||||
resourceFields: {},
|
||||
@@ -50,6 +51,14 @@ export default createReducer(initialState, {
|
||||
};
|
||||
state.resourceFields[action.resource_slug] = action.fields.map(f => f.id);
|
||||
},
|
||||
|
||||
[t.RESOURCE_DATA_SET]: (state, action) => {
|
||||
const { data, resource_key: resourceKey } = action.payload;
|
||||
const dataMapped = {};
|
||||
|
||||
data.forEach((item) => { dataMapped[item.id] = item; })
|
||||
state.data[resourceKey] = dataMapped;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -96,4 +105,9 @@ export const getResourceColumn = (state, columnId) => {
|
||||
|
||||
export const getResourceMetadata = (state, resourceSlug) => {
|
||||
return state.resources.metadata[resourceSlug];
|
||||
};
|
||||
|
||||
|
||||
export const getResourceData = (state, resourceSlug) => {
|
||||
return state.resources.data[resourceSlug] || {};
|
||||
};
|
||||
Reference in New Issue
Block a user