gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-wallet-webex] 02/02: render both string and JSON amo


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] 02/02: render both string and JSON amounts correctly to HTML
Date: Tue, 20 Feb 2018 09:34:07 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-webex.

commit 65228afb876d4fcec36ceabd3e6bfc1ea6f15cee
Author: Florian Dold <address@hidden>
AuthorDate: Tue Feb 20 09:33:17 2018 +0100

    render both string and JSON amounts correctly to HTML
---
 src/webex/renderHtml.tsx | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/webex/renderHtml.tsx b/src/webex/renderHtml.tsx
index 2e21932b..e4686ade 100644
--- a/src/webex/renderHtml.tsx
+++ b/src/webex/renderHtml.tsx
@@ -48,12 +48,21 @@ import * as React from "react";
  * Render amount as HTML, which non-breaking space between
  * decimal value and currency.
  */
-export function renderAmount(amount: AmountJson) {
-  const x = amount.value + amount.fraction / Amounts.fractionalBase;
-  return <span>{x}&nbsp;{amount.currency}</span>;
+export function renderAmount(amount: AmountJson | string) {
+  let a;
+  if (typeof amount === "string") {
+    a = Amounts.parse(amount);
+  } else {
+    a = amount;
+  }
+  if (!a) {
+    return <span>(invalid amount)</span>;
+  }
+  const x = a.value + a.fraction / Amounts.fractionalBase;
+  return <span>{x}&nbsp;{a.currency}</span>;
 }
 
-export const AmountDisplay = ({amount}: {amount: AmountJson}) => 
renderAmount(amount);
+export const AmountDisplay = ({amount}: {amount: AmountJson | string}) => 
renderAmount(amount);
 
 
 /**

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]