fix: conflict merge.

This commit is contained in:
Ahmed Bouhuolia
2020-10-25 18:34:07 +02:00
parent 426f9fcf55
commit fb7686bfdd
18 changed files with 283 additions and 66 deletions

View File

@@ -19,21 +19,21 @@ export const fetchBillsTable = ({ query = {} }) => {
dispatch({
type: t.BILLS_PAGE_SET,
payload: {
bills: response.data.bills.results,
pagination: response.data.bills.pagination,
bills: response.data.bills,
pagination: response.data.pagination,
customViewId: response.data.customViewId || -1,
},
});
dispatch({
type: t.BILLS_ITEMS_SET,
payload: {
bills: response.data.bills.results,
bills: response.data.bills,
},
});
dispatch({
type: t.BILLS_PAGINATION_SET,
payload: {
pagination: response.data.bills.pagination,
pagination: response.data.pagination,
customViewId: response.data.customViewId || -1,
},
});
@@ -66,7 +66,19 @@ export const deleteBill = ({ id }) => {
};
export const submitBill = ({ form }) => {
return (dispatch) => ApiService.post('purchases/bills', form);
return (dispatch) =>
new Promise((resolve, reject) => {
ApiService.post('purchases/bills', form)
.then((response) => {
resolve(response);
})
.catch((error) => {
const { response } = error;
const { data } = response;
reject(data?.errors);
});
});
};
export const fetchBill = ({ id }) => {
@@ -91,5 +103,17 @@ export const fetchBill = ({ id }) => {
};
export const editBill = (id, form) => {
return (dispatch) => ApiService.post(`purchases/bills/${id}`, form);
return (dispatch) =>
new Promise((resolve, reject) => {
ApiService.post(`purchases/bills/${id}`, form)
.then((response) => {
resolve(response);
})
.catch((error) => {
const { response } = error;
const { data } = response;
reject(data?.errors);
});
});
};

View File

@@ -12,6 +12,7 @@ const initialState = {
page_size: 5,
page: 1,
},
nextBillNumberChanged: false,
};
const defaultBill = {
@@ -98,6 +99,11 @@ const reducer = createReducer(initialState, {
},
};
},
[t.BILL_NUMBER_CHANGED]: (state, action) => {
const { isChanged } = action.payload;
state.nextBillNumberChanged = isChanged;
},
});
export default createTableQueryReducers('bills', reducer);

View File

@@ -9,4 +9,5 @@ export default {
BILLS_PAGINATION_SET: 'BILLS_PAGINATION_SET',
BILLS_PAGE_SET: 'BILLS_PAGE_SET',
BILLS_ITEMS_SET: 'BILLS_ITEMS_SET',
BILL_NUMBER_CHANGED: 'BILL_NUMBER_CHANGED',
};

View File

@@ -17,7 +17,7 @@ export const fetchVendorsTable = ({ query }) => {
payload: {
vendors: response.data.vendors,
pagination: response.data.pagination,
customViewId: response.data.customViewId,
customViewId: response.data.customViewId || -1,
},
});
dispatch({