mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
Fix bugs.
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
|
||||
import ApiService from 'services/ApiService';
|
||||
|
||||
export const submitInvite = ({ form, token }) => {
|
||||
return (dispatch) => {
|
||||
return ApiService.post(`/invite/accept/${token}`, { ...form });
|
||||
};
|
||||
};
|
||||
|
||||
export const submitSendInvite = ({ form }) => {
|
||||
return (dispatch) => {
|
||||
return ApiService.post('invite', { form });
|
||||
};
|
||||
};
|
||||
@@ -7,7 +7,7 @@ export const submitItemCategory = ({ form }) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchItemCategories = () => {
|
||||
export const fetchItemCategories = ({ query }) => {
|
||||
return (dispatch, getState) => new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
@@ -18,7 +18,7 @@ export const fetchItemCategories = () => {
|
||||
loading: true,
|
||||
}
|
||||
});
|
||||
ApiService.get('item_categories')
|
||||
ApiService.get('item_categories', { params: { ...query } })
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.ITEMS_CATEGORY_LIST_SET,
|
||||
@@ -70,7 +70,7 @@ export const deleteItemCategory = (id) => {
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.CATEGORY_DELETE,
|
||||
id,
|
||||
payload: { id },
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
|
||||
@@ -24,8 +24,10 @@ export default createReducer(initialState, {
|
||||
},
|
||||
|
||||
[t.CATEGORY_DELETE]: (state, action) => {
|
||||
if (typeof state.categories[action.id] !== 'undefined') {
|
||||
delete state.categories[action.id];
|
||||
const { id } = action.payload;
|
||||
|
||||
if (typeof state.categories[id] !== 'undefined') {
|
||||
delete state.categories[id];
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -20,8 +20,12 @@ export default createReducer(initialState, {
|
||||
},
|
||||
|
||||
[t.CATEGORY_DELETE]: (state, action) => {
|
||||
if (typeof state.categories[action.id] !== 'undefined') {
|
||||
delete state.categories[action.id];
|
||||
const { id } = action.payload;
|
||||
const categories = { ...state.categories };
|
||||
|
||||
if (typeof categories[id] !== 'undefined') {
|
||||
delete categories[id];
|
||||
state.categories = categories;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -65,5 +65,14 @@ export const fetchItem = ({ id }) => {
|
||||
};
|
||||
|
||||
export const deleteItem = ({ id }) => {
|
||||
return dispatch => ApiService.delete(`items/${id}`);
|
||||
return dispatch => new Promise((resolve, reject) => {
|
||||
ApiService.delete(`items/${id}`)
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.ITEM_DELETE,
|
||||
payload: { id },
|
||||
});
|
||||
resolve(response);
|
||||
}).catch((error) => { reject(error); });
|
||||
});
|
||||
};
|
||||
|
||||
@@ -77,14 +77,14 @@ const itemsReducer = createReducer(initialState, {
|
||||
},
|
||||
|
||||
[t.ITEM_DELETE]: (state, action) => {
|
||||
const { itemId } = action;
|
||||
const { id } = action.payload;
|
||||
const items = { ...state.items };
|
||||
|
||||
if (state.items[itemId]) {
|
||||
const item = state.items[itemId];
|
||||
const itemPageNumber = item._page_number;
|
||||
|
||||
delete state.items[itemId];
|
||||
if (items[id]) {
|
||||
const item = items[id];
|
||||
|
||||
delete items[id];
|
||||
state.items = items;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user