From 1d4815c66c395f4fcc86c30e20f3d005e3cb9ff5 Mon Sep 17 00:00:00 2001 From: Sebastian 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 */ -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 => { @@ -43,45 +49,74 @@ export function HistoryPage(props: any): JSX.Element { return
Loading ...
; } - return ; + return ( + + ); } 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 - {balances.length > 0 &&
- {balances.length === 1 &&
- Balance: {amountToString(balances[0].available)} -
} - {balances.length > 1 &&
- Balance:
    - {balances.map(b =>
  • {b.available}
  • )} -
-
} -
} -
- {Object.keys(byDate).map((d,i) => { - return - {d} - {byDate[d].map((tx, i) => ( - - ))} - - })} -
-
+ return ( + + {balances.length > 0 && ( +
+ {balances.length === 1 && ( +
+ Balance: {amountToString(balances[0].available)} +
+ )} + {balances.length > 1 && ( +
+ Balance:{" "} +
    + {balances.map((b) => ( +
  • {b.available}
  • + ))} +
+
+ )} +
+ )} +
+ {Object.keys(byDate).map((d, i) => { + return ( + + {d} + {byDate[d].map((tx, i) => ( + + ))} + + ); + })} +
+
+ ); } -- cgit v1.2.3