Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active February 8, 2020 20:26
Show Gist options
  • Save alexytiger/b5ee22faa5feb332a889b67a865de654 to your computer and use it in GitHub Desktop.
Save alexytiger/b5ee22faa5feb332a889b67a865de654 to your computer and use it in GitHub Desktop.
e-book
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.description}`,
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();
}),
filter(result => !!result),
exhaustMap(result => concat(
of(SpinnerActions.show()),
this.purchaseSrv.confirmDelivery(result).pipe(
tap(address => console.log(`Delivery confirmed successfully for the contract: ${address} `)),
concatMapTo(
[PurchaseContractActions.confirmDeliverySuccess(), Web3ProviderActions.getBalance()]
),
catchError((err: Error) =>
of(this.handleError(err), Web3ProviderActions.getBalance())
)
),
of(SpinnerActions.hide()),
))
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment