/*
This file is part of GNU Taler
(C) 2022-2024 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,
Amounts,
HttpStatusCode,
TalerError,
assertUnreachable,
} from "@gnu-taler/taler-util";
import {
Attention,
Loading,
useTranslationContext,
} from "@gnu-taler/web-util/browser";
import { VNode, h } from "preact";
import { ErrorLoadingWithDebug } from "../../components/ErrorLoadingWithDebug.js";
import { Time } from "../../components/Time.js";
import { useCashoutDetails, useConversionInfo } from "../../hooks/regional.js";
import { RouteDefinition } from "@gnu-taler/web-util/browser";
import { RenderAmount } from "../PaytoWireTransferForm.js";
interface Props {
id: string;
routeClose: RouteDefinition;
}
export function ShowCashoutDetails({ id, routeClose }: Props): VNode {
const { i18n } = useTranslationContext();
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 (
Cashout should be enable by configuration and the conversion rate
should be initialized with fee, ratio and rounding mode.
);
default:
assertUnreachable(result);
}
}
if (!info) {
return ;
}
if (info instanceof TalerError) {
return ;
}
if (info.type === "fail") {
switch (info.case) {
case HttpStatusCode.NotImplemented: {
return (
Cashout should be enable by configuration and the conversion rate
should be initialized with fee, ratio and rounding mode.
);
}
default:
assertUnreachable(info.case);
}
}
const { fiat_currency_specification, regional_currency_specification } =
info.body;
return (