/*
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, constructRecoveryUri } from "@gnu-taler/taler-util";
import {
ProviderInfo,
ProviderPaymentPaid,
ProviderPaymentStatus,
ProviderPaymentType,
WalletApiOperation,
} from "@gnu-taler/taler-wallet-core";
import {
differenceInMonths,
formatDuration,
intervalToDuration,
} from "date-fns";
import { Fragment, h, VNode } from "preact";
import { useEffect, useState } from "preact/hooks";
import { ErrorAlertView } from "../components/CurrentAlerts.js";
import { Loading } from "../components/Loading.js";
import { QR } from "../components/QR.js";
import {
BoldLight,
Centered,
CenteredBoldText,
CenteredText,
RowBorderGray,
SmallLightText,
SmallText,
WarningBox,
} from "../components/styled/index.js";
import { alertFromError } from "../context/alert.js";
import { useBackendContext } from "../context/backend.js";
import { useTranslationContext } from "../context/translation.js";
import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
import { Button } from "../mui/Button.js";
import { Pages } from "../NavigationBar.js";
interface Props {
onAddProvider: () => Promise;
}
export function ShowRecoveryInfo({
info,
onClose,
}: {
info: string;
onClose: () => Promise;
}): VNode {
const [display, setDisplay] = useState(false);
const [copied, setCopied] = useState(false);
async function copyText(): Promise {
navigator.clipboard.writeText(info);
setCopied(true);
}
useEffect(() => {
if (copied) {
setTimeout(() => {
setCopied(false);
}, 1000);
}
}, [copied]);
return (
Wallet Recovery
Do not share this QR or URI with anyone
The qr code can be scanned by another wallet to keep synchronized with
this wallet.