/* 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 */ /** * * @author Sebastian Javier Marchano (sebasjm) */ import { Amounts } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; import { format } from "date-fns"; import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { QR } from "../../../../components/exception/QR.js"; import { FormProvider } from "../../../../components/form/FormProvider.js"; import { Input } from "../../../../components/form/Input.js"; import { InputCurrency } from "../../../../components/form/InputCurrency.js"; import { InputDate } from "../../../../components/form/InputDate.js"; import { TextField } from "../../../../components/form/TextField.js"; import { SimpleModal } from "../../../../components/modal/index.js"; import { MerchantBackend } from "../../../../declaration.js"; import { useTipDetails } from "../../../../hooks/reserves.js"; import { TipInfo } from "./TipInfo.js"; type Entity = MerchantBackend.Tips.ReserveDetail; type CT = MerchantBackend.ContractTerms; interface Props { onBack: () => void; selected: Entity; id: string; } export function DetailPage({ id, selected, onBack }: Props): VNode { const { i18n } = useTranslationContext(); const didExchangeAckTransfer = Amounts.isNonZero( Amounts.parseOrThrow(selected.exchange_initial_amount), ); const link = `${selected.payto_uri}?message=${id}&amount=${selected.merchant_initial_amount}`; return (
name="creation_time" label={i18n.str`Created at`} readonly /> name="expiration_time" label={i18n.str`Valid until`} readonly /> name="merchant_initial_amount" label={i18n.str`Created balance`} readonly /> name="exchange_url" label={i18n.str`Exchange URL`} readonly > {selected.exchange_url} {didExchangeAckTransfer && ( name="exchange_initial_amount" label={i18n.str`Exchange balance`} readonly /> name="pickup_amount" label={i18n.str`Picked up`} readonly /> name="committed_amount" label={i18n.str`Committed`} readonly /> )} name="payto_uri" label={i18n.str`Account address`} readonly /> {didExchangeAckTransfer ? (

Tips

{selected.tips && selected.tips.length > 0 ? ( ) : ( )} ) : (

To complete the setup of the reserve, you must now initiate a wire transfer using the given wire transfer subject and crediting the specified amount to the indicated account of the exchange.

If your system supports RFC 8905, you can do this by opening this URI:

                
                  {link}
                
              
)}
); } function EmptyTable(): VNode { const { i18n } = useTranslationContext(); return (

No tips has been authorized from this reserve

); } interface TableProps { tips: MerchantBackend.Tips.TipStatusEntry[]; } function Table({ tips }: TableProps): VNode { const { i18n } = useTranslationContext(); return (
{tips.map((t, i) => { return ; })}
Authorized Picked up Reason Expiration
); } function TipRow({ id, entry, }: { id: string; entry: MerchantBackend.Tips.TipStatusEntry; }) { const [selected, setSelected] = useState(false); const result = useTipDetails(id); if (result.loading) { return ( ... ... ... ... ); } if (!result.ok) { return ( ... {/* authorized */} {entry.total_amount} {entry.reason} ... {/* expired */} ); } const info = result.data; function onSelect() { setSelected(true); } return ( {selected && ( setSelected(false)} > )} {info.total_authorized} {info.total_picked_up} {info.reason} {info.expiration.t_s === "never" ? "never" : format(info.expiration.t_s * 1000, "yyyy/MM/dd HH:mm:ss")} ); }