diff options
author | Nic Eigel <nic@eigel.ch> | 2024-06-24 01:50:38 +0200 |
---|---|---|
committer | Nic Eigel <nic@eigel.ch> | 2024-06-24 01:50:38 +0200 |
commit | 0b90a34e7c7c5d9bcca9a2ebe74df9fdfafc6577 (patch) | |
tree | 6a1818c24f8fcad09d1756d96e171d32a1f9c0f7 /packages/auditor-backoffice-ui/src/paths/finance/ListPage.tsx | |
parent | bf94287904c08f2c62acbb5b52c2cc0d1fcb964b (diff) | |
download | wallet-core-0b90a34e7c7c5d9bcca9a2ebe74df9fdfafc6577.tar.xz |
real-time-auditor
Diffstat (limited to 'packages/auditor-backoffice-ui/src/paths/finance/ListPage.tsx')
-rw-r--r-- | packages/auditor-backoffice-ui/src/paths/finance/ListPage.tsx | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/packages/auditor-backoffice-ui/src/paths/finance/ListPage.tsx b/packages/auditor-backoffice-ui/src/paths/finance/ListPage.tsx new file mode 100644 index 000000000..88ca6bcfd --- /dev/null +++ b/packages/auditor-backoffice-ui/src/paths/finance/ListPage.tsx @@ -0,0 +1,214 @@ +/* + This file is part of GNU Taler + (C) 2021-2023 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** + * + * @author Nic Eigel + * @author Sebastian Javier Marchano (sebasjm) + */ + +import { useTranslationContext } from "@gnu-taler/web-util/browser"; +import { h, VNode, Fragment } from "preact"; + +export function ListPage(data: any): VNode { + const { i18n } = useTranslationContext(); + + let balances = data.data.data[0][4].data.balances; + let coinBalances = [ + "Total recoup loss", + "Coin refund fee revenue", + "Coin deposit fee revenue", + "Coin melt fee revenue", + "Coin irregular loss", + "Coins reported emergency risk by amount", + "Coins emergencies loss by count", + "Coins emergencies loss", + "Coins total arithmetic delta minus", + "Coins total arithmetic delta plus", + "Total escrowed", + "Total refresh hanging", + ]; + let reserveBalances = [ + "Total balance summary delta minus", + "Total balance reserve not closed", + "Reserves total arithmetic delta minus", + "Reserves total arithmetic delta plus", + "Reserves total bad signature loss", + "Reserves history fee revenue", + "Reserves open fee revenue", + ]; + let i = 0; + + return ( + <Fragment> + <div class="columns"> + <div class="column is-half"> + <div class="columns"> + <div class="column"> + <div class="card"> + <div class="card-content"> + <table class="table is-striped is-fullwidth is-dark"> + <tbody> + <tr> + <th>Finding</th> + <td class="has-text-right"><b>Count</b></td> + <td class="has-text-right"><b>Gain/Loss</b></td> + </tr> + { + data["data"]["data"][0].map((x: any) => { + const key = Object.keys(x.data)[0]; + let value = Object.values(x.data)[0]; + const paramName = key[0].toUpperCase() + key.split("_").join(" ").split("-").join(" ").slice(1, key.length); + if (key == "balances") { + //TODO fix + let gains = 0; + if (value == null) + value = 0; + else + value = Object.keys(value).length; + + return ( + <tr class="is-link"> + <td>{paramName}</td> + <td class="has-text-right"><p + class={value == 0 ? "text-success" : "text-danger"}>{String(value)}</p></td> + <td class="has-text-right"><p + class={gains == 0 ? "text-success" : "text-danger"}>{String(gains)}</p></td> + </tr> + ); + } else { + <tr class="is-link"> + <td>{paramName}</td> + <td class="has-text-right"><p + class={value == 0 ? "text-success" : "text-danger"}>{String(value)}</p></td> + <td class="has-text-right"><p>{ + //TODO + }</p></td> + </tr>; + } + }) + } + </tbody> + </table> + </div> + </div> + <div class="card"> + <div class="card-content"> + <table class="table is-striped is-fullwidth is-dark"> + <tbody> + <tr> + <th>Summary</th> + <td class="has-text-right"><b>Value</b></td> + </tr> + <tr> + <td>Total gain/loss</td> + <td class="has-text-right">{ + //TODO fix + }</td> + </tr> + <tr> + <td>Pending gain/loss</td> + <td class="has-text-right">{ + //TODO fix + }</td> + </tr> + <tr> + <td>Transaction count</td> + <td class="has-text-right">{ + //TODO fix + }</td> + </tr> + <tr> + <td>Transactions pending</td> + <td class="has-text-right">{ + //TODO fix + }</td> + </tr> + </tbody> + </table> + </div> + </div> + </div> + </div> + </div> + <div class="column is-half"> + <div class="card"> + <div class="card-content"> + <p class="has-text-weight-bold">Helper coin</p> + <table class="table is-striped is-fullwidth is-dark"> + <tbody> + <tr> + <th>Balance</th> + <td><b>Value</b></td> + </tr> + { + balances.map((x: any) => { + let key = x.balance_key; + let balanceName = key[0].toUpperCase() + key.split("_").join(" ").split("-").join(" ").slice(1, key.length); + + if(coinBalances.includes(balanceName)) + { + let value = balances[i].balance_value.replace(":", " "); + i=i+1; + return ( + <tr class="is-link"> + <td>{balanceName}</td> + <td><p>{value}</p></td> + </tr> + ); + } else { + return null; + } + }) + } + </tbody> + </table> + <p class="has-text-weight-bold">Helper reserve</p> + <table class="table is-striped is-fullwidth is-dark"> + <tbody> + <tr> + <th>Balance</th> + <td><b>Value</b></td> + </tr> + { + balances.map((x: any) => { + let key = x.balance_key; + let balanceName = key[0].toUpperCase() + key.split("_").join(" ").split("-").join(" ").slice(1, key.length); + + if(reserveBalances.includes(balanceName)) + { + let value = balances[i].balance_value.replace(":", " "); + i = i+1; + return ( + <tr class="is-link"> + <td>{balanceName}</td> + <td><p>{value}</p></td> + </tr> + ); + } else { + return null; + } + }) + } + </tbody> + </table> + </div> + </div> + </div> + </div> + </Fragment> + ); +} |