libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 089b2fd5c6e402bd2606d1e69a9f8ea2c467d28a
parent 340506abc60e1c3e30767b1a14e54bd6cf620f71
Author: tanhengyeow <E0032242@u.nus.edu>
Date:   Fri,  3 Jul 2020 00:31:30 +0800

Improve error handling when adding bank connections

Diffstat:
Mfrontend/src/components/bank-accounts/AddBankConnectionDrawer.tsx | 42+++++++++++++++++++++++++++++++-----------
1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/frontend/src/components/bank-accounts/AddBankConnectionDrawer.tsx b/frontend/src/components/bank-accounts/AddBankConnectionDrawer.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { Button, Drawer, Input, Form, Steps } from 'antd'; +import { message, Button, Drawer, Input, Form, Steps } from 'antd'; const { Step } = Steps; const layout = { @@ -20,6 +20,10 @@ const AddBankConnectionDrawer = (props) => { const steps = [{ title: 'Fill up details' }, { title: 'Print document' }]; + const showError = (err) => { + message.error(String(err)); + }; + const createBankConnection = async () => { const authHeader = await window.localStorage.getItem('authHeader'); await fetch(`/bank-connections`, { @@ -109,17 +113,33 @@ const AddBankConnectionDrawer = (props) => { }; const next = async () => { - await createBankConnection(); - await connectBankConnection(); - await fetchKeyLetter(); - await updateBankAccounts(); + let isError = true; + await createBankConnection() + .then(async () => { + await connectBankConnection() + .then(async () => { + await fetchKeyLetter() + .then(async () => { + await updateBankAccounts() + .then(() => { + isError = false; + }) + .catch((err) => showError(err)); + }) + .catch((err) => showError(err)); + }) + .catch((err) => showError(err)); + }) + .catch((err) => showError(err)); - setServerURL(''); - setHostID(''); - setPartnerID(''); - setUserID(''); - setSystemID(''); - setCurrentStep(currentStep + 1); + if (!isError) { + setServerURL(''); + setHostID(''); + setPartnerID(''); + setUserID(''); + setSystemID(''); + setCurrentStep(currentStep + 1); + } }; const closeDrawer = () => {