mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
Merge remote-tracking branch 'origin/customers'
This commit is contained in:
@@ -68,6 +68,7 @@ export const fetchCustomers = ({ query }) => {
|
||||
type: t.CUSTOMER_SET,
|
||||
customers: response.data.customers.results,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: t.CUSTOMERS_PAGE_SET,
|
||||
customers: response.data.customers.results,
|
||||
@@ -91,3 +92,18 @@ export const fetchCustomers = ({ query }) => {
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteCustomer = ({ id }) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.delete(`customers/${id}`)
|
||||
.then((response) => {
|
||||
dispatch({ type: t.CUSTOMER_DELETE, id });
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error.response.data.errors || []);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -36,10 +36,14 @@ const customersReducer = createReducer(initialState, {
|
||||
delete state.items[action.id];
|
||||
}
|
||||
},
|
||||
[t.CUSTOMERS_TABLE_LOADING]: (state, action) => {
|
||||
const { loading } = action.payload;
|
||||
state.loading = !!loading;
|
||||
},
|
||||
});
|
||||
|
||||
export default createTableQueryReducers('customers', customersReducer);
|
||||
|
||||
export const getCustomerById = (state, id) => {
|
||||
return state.customers[id];
|
||||
return state.customers.items[id];
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { pickItemsFromIds } from 'store/selectors';
|
||||
|
||||
export const getCustomersItems = (state, viewId) => {
|
||||
|
||||
const customersView = state.customers.views[viewId || -1];
|
||||
const customersItems = state.customers.items;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user