diff --git a/src/webex/notify.ts b/src/webex/notify.ts index da4657a96..5e024d619 100644 --- a/src/webex/notify.ts +++ b/src/webex/notify.ts @@ -120,6 +120,7 @@ async function handlePaymentResponse(maybeFoundResponse: QueryPaymentResult) { // Gives the user the option to retry / abort and refresh wxApi.logAndDisplayError({ name: "pay-post-failed", + contractTerms: walletResp.contractTerms, message: e.message, response: e.response, }); diff --git a/src/webex/pages/confirm-create-reserve.tsx b/src/webex/pages/confirm-create-reserve.tsx index 4e3b6748f..f957364c4 100644 --- a/src/webex/pages/confirm-create-reserve.tsx +++ b/src/webex/pages/confirm-create-reserve.tsx @@ -41,7 +41,7 @@ import { getReserveCreationInfo, } from "../wxApi"; -import {renderAmount} from "../renderHtml"; +import {Collapsible, renderAmount} from "../renderHtml"; import * as React from "react"; import * as ReactDOM from "react-dom"; @@ -80,40 +80,6 @@ class EventTrigger { } -interface CollapsibleState { - collapsed: boolean; -} - -interface CollapsibleProps { - initiallyCollapsed: boolean; - title: string; -} - -class Collapsible extends React.Component { - constructor(props: CollapsibleProps) { - super(props); - this.state = { collapsed: props.initiallyCollapsed }; - } - render() { - const doOpen = (e: any) => { - this.setState({collapsed: false}); - e.preventDefault(); - }; - const doClose = (e: any) => { - this.setState({collapsed: true}); - e.preventDefault(); - }; - if (this.state.collapsed) { - return

{this.props.title}

; - } - return ( -
-

{this.props.title}

- {this.props.children} -
- ); - } -} function renderAuditorDetails(rci: ReserveCreationInfo|null) { console.log("rci", rci); diff --git a/src/webex/pages/error.tsx b/src/webex/pages/error.tsx index 3f3940d72..2edef5e5b 100644 --- a/src/webex/pages/error.tsx +++ b/src/webex/pages/error.tsx @@ -29,6 +29,8 @@ import URI = require("urijs"); import * as wxApi from "../wxApi"; +import { Collapsible } from "../renderHtml"; + interface ErrorProps { report: any; } @@ -38,7 +40,7 @@ class ErrorView extends React.Component { const report = this.props.report; if (!report) { return ( -
+

Error Report Not Found

This page is supposed to display an error reported by the GNU Taler wallet, but the corresponding error report can't be found.

@@ -46,15 +48,47 @@ class ErrorView extends React.Component {
); } - switch (report.name) { - default: + try { + switch (report.name) { + case "pay-post-failed": { + const summary = report.contractTerms.summary || report.contractTerms.order_id; + return ( +
+

Failed to send payment

+

Failed to send payment for {summary} to merchant {report.contractTerms.merchant.name}.

+

You can retry the payment. If this problem persists, + please contact the mechant with the error details below.

+ +
+                  {JSON.stringify(report, null, " ")}
+                
+
+
+ ); + } + default: + return ( +
+

Unknown Error

+ The GNU Taler wallet reported an unknown error. Here are the details: +
+                {JSON.stringify(report, null, " ")}
+              
+
+ ); + } + } catch (e) { return ( -
-

Unknown Error

- The GNU Taler wallet reported an unknown error. Here are the details: +
+

Error

+ The GNU Taler wallet reported an error. Here are the details:
               {JSON.stringify(report, null, " ")}
             
+ A detailed error report could not be generated: +
+              {e.toString()}
+            
); } diff --git a/src/webex/renderHtml.tsx b/src/webex/renderHtml.tsx index fe964e68a..2a5b50533 100644 --- a/src/webex/renderHtml.tsx +++ b/src/webex/renderHtml.tsx @@ -91,3 +91,40 @@ export function abbrev(s: string, n: number = 5) { ); } + + + +interface CollapsibleState { + collapsed: boolean; +} + +interface CollapsibleProps { + initiallyCollapsed: boolean; + title: string; +} + +export class Collapsible extends React.Component { + constructor(props: CollapsibleProps) { + super(props); + this.state = { collapsed: props.initiallyCollapsed }; + } + render() { + const doOpen = (e: any) => { + this.setState({collapsed: false}); + e.preventDefault(); + }; + const doClose = (e: any) => { + this.setState({collapsed: true}); + e.preventDefault(); + }; + if (this.state.collapsed) { + return

{this.props.title}

; + } + return ( +
+

{this.props.title}

+ {this.props.children} +
+ ); + } +}