From c8c03e381e252dc3a73a2c35bb1cd2ee24eeaabb Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Tue, 23 Jan 2018 17:05:58 +0100
Subject: better types

---
 src/webex/pages/confirm-contract.tsx | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

(limited to 'src/webex/pages/confirm-contract.tsx')

diff --git a/src/webex/pages/confirm-contract.tsx b/src/webex/pages/confirm-contract.tsx
index 2ec131052..7fe6b9600 100644
--- a/src/webex/pages/confirm-contract.tsx
+++ b/src/webex/pages/confirm-contract.tsx
@@ -49,7 +49,7 @@ interface DetailState {
 interface DetailProps {
   contractTerms: ContractTerms;
   collapsed: boolean;
-  exchanges: null|ExchangeRecord[];
+  exchanges: ExchangeRecord[] | undefined;
 }
 
 
@@ -110,11 +110,11 @@ interface ContractPromptProps {
 
 interface ContractPromptState {
   proposalId: number | undefined;
-  proposal: ProposalDownloadRecord | null;
+  proposal: ProposalDownloadRecord | undefined;
   error: string |  null;
   payDisabled: boolean;
   alreadyPaid: boolean;
-  exchanges: null|ExchangeRecord[];
+  exchanges: ExchangeRecord[] | undefined;
   /**
    * Don't request updates to proposal state while
    * this is set to true, to avoid UI flickering
@@ -123,6 +123,7 @@ interface ContractPromptState {
   holdCheck: boolean;
   payStatus?: CheckPayResult;
   replaying: boolean;
+  payInProgress: boolean;
 }
 
 class ContractPrompt extends React.Component<ContractPromptProps, ContractPromptState> {
@@ -131,10 +132,11 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
     this.state = {
       alreadyPaid: false,
       error: null,
-      exchanges: null,
+      exchanges: undefined,
       holdCheck: false,
       payDisabled: true,
-      proposal: null,
+      payInProgress: false,
+      proposal: undefined,
       proposalId: props.proposalId,
       replaying: false,
     };
@@ -231,7 +233,13 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
       return;
     }
     console.log("confirmPay with", proposalId, "and", this.props.sessionId);
-    const payResult = await wxApi.confirmPay(proposalId, this.props.sessionId);
+    let payResult;
+    try {
+      payResult = await wxApi.confirmPay(proposalId, this.props.sessionId);
+    } catch (e) {
+
+      return;
+    }
     console.log("payResult", payResult);
     document.location.href = payResult.nextUrl;
     this.setState({ holdCheck: true });
-- 
cgit v1.2.3

