mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feature : Puschases & Sales / fix : tasks
This commit is contained in:
@@ -8,7 +8,6 @@ export const submitEstimate = ({ form }) => {
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
ApiService.post('sales/estimates', form)
|
||||
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
@@ -21,7 +20,6 @@ export const submitEstimate = ({ form }) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
|
||||
reject(data?.errors);
|
||||
});
|
||||
});
|
||||
@@ -30,23 +28,14 @@ export const submitEstimate = ({ form }) => {
|
||||
export const editEstimate = (id, form) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
ApiService.post(`sales/estimates/${id}`, form)
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
reject(data?.errors);
|
||||
});
|
||||
});
|
||||
@@ -74,12 +63,12 @@ export const fetchEstimate = ({ id }) => {
|
||||
new Promise((resovle, reject) => {
|
||||
ApiService.get(`sales/estimates/${id}`)
|
||||
.then((response) => {
|
||||
|
||||
const { estimate } = response.data;
|
||||
dispatch({
|
||||
type: t.ESTIMATE_SET,
|
||||
payload: {
|
||||
id,
|
||||
estimate: response.data.estimate,
|
||||
estimate,
|
||||
},
|
||||
});
|
||||
resovle(response);
|
||||
@@ -95,7 +84,7 @@ export const fetchEstimate = ({ id }) => {
|
||||
export const fetchEstimatesTable = ({ query = {} }) => {
|
||||
return (dispatch, getState) =>
|
||||
new Promise((resolve, rejcet) => {
|
||||
const pageQuery = getState().sales_estimates.tableQuery;
|
||||
const pageQuery = getState().salesEstimates.tableQuery;
|
||||
dispatch({
|
||||
type: t.ESTIMATES_TABLE_LOADING,
|
||||
payload: {
|
||||
@@ -106,7 +95,6 @@ export const fetchEstimatesTable = ({ query = {} }) => {
|
||||
params: { ...pageQuery, ...query },
|
||||
})
|
||||
.then((response) => {
|
||||
// debugger;
|
||||
dispatch({
|
||||
type: t.ESTIMATES_PAGE_SET,
|
||||
payload: {
|
||||
|
||||
@@ -59,6 +59,7 @@ const reducer = createReducer(initialState, {
|
||||
},
|
||||
|
||||
[t.ESTIMATES_PAGE_SET]: (state, action) => {
|
||||
// @todo camelCase keys.
|
||||
const { customViewId, sales_estimates, pagination } = action.payload;
|
||||
|
||||
const viewId = customViewId || -1;
|
||||
|
||||
@@ -1,27 +1,33 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { pickItemsFromIds, paginationLocationQuery } from 'store/selectors';
|
||||
|
||||
const estimateTableQuery = (state) => {
|
||||
return state.sales_estimates.tableQuery;
|
||||
};
|
||||
const estimateTableQuery = (state) => state.salesEstimates.tableQuery;
|
||||
|
||||
export const getEstimatesTableQuery = createSelector(
|
||||
paginationLocationQuery,
|
||||
estimateTableQuery,
|
||||
(locationQuery, tableQuery) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableQuery,
|
||||
};
|
||||
},
|
||||
);
|
||||
const estimateByIdSelector = (state, props) =>
|
||||
state.salesEstimates.items[props.estimateId];
|
||||
|
||||
const estimatesCurrentViewSelector = (state, props) => {
|
||||
const viewId = state.salesEstimates.currentViewId;
|
||||
return state.salesEstimates.views?.[viewId];
|
||||
};
|
||||
const estimateItemsSelector = (state) => state.salesEstimates.items;
|
||||
|
||||
const estimatesPageSelector = (state, props, query) => {
|
||||
const viewId = state.sales_estimates.currentViewId;
|
||||
return state.sales_estimates.views?.[viewId]?.pages?.[query.page];
|
||||
const viewId = state.salesEstimates.currentViewId;
|
||||
return state.salesEstimates.views?.[viewId]?.pages?.[query.page];
|
||||
};
|
||||
|
||||
const estimateItemsSelector = (state) => state.sales_estimates.items;
|
||||
export const getEstimatesTableQueryFactory = () =>
|
||||
createSelector(
|
||||
paginationLocationQuery,
|
||||
estimateTableQuery,
|
||||
(locationQuery, tableQuery) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableQuery,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const getEstimateCurrentPageFactory = () =>
|
||||
createSelector(
|
||||
@@ -34,21 +40,12 @@ export const getEstimateCurrentPageFactory = () =>
|
||||
},
|
||||
);
|
||||
|
||||
const estimateByIdSelector = (state, props) => {
|
||||
return state.sales_estimates.items[props.estimateId];
|
||||
};
|
||||
|
||||
export const getEstimateByIdFactory = () =>
|
||||
createSelector(estimateByIdSelector, (estimate) => {
|
||||
return estimate;
|
||||
});
|
||||
|
||||
const estimatesPaginationSelector = (state, props) => {
|
||||
const viewId = state.sales_estimates.currentViewId;
|
||||
return state.sales_estimates.views?.[viewId];
|
||||
};
|
||||
|
||||
export const getEstimatesPaginationMetaFactory = () =>
|
||||
createSelector(estimatesPaginationSelector, (estimatePage) => {
|
||||
return estimatePage?.paginationMeta || {};
|
||||
createSelector(estimatesCurrentViewSelector, (estimateView) => {
|
||||
return estimateView?.paginationMeta || {};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user