From 1d4815c66c395f4fcc86c30e20f3d005e3cb9ff5 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Mon, 15 Nov 2021 11:18:58 -0300
Subject: prettier

---
 .../src/wallet/History.tsx                         | 103 ++++++++++++++-------
 1 file changed, 69 insertions(+), 34 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/wallet/History.tsx')

diff --git a/packages/taler-wallet-webextension/src/wallet/History.tsx b/packages/taler-wallet-webextension/src/wallet/History.tsx
index 8160f8574..aabe50a29 100644
--- a/packages/taler-wallet-webextension/src/wallet/History.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/History.tsx
@@ -14,7 +14,12 @@
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import { AmountString, Balance, Transaction, TransactionsResponse } from "@gnu-taler/taler-util";
+import {
+  AmountString,
+  Balance,
+  Transaction,
+  TransactionsResponse,
+} from "@gnu-taler/taler-util";
 import { format } from "date-fns";
 import { Fragment, h, JSX } from "preact";
 import { useEffect, useState } from "preact/hooks";
@@ -23,13 +28,14 @@ import { TransactionItem } from "../components/TransactionItem";
 import { useBalances } from "../hooks/useBalances";
 import * as wxApi from "../wxApi";
 
-
 export function HistoryPage(props: any): JSX.Element {
   const [transactions, setTransactions] = useState<
     TransactionsResponse | undefined
   >(undefined);
-  const balance = useBalances()
-  const balanceWithoutError = balance?.hasError ? [] : (balance?.response.balances || [])
+  const balance = useBalances();
+  const balanceWithoutError = balance?.hasError
+    ? []
+    : balance?.response.balances || [];
 
   useEffect(() => {
     const fetchData = async (): Promise<void> => {
@@ -43,45 +49,74 @@ export function HistoryPage(props: any): JSX.Element {
     return <div>Loading ...</div>;
   }
 
-  return <HistoryView balances={balanceWithoutError} list={[...transactions.transactions].reverse()} />;
+  return (
+    <HistoryView
+      balances={balanceWithoutError}
+      list={[...transactions.transactions].reverse()}
+    />
+  );
 }
 
 function amountToString(c: AmountString) {
-  const idx = c.indexOf(':')
-  return `${c.substring(idx + 1)} ${c.substring(0, idx)}`
+  const idx = c.indexOf(":");
+  return `${c.substring(idx + 1)} ${c.substring(0, idx)}`;
 }
 
-
-
-export function HistoryView({ list, balances }: { list: Transaction[], balances: Balance[] }) {
+export function HistoryView({
+  list,
+  balances,
+}: {
+  list: Transaction[];
+  balances: Balance[];
+}) {
   const byDate = list.reduce(function (rv, x) {
-    const theDate = x.timestamp.t_ms === "never" ? "never" : format(x.timestamp.t_ms, 'dd MMMM yyyy');
+    const theDate =
+      x.timestamp.t_ms === "never"
+        ? "never"
+        : format(x.timestamp.t_ms, "dd MMMM yyyy");
     (rv[theDate] = rv[theDate] || []).push(x);
     return rv;
   }, {} as { [x: string]: Transaction[] });
 
-  const multiCurrency = balances.length > 1
+  const multiCurrency = balances.length > 1;
 
-  return <WalletBox noPadding>
-    {balances.length > 0 && <header>
-      {balances.length === 1 && <div class="title">
-        Balance: <span>{amountToString(balances[0].available)}</span>
-      </div>}
-      {balances.length > 1 && <div class="title">
-        Balance: <ul style={{ margin: 0 }}>
-          {balances.map(b => <li>{b.available}</li>)}
-        </ul>
-      </div>}
-    </header>}
-    <section>
-      {Object.keys(byDate).map((d,i) => {
-        return <Fragment key={i}>
-          <DateSeparator>{d}</DateSeparator>
-          {byDate[d].map((tx, i) => (
-            <TransactionItem key={i} tx={tx} multiCurrency={multiCurrency}/>
-          ))}
-        </Fragment>
-      })}
-    </section>
-  </WalletBox>
+  return (
+    <WalletBox noPadding>
+      {balances.length > 0 && (
+        <header>
+          {balances.length === 1 && (
+            <div class="title">
+              Balance: <span>{amountToString(balances[0].available)}</span>
+            </div>
+          )}
+          {balances.length > 1 && (
+            <div class="title">
+              Balance:{" "}
+              <ul style={{ margin: 0 }}>
+                {balances.map((b) => (
+                  <li>{b.available}</li>
+                ))}
+              </ul>
+            </div>
+          )}
+        </header>
+      )}
+      <section>
+        {Object.keys(byDate).map((d, i) => {
+          return (
+            <Fragment key={i}>
+              <DateSeparator>{d}</DateSeparator>
+              {byDate[d].map((tx, i) => (
+                <TransactionItem
+                  key={i}
+                  tx={tx}
+                  multiCurrency={multiCurrency}
+                />
+              ))}
+            </Fragment>
+          );
+        })}
+      </section>
+    </WalletBox>
+  );
 }
-- 
cgit v1.2.3

