import { h, VNode } from "preact"; import { useBusinessAccounts } from "../../hooks/circuit.js"; import { handleNotOkResult } from "../HomePage.js"; import { AccountAction } from "./Home.js"; import { Amounts } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; interface Props { onAction: (type: AccountAction, account: string) => void; account: string | undefined; onRegister: () => void; onCreateAccount: () => void; } export function AccountList({ account, onAction, onCreateAccount, onRegister }: Props): VNode { const result = useBusinessAccounts({ account }); const { i18n } = useTranslationContext(); if (result.loading) return
; if (!result.ok) { return handleNotOkResult(i18n, onRegister)(result); } const { customers } = result.data; return

Accounts

A list of all business account in the bank.

{!customers.length ? (
) : ( {customers.map((item, idx) => { const balance = !item.balance ? undefined : Amounts.parse(item.balance.amount); const balanceIsDebit = item.balance && item.balance.credit_debit_indicator == "debit"; return })}
{i18n.str`Username`} {i18n.str`Name`} {i18n.str`Balance`} {i18n.str`Actions`}
{ e.preventDefault(); onAction("show-details", item.username) }} > {item.username} {item.name} {!balance ? ( i18n.str`unknown` ) : ( {balanceIsDebit ? - : null} {`${Amounts.stringifyValue( balance, )}`}   {`${balance.currency}`} )} { e.preventDefault(); onAction("update-password", item.username) }} > change password
{ e.preventDefault(); onAction("show-cashout", item.username) }} > cashouts
{ e.preventDefault(); onAction("remove-account", item.username) }} > remove
)}
}