diff options
author | tanhengyeow <E0032242@u.nus.edu> | 2020-07-03 00:31:30 +0800 |
---|---|---|
committer | tanhengyeow <E0032242@u.nus.edu> | 2020-07-03 00:31:30 +0800 |
commit | 089b2fd5c6e402bd2606d1e69a9f8ea2c467d28a (patch) | |
tree | 512faad13621aeec4059e5145f545735a9ecf0a4 /frontend | |
parent | 340506abc60e1c3e30767b1a14e54bd6cf620f71 (diff) | |
download | libeufin-089b2fd5c6e402bd2606d1e69a9f8ea2c467d28a.tar.gz libeufin-089b2fd5c6e402bd2606d1e69a9f8ea2c467d28a.tar.bz2 libeufin-089b2fd5c6e402bd2606d1e69a9f8ea2c467d28a.zip |
Improve error handling when adding bank connections
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/src/components/bank-accounts/AddBankConnectionDrawer.tsx | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/frontend/src/components/bank-accounts/AddBankConnectionDrawer.tsx b/frontend/src/components/bank-accounts/AddBankConnectionDrawer.tsx index 57b85cca..6978192c 100644 --- 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 = () => { |