/* This file is part of GNU Taler (C) 2022 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 */ import { AbsoluteTime, ExchangeListItem, TalerProtocolTimestamp, } from "@gnu-taler/taler-util"; import { styled } from "@linaria/react"; import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { Loading } from "../components/Loading.js"; import { LoadingError } from "../components/LoadingError.js"; import { SelectList } from "../components/SelectList.js"; import { Input, LinkPrimary } from "../components/styled/index.js"; import { Time } from "../components/Time.js"; import { useTranslationContext } from "../context/translation.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { Button } from "../mui/Button.js"; import * as wxApi from "../wxApi.js"; const Container = styled.div` display: flex; flex-direction: column; & > * { margin-bottom: 20px; } `; interface Props { initialValue?: number; exchanges: ExchangeListItem[]; onSelected: (exchange: string) => void; } const ButtonGroup = styled.div` & > button { margin-left: 8px; margin-right: 8px; } `; export function ExchangeSelection(): VNode { const hook = useAsyncAsHook(wxApi.listExchanges); const { i18n } = useTranslationContext(); if (!hook) { return ; } if (hook.hasError) { return ( Could not load list of exchange} /> ); } return ( alert(`ok, selected: ${exchange}`)} /> ); } export function ExchangeSelectionView({ initialValue, exchanges, onSelected, }: Props): VNode { const list: Record = {}; exchanges.forEach((e, i) => (list[String(i)] = e.exchangeBaseUrl)); const [value, setValue] = useState(String(initialValue || 0)); const { i18n } = useTranslationContext(); if (!exchanges.length) { return
no exchanges for listing, please add one
; } const current = exchanges[Number(value)]; const hasChange = value !== current.exchangeBaseUrl; function nearestTimestamp( first: TalerProtocolTimestamp, second: TalerProtocolTimestamp, ): TalerProtocolTimestamp { const f = AbsoluteTime.fromTimestamp(first); const s = AbsoluteTime.fromTimestamp(second); const a = AbsoluteTime.min(f, s); return AbsoluteTime.toTimestamp(a); } let nextFeeUpdate = TalerProtocolTimestamp.never(); nextFeeUpdate = Object.values(current.wireInfo.feesForType).reduce( (prev, cur) => { return cur.reduce((p, c) => nearestTimestamp(p, c.endStamp), prev); }, nextFeeUpdate, ); nextFeeUpdate = current.denominations.reduce((prev, cur) => { return [ cur.stampExpireWithdraw, cur.stampExpireLegal, cur.stampExpireDeposit, ].reduce(nearestTimestamp, prev); }, nextFeeUpdate); return (

Service fee description

Known exchanges} list={list} name="lang" value={value} onChange={(v) => setValue(v)} />

{hasChange ? ( ) : ( )}
Auditors
{current.auditors.map((a) => {
{a.auditor_url}
; })}
currency {current.currency}
next fee update {
Denomination operations Current fee
deposit (i)
* 10 0.1
* 5 0.05
* 1 0.01
Wallet operations Current fee
history(i) 0.1
kyc (i) 0.1
account (i) 0.1
purse (i) 0.1
wire SEPA (i) 0.1
closing SEPA(i) 0.1
wad SEPA (i) 0.1
Privacy policy Terms of service
); }