This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PON-251: Update Existing Error Handling (#294)
* feat: update order history error flows * refactor: remove unused AsyncActionType, favour saga routines over this * fix: add sr message to loading, fix order history loading * test: add more tests for coverage
- Loading branch information
1 parent
74cc3da
commit c2039c6
Showing
17 changed files
with
522 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/order-history/__snapshots__/OrderHistoryPage.test.jsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,4 @@ | ||
import { AsyncActionType } from '../utils'; | ||
import { createRoutine } from 'redux-saga-routines'; | ||
|
||
export const FETCH_ORDERS = new AsyncActionType( | ||
'ORDER_HISTORY', | ||
'FETCH_ORDERS', | ||
); | ||
|
||
// FETCH ORDERS ACTIONS | ||
|
||
export const fetchOrders = (pageToFetch) => ({ | ||
type: FETCH_ORDERS.BASE, | ||
payload: { pageToFetch }, | ||
}); | ||
|
||
export const fetchOrdersBegin = () => ({ | ||
type: FETCH_ORDERS.BEGIN, | ||
}); | ||
|
||
export const fetchOrdersSuccess = result => ({ | ||
type: FETCH_ORDERS.SUCCESS, | ||
payload: result, | ||
}); | ||
|
||
export const fetchOrdersReset = () => ({ | ||
type: FETCH_ORDERS.RESET, | ||
}); | ||
// eslint-disable-next-line import/prefer-default-export | ||
export const fetchOrders = createRoutine('FETCH_Orders'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,12 @@ | ||
import { call, put, takeEvery } from 'redux-saga/effects'; | ||
import { takeEvery } from 'redux-saga/effects'; | ||
|
||
// Actions | ||
import { | ||
FETCH_ORDERS, | ||
fetchOrdersBegin, | ||
fetchOrdersSuccess, | ||
fetchOrdersReset, | ||
} from './actions'; | ||
import { createFetchHandler } from '../utils'; | ||
|
||
// Services | ||
import * as OrdersApiService from './service'; | ||
import { fetchOrders } from './actions'; | ||
import { getOrders } from './service'; | ||
|
||
export function* handleFetchOrders(action) { | ||
const { pageToFetch } = action.payload; | ||
yield put(fetchOrdersBegin()); | ||
const result = yield call(OrdersApiService.getOrders, pageToFetch); | ||
yield put(fetchOrdersSuccess(result)); | ||
yield put(fetchOrdersReset()); | ||
} | ||
const handleFetchOrders = createFetchHandler(fetchOrders, getOrders); | ||
|
||
export default function* orderHistorySaga() { | ||
yield takeEvery(FETCH_ORDERS.BASE, handleFetchOrders); | ||
yield takeEvery(fetchOrders.TRIGGER, handleFetchOrders); | ||
} |
Oops, something went wrong.