mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
WIP Fix & last tasks
This commit is contained in:
@@ -8,7 +8,17 @@ export const submitCurrencies = ({ form }) => {
|
||||
};
|
||||
|
||||
export const deleteCurrency = ({ currency_code }) => {
|
||||
return (dispatch) => ApiService.delete(`currencies/${currency_code}`);
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.delete(`currencies/${currency_code}`)
|
||||
.then((response) => {
|
||||
dispatch({ type: t.CURRENCY_CODE_DELETE, currency_code });
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error.response.data.errors || []);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const editCurrency = ({ id, form }) => {
|
||||
@@ -36,12 +46,20 @@ export const editCurrency = ({ id, form }) => {
|
||||
export const fetchCurrencies = () => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.CURRENCIES_TABLE_LOADING,
|
||||
loading: true,
|
||||
});
|
||||
ApiService.get('currencies')
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.CURRENCIES_REGISTERED_SET,
|
||||
currencies: response.data.currencies,
|
||||
});
|
||||
dispatch({
|
||||
type: t.CURRENCIES_TABLE_LOADING,
|
||||
loading: false,
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -17,4 +17,12 @@ export default createReducer(initialState, {
|
||||
..._currencies,
|
||||
};
|
||||
},
|
||||
[t.CURRENCIES_TABLE_LOADING]: (state, action) => {
|
||||
state.loading = action.loading;
|
||||
},
|
||||
[t.CURRENCY_CODE_DELETE]: (state, action) => {
|
||||
if (typeof state.data[action.currency_code] !== 'undefined') {
|
||||
delete state.data[action.currency_code];
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
export default {
|
||||
CURRENCIES_REGISTERED_SET: 'CURRENCIES_REGISTERED_SET',
|
||||
CLEAR_CURRENCY_FORM_ERRORS: 'CLEAR_CURRENCY_FORM_ERRORS',
|
||||
CURRENCIES_TABLE_LOADING: 'CURRENCIES_TABLE_LOADING',
|
||||
CURRENCY_CODE_DELETE: 'CURRENCY_CODE_DELETE',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user