Created
September 29, 2019 20:21
-
-
Save alexytiger/56fa78ec80e54bc10ee4bee6c727dc4d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| confirmDelivery$ = createEffect( | |
| () => | |
| this.actions$.pipe( | |
| ofType(PurchaseContractActions.confirmDelivery), | |
| withLatestFrom(this.store$.pipe(select(fromStore.getSelectedPurchaseContract))), | |
| switchMap(([payload, contract]) => { | |
| const dialogConfig = new MatDialogConfig(); | |
| dialogConfig.width = '420px'; | |
| dialogConfig.disableClose = true; | |
| dialogConfig.autoFocus = true; | |
| dialogConfig.data = { | |
| title: 'Confirm Delivery', | |
| content: `Are you sure you want to confirm that you received the purchase item ${contract.title}`, | |
| output: contract.contractAddress | |
| }; | |
| const dialogRef = this.dialog.open(ConfirmDialogComponent, dialogConfig); | |
| // * Gets an observable that is notified when the dialog is finished closing. | |
| return dialogRef.afterClosed(); | |
| }), | |
| exhaustMap(result => { | |
| if (result === undefined) { | |
| return of(SpinnerActions.hide()); | |
| } | |
| return this.purchaseSrv.confirmDelivery(result).pipe( | |
| tap(address => console.log(`Delivery confirmed successfully for the contract: ${address} `)), | |
| concatMapTo( | |
| [PurchaseContractActions.confirmDeliverySuccess(), | |
| // update ballance | |
| Web3ProviderActions.getBalance()] | |
| ), | |
| catchError((err: Error) => | |
| of(ErrorActions.errorMessage({ errorMsg: err.message }), SpinnerActions.hide(), | |
| // update ballance | |
| Web3ProviderActions.getBalance()) | |
| ) | |
| ) | |
| }) | |
| )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment