mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
WIP / Feature & Fix Expense /Customer
This commit is contained in:
@@ -107,3 +107,19 @@ export const deleteCustomer = ({ id }) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteBulkCustomers = ({ ids }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.delete('customers', { params: { ids } })
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.CUSTOMERS_BULK_DELETE,
|
||||
payload: { ids },
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error.response.data.errors || []);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -40,6 +40,17 @@ const customersReducer = createReducer(initialState, {
|
||||
const { loading } = action.payload;
|
||||
state.loading = !!loading;
|
||||
},
|
||||
[t.CUSTOMERS_BULK_DELETE]: (state, action) => {
|
||||
const { ids } = action.payload;
|
||||
const items = { ...state.items };
|
||||
|
||||
ids.forEach((id) => {
|
||||
if (typeof items[id] !== 'undefined') {
|
||||
delete items[id];
|
||||
}
|
||||
});
|
||||
state.items = items;
|
||||
},
|
||||
});
|
||||
|
||||
export default createTableQueryReducers('customers', customersReducer);
|
||||
|
||||
@@ -4,5 +4,6 @@ export default {
|
||||
CUSTOMERS_PAGE_SET: 'CUSTOMERS_PAGE_SET',
|
||||
CUSTOMERS_TABLE_LOADING: 'CUSTOMERS_TABLE_LOADING',
|
||||
CUSTOMERS_TABLE_QUERIES_ADD: 'CUSTOMERS_TABLE_QUERIES_ADD',
|
||||
CUSTOMER_DELETE:'CUSTOMER_DELETE'
|
||||
CUSTOMER_DELETE:'CUSTOMER_DELETE',
|
||||
CUSTOMERS_BULK_DELETE:'CUSTOMERS_BULK_DELETE'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user