mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix Merge conflict.
This commit is contained in:
@@ -2,107 +2,131 @@ import ApiService from 'services/ApiService';
|
||||
import t from 'store/types';
|
||||
|
||||
export const fetchAccountTypes = () => {
|
||||
return (dispatch, getState) => new Promise((resolve, reject) => {
|
||||
ApiService.get('account_types').then((response) => {
|
||||
dispatch({
|
||||
type: t.ACCOUNT_TYPES_LIST_SET,
|
||||
account_types: response.data.account_types,
|
||||
});
|
||||
resolve(response);
|
||||
}).catch((error) => { reject(error); });
|
||||
});
|
||||
return (dispatch, getState) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.get('account_types')
|
||||
.then(response => {
|
||||
dispatch({
|
||||
type: t.ACCOUNT_TYPES_LIST_SET,
|
||||
account_types: response.data.account_types
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchAccountsList = ({ query } = {}) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.get('accounts', { params: query }).then((response) => {
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_PAGE_SET,
|
||||
accounts: response.data.accounts,
|
||||
customViewId: response.data.customViewId,
|
||||
});
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_ITEMS_SET,
|
||||
accounts: response.data.accounts,
|
||||
});
|
||||
resolve(response);
|
||||
}).catch((error) => { reject(error); });
|
||||
});
|
||||
return dispatch =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.get('accounts', { params: query })
|
||||
.then(response => {
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_PAGE_SET,
|
||||
accounts: response.data.accounts,
|
||||
customViewId: response.data.customViewId
|
||||
});
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_ITEMS_SET,
|
||||
accounts: response.data.accounts
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchAccountsDataTable = ({ query }) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.get('accounts', ).then((response) => {
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_DATA_TABLE,
|
||||
data: response.data,
|
||||
})
|
||||
}).catch((error) => { reject(error); })
|
||||
})
|
||||
return dispatch =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.get('accounts')
|
||||
.then(response => {
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_DATA_TABLE,
|
||||
data: response.data
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const submitAccount = ({ form }) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.post('accounts', form).then((response) => {
|
||||
dispatch({ type: t.CLEAR_ACCOUNT_FORM_ERRORS });
|
||||
resolve(response);
|
||||
}).catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
const { errors } = data;
|
||||
return dispatch =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.post('accounts', form)
|
||||
.then(response => {
|
||||
dispatch({ type: t.CLEAR_ACCOUNT_FORM_ERRORS });
|
||||
resolve(response);
|
||||
})
|
||||
.catch(error => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
const { errors } = data;
|
||||
|
||||
dispatch({ type: t.CLEAR_ACCOUNT_FORM_ERRORS });
|
||||
if (errors){
|
||||
dispatch({ type: t.ACCOUNT_FORM_ERRORS, errors });
|
||||
}
|
||||
reject(error);
|
||||
dispatch({ type: t.CLEAR_ACCOUNT_FORM_ERRORS });
|
||||
if (errors) {
|
||||
dispatch({ type: t.ACCOUNT_FORM_ERRORS, errors });
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const editAccount = ({ id, form }) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.post(`accounts/${id}`, form).then((response) => {
|
||||
dispatch({type: t.CLEAR_ACCOUNT_FORM_ERRORS});
|
||||
resolve(response);
|
||||
}).catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
const { errors } = data;
|
||||
return dispatch =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.post(`accounts/${id}`, form)
|
||||
.then(response => {
|
||||
dispatch({ type: t.CLEAR_ACCOUNT_FORM_ERRORS });
|
||||
resolve(response);
|
||||
})
|
||||
.catch(error => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
const { errors } = data;
|
||||
|
||||
dispatch({type: t.CLEAR_ACCOUNT_FORM_ERRORS});
|
||||
if (errors){
|
||||
dispatch({ type: t.ACCOUNT_FORM_ERRORS, errors });
|
||||
}
|
||||
reject(error);
|
||||
dispatch({ type: t.CLEAR_ACCOUNT_FORM_ERRORS });
|
||||
if (errors) {
|
||||
dispatch({ type: t.ACCOUNT_FORM_ERRORS, errors });
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const activeAccount = ({ id }) => {
|
||||
return (dispatch) => ApiService.post(`accounts/${id}/active`);
|
||||
return dispatch => ApiService.post(`accounts/${id}/active`);
|
||||
};
|
||||
|
||||
export const inactiveAccount = ({ id }) => {
|
||||
return (dispatch) => ApiService.post(`accounts/${id}/inactive`);
|
||||
return dispatch => ApiService.post(`accounts/${id}/inactive`);
|
||||
};
|
||||
|
||||
export const deleteAccount = ({ id }) => {
|
||||
return (dispatch) => ApiService.delete(`accounts/${id}`);
|
||||
return dispatch => ApiService.delete(`accounts/${id}`);
|
||||
};
|
||||
|
||||
export const deleteBulkAccounts = ({ ids }) => {
|
||||
|
||||
};
|
||||
export const deleteBulkAccounts = ({ ids }) => {};
|
||||
|
||||
export const fetchAccount = ({ id }) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.get(`accounts/${id}`).then((response) => {
|
||||
dispatch({
|
||||
type: t.ACCOUNT_SET,
|
||||
account: response.data.account,
|
||||
});
|
||||
resolve(response);
|
||||
}).catch((error) => { reject(error); });
|
||||
});
|
||||
}
|
||||
return dispatch =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.get(`accounts/${id}`)
|
||||
.then(response => {
|
||||
dispatch({
|
||||
type: t.ACCOUNT_SET,
|
||||
account: response.data.account
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import ApiService from "services/ApiService"
|
||||
import ApiService from 'services/ApiService';
|
||||
import t from 'store/types';
|
||||
|
||||
export const submitItem = ({ form }) => {
|
||||
return (dispatch) => ApiService.post(`items`, form);
|
||||
return dispatch => ApiService.post(`items`, form);
|
||||
};
|
||||
|
||||
export const editItem = ({ id, form }) => {
|
||||
return (dispatch) => ApiService.post(`items/${id}`, form);
|
||||
return dispatch => ApiService.post(`items/${id}`, form);
|
||||
};
|
||||
|
||||
export const fetchItems = ({ query }) => {
|
||||
@@ -28,16 +28,21 @@ export const fetchItems = ({ query }) => {
|
||||
};
|
||||
|
||||
export const fetchItem = ({ id }) => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.get(`items/${id}`).then((response) => {
|
||||
dispatch({
|
||||
type: t.ITEM_SET,
|
||||
item: response.data.item,
|
||||
});
|
||||
}).catch(error => { reject(error); });
|
||||
});
|
||||
return dispatch =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.get(`items/${id}`)
|
||||
.then(response => {
|
||||
dispatch({
|
||||
type: t.ITEM_SET,
|
||||
item: response.data.item
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteItem = ({ id }) => {
|
||||
return (dispatch) => ApiService.delete(`items/${id}`);
|
||||
};
|
||||
return dispatch => ApiService.delete(`items/${id}`);
|
||||
};
|
||||
|
||||
@@ -89,4 +89,4 @@ export default createReducer(initialState, {
|
||||
|
||||
export const getItemById = (state, id) => {
|
||||
return state.items.items[id];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -6,4 +6,4 @@ export default {
|
||||
ITEM_DELETE: 'ITEM_DELETE',
|
||||
ITEM_BULK_ACTION_ADD: 'ITEM_BULK_ACTION_ADD',
|
||||
ITEM_BULK_ACTION_REMOVE: 'ITEM_BULK_ACTION_REMOVE',
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user