/* 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 { Amounts, HttpStatusCode, TalerError, TalerErrorCode, TranslatedString } from "@gnu-taler/taler-util"; import { Attention, Loading, LocalNotificationBanner, ShowInputErrorLabel, useLocalNotification, useTranslationContext } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; import { mutate } from "swr"; import { ErrorLoadingWithDebug } from "../../components/ErrorLoadingWithDebug.js"; import { useBankCoreApiContext } from "../../context/config.js"; import { useBackendState } from "../../hooks/backend.js"; import { useCashoutDetails, useConversionInfo } from "../../hooks/circuit.js"; import { undefinedIfEmpty } from "../../utils.js"; import { RenderAmount } from "../PaytoWireTransferForm.js"; import { assertUnreachable } from "../WithdrawalOperationPage.js"; interface Props { id: string; onCancel: () => void; } export function ShowCashoutDetails({ id, onCancel, }: Props): VNode { const { i18n, dateLocale } = useTranslationContext(); const { state } = useBackendState(); const cid = Number.parseInt(id, 10) const result = useCashoutDetails(Number.isNaN(cid) ? undefined : cid); const info = useConversionInfo(); if (Number.isNaN(cid)) { return } if (!result) { return } if (result instanceof TalerError) { return } if (result.type === "fail") { switch (result.case) { case HttpStatusCode.NotFound: return case HttpStatusCode.NotImplemented: return default: assertUnreachable(result) } } if (!info) { return } if (info instanceof TalerError) { return } if (info.type === "fail") { switch (info.case) { case HttpStatusCode.NotImplemented: { return } default: assertUnreachable(info.case) } } const { fiat_currency_specification, regional_currency_specification } = info.body return (

Cashout detail

Subject
{result.body.subject}
{result.body.creation_time.t_s !== "never" ?
Created
{format(result.body.creation_time.t_s * 1000, "dd/MM/yyyy HH:mm:ss", { locale: dateLocale })}
: undefined}
Debited
Credited

); }