mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
Fix: PaymentReceive & ExchangeRate & itemCategories
This commit is contained in:
@@ -13,6 +13,7 @@ export const fetchExchangeRates = () => {
|
||||
});
|
||||
ApiService.get('exchange_rates')
|
||||
.then((response) => {
|
||||
|
||||
dispatch({
|
||||
type: t.EXCHANGE_RATE_LIST_SET,
|
||||
exchange_rates: response.data.exchange_rates.results,
|
||||
@@ -35,20 +36,18 @@ export const fetchExchangeRates = () => {
|
||||
export const submitExchangeRate = ({ form }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.post('exchange_rates', form).then((response) => {
|
||||
resolve(response);
|
||||
}).catch((error)=>{
|
||||
const {response} = error
|
||||
const {data} = response;
|
||||
reject(data?.errors)
|
||||
})
|
||||
ApiService.post('exchange_rates', form)
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
reject(data?.errors);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// export const deleteExchangeRate = (id) => {
|
||||
// return (dispatch) => ApiService.delete(`exchange_rates/${id}`);
|
||||
// }
|
||||
|
||||
export const deleteExchangeRate = (id) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import { pickItemsFromIds, getItemById } from 'store/selectors';
|
||||
|
||||
const exchangeRateItemsSelector = state => state.exchangeRates.exchangeRates;
|
||||
const exchangeRateItemsSelector = (state) => state.exchangeRates.exchangeRates;
|
||||
const exchangeRateIdPropSelector = (state, props) => props.exchangeRateId;
|
||||
|
||||
export const getExchangeRatesList = createSelector(
|
||||
exchangeRateItemsSelector,
|
||||
(exchangeRateItems) => {
|
||||
return Object.values(exchangeRateItems);
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
export const getExchangeRateById = createSelector(
|
||||
exchangeRateItemsSelector,
|
||||
exchangeRateIdPropSelector,
|
||||
(exchangeRates, exchangeRateId) => {
|
||||
return getItemById(exchangeRates, exchangeRateId);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -8,37 +8,38 @@ export const submitItemCategory = ({ form }) => {
|
||||
};
|
||||
|
||||
export const fetchItemCategories = ({ query }) => {
|
||||
return (dispatch, getState) => new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
dispatch({
|
||||
type: t.ITEM_CATEGORIES_TABLE_LOADING,
|
||||
payload: {
|
||||
loading: true,
|
||||
}
|
||||
});
|
||||
ApiService.get('item_categories', { params: { ...query } })
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.ITEMS_CATEGORY_LIST_SET,
|
||||
categories: response.data.categories,
|
||||
});
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
dispatch({
|
||||
type: t.ITEM_CATEGORIES_TABLE_LOADING,
|
||||
payload: {
|
||||
loading: false,
|
||||
}
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
return (dispatch, getState) =>
|
||||
new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
});
|
||||
dispatch({
|
||||
type: t.ITEM_CATEGORIES_TABLE_LOADING,
|
||||
payload: {
|
||||
loading: true,
|
||||
},
|
||||
});
|
||||
ApiService.get('item_categories', { params: { ...query } })
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.ITEMS_CATEGORY_LIST_SET,
|
||||
categories: response.data.categories,
|
||||
});
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
dispatch({
|
||||
type: t.ITEM_CATEGORIES_TABLE_LOADING,
|
||||
payload: {
|
||||
loading: false,
|
||||
},
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const editItemCategory = (id, form) => {
|
||||
@@ -46,19 +47,13 @@ export const editItemCategory = (id, form) => {
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.post(`item_categories/${id}`, form)
|
||||
.then((response) => {
|
||||
dispatch({ type: t.CLEAR_CATEGORY_FORM_ERRORS });
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
const { errors } = data;
|
||||
|
||||
dispatch({ type: t.CLEAR_CATEGORY_FORM_ERRORS });
|
||||
if (errors) {
|
||||
dispatch({ type: t.CLEAR_CATEGORY_FORM_ERRORS, errors });
|
||||
}
|
||||
reject(error);
|
||||
reject(data?.errors);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -81,15 +76,18 @@ export const deleteItemCategory = (id) => {
|
||||
};
|
||||
|
||||
export const deleteBulkItemCategories = ({ ids }) => {
|
||||
return dispatch => new Promise((resolve, reject) => {
|
||||
ApiService.delete(`item_categories/bulk`, { params: { ids }}).then((response) => {
|
||||
dispatch({
|
||||
type: t.ITEM_CATEGORIES_BULK_DELETE,
|
||||
payload: { ids }
|
||||
});
|
||||
resolve(response);
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.delete(`item_categories/bulk`, { params: { ids } })
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.ITEM_CATEGORIES_BULK_DELETE,
|
||||
payload: { ids },
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user