Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ahmed Bouhuolia
2020-11-07 14:31:13 +02:00
8 changed files with 19 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ import t from 'store/types';
const initialState = {
exchangeRates: {},
loading: false,
views: {},
tableQuery: {
page_size: 5,
page: 1,
@@ -26,17 +27,15 @@ const reducer = createReducer(initialState, {
},
[t.EXCHANGE_RATE_TABLE_LOADING]: (state, action) => {
const { loading } = action.payload;
state.loading = loading;
},
[t.ESTIMATES_PAGE_SET]: (state, action) => {
[t.EXCHANGE_RATES_PAGE_SET]: (state, action) => {
const { customViewId, exchange_rates, pagination } = action.payload;
const viewId = customViewId || -1;
const view = state.views[viewId] || {};
state.views[viewId] = {
...view,
pages: {

View File

@@ -54,10 +54,9 @@ export const fetchReceipt = ({ id }) => {
new Promise((resovle, reject) => {
ApiService.get(`sales/receipts/${id}`)
.then((response) => {
const { receipt } = response.data;
dispatch({
type: t.RECEIPT_SET,
payload: { id, receipt },
payload: { id, sale_receipt: response.data.sale_receipt },
});
resovle(response);
})

View File

@@ -18,12 +18,14 @@ const defaultReceipt = {
};
const reducer = createReducer(initialState, {
[t.RECEIPT_SET]: (state, action) => {
const { id, receipt } = action.payload;
const { id, sale_receipt } = action.payload;
const _receipt = state.items[id] || {};
state.items[id] = { ...defaultReceipt, ..._receipt, ...receipt };
state.items[id] = { ...defaultReceipt, ..._receipt, ...sale_receipt };
},
[t.RECEIPTS_ITEMS_SET]: (state, action) => {
const { sales_receipts } = action.payload;
const _receipts = {};