2019-08-29 23:12:55 +02:00
|
|
|
/*
|
|
|
|
This file is part of TALER
|
|
|
|
(C) 2015-2016 GNUnet e.V.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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
|
|
|
|
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Page shown to the user to confirm creation
|
|
|
|
* of a reserve, usually requested by the bank.
|
|
|
|
*
|
2022-02-23 19:18:37 +01:00
|
|
|
* @author sebasjm
|
2019-08-29 23:12:55 +02:00
|
|
|
*/
|
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
import { AmountJson, Amounts } from "@gnu-taler/taler-util";
|
|
|
|
import { TalerError } from "@gnu-taler/taler-wallet-core";
|
2021-11-22 21:34:27 +01:00
|
|
|
import { Fragment, h, VNode } from "preact";
|
2022-04-11 16:36:32 +02:00
|
|
|
import { useState } from "preact/hooks";
|
|
|
|
import { Amount } from "../components/Amount.js";
|
|
|
|
import { ErrorTalerOperation } from "../components/ErrorTalerOperation.js";
|
2022-03-29 04:41:07 +02:00
|
|
|
import { Loading } from "../components/Loading.js";
|
|
|
|
import { LoadingError } from "../components/LoadingError.js";
|
|
|
|
import { LogoHeader } from "../components/LogoHeader.js";
|
|
|
|
import { Part } from "../components/Part.js";
|
|
|
|
import { SelectList } from "../components/SelectList.js";
|
2021-11-15 15:18:58 +01:00
|
|
|
import {
|
|
|
|
ButtonSuccess,
|
|
|
|
ButtonWarning,
|
|
|
|
LinkSuccess,
|
2022-03-28 19:03:59 +02:00
|
|
|
SubTitle,
|
2021-11-15 15:18:58 +01:00
|
|
|
WalletAction,
|
2022-03-29 04:41:07 +02:00
|
|
|
} from "../components/styled/index.js";
|
2022-04-11 16:36:32 +02:00
|
|
|
import { useTranslationContext } from "../context/translation.js";
|
|
|
|
import { HookError, useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
|
|
|
|
import { buildTermsOfServiceState } from "../utils/index.js";
|
2022-01-04 21:06:17 +01:00
|
|
|
import {
|
2022-04-11 16:36:32 +02:00
|
|
|
ButtonHandler,
|
|
|
|
SelectFieldHandler,
|
|
|
|
} from "../wallet/CreateManualWithdraw.js";
|
2022-03-29 04:41:07 +02:00
|
|
|
import * as wxApi from "../wxApi.js";
|
2022-04-11 16:36:32 +02:00
|
|
|
import {
|
|
|
|
Props as TermsOfServiceSectionProps,
|
|
|
|
TermsOfServiceSection,
|
|
|
|
} from "./TermsOfServiceSection.js";
|
2019-08-29 23:12:55 +02:00
|
|
|
|
2021-05-07 23:10:27 +02:00
|
|
|
interface Props {
|
|
|
|
talerWithdrawUri?: string;
|
|
|
|
}
|
2019-08-29 23:12:55 +02:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
type State = LoadingUri | LoadingExchange | LoadingInfoError | Success;
|
|
|
|
|
|
|
|
interface LoadingUri {
|
|
|
|
status: "loading-uri";
|
|
|
|
hook: HookError | undefined;
|
|
|
|
}
|
|
|
|
interface LoadingExchange {
|
|
|
|
status: "loading-exchange";
|
|
|
|
hook: HookError | undefined;
|
|
|
|
}
|
|
|
|
interface LoadingInfoError {
|
|
|
|
status: "loading-info";
|
|
|
|
hook: HookError | undefined;
|
2021-11-15 15:18:58 +01:00
|
|
|
}
|
2021-09-13 18:32:58 +02:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
type Success = {
|
|
|
|
status: "success";
|
|
|
|
hook: undefined;
|
|
|
|
|
|
|
|
exchange: SelectFieldHandler;
|
|
|
|
|
|
|
|
editExchange: ButtonHandler;
|
|
|
|
cancelEditExchange: ButtonHandler;
|
|
|
|
confirmEditExchange: ButtonHandler;
|
|
|
|
|
|
|
|
showExchangeSelection: boolean;
|
|
|
|
chosenAmount: AmountJson;
|
|
|
|
withdrawalFee: AmountJson;
|
|
|
|
toBeReceived: AmountJson;
|
|
|
|
|
|
|
|
doWithdrawal: ButtonHandler;
|
|
|
|
tosProps?: TermsOfServiceSectionProps;
|
|
|
|
mustAcceptFirst: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export function useComponentState(
|
|
|
|
talerWithdrawUri: string | undefined,
|
|
|
|
api: typeof wxApi,
|
|
|
|
): State {
|
|
|
|
const [customExchange, setCustomExchange] = useState<string | undefined>(
|
2022-03-22 21:16:38 +01:00
|
|
|
undefined,
|
|
|
|
);
|
2022-02-18 20:54:15 +01:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
const uriInfoHook = useAsyncAsHook(async () => {
|
|
|
|
if (!talerWithdrawUri) throw Error("ERROR_NO-URI-FOR-WITHDRAWAL");
|
|
|
|
|
|
|
|
const uriInfo = await api.getWithdrawalDetailsForUri({
|
|
|
|
talerWithdrawUri,
|
|
|
|
});
|
|
|
|
const { exchanges: knownExchanges } = await api.listExchanges();
|
|
|
|
|
|
|
|
return { uriInfo, knownExchanges };
|
|
|
|
});
|
|
|
|
|
|
|
|
const exchangeAndAmount = useAsyncAsHook(
|
|
|
|
async () => {
|
|
|
|
if (!uriInfoHook || uriInfoHook.hasError || !uriInfoHook.response) return;
|
|
|
|
const { uriInfo, knownExchanges } = uriInfoHook.response;
|
|
|
|
|
|
|
|
const amount = Amounts.parseOrThrow(uriInfo.amount);
|
|
|
|
|
|
|
|
const thisCurrencyExchanges = knownExchanges.filter(
|
|
|
|
(ex) => ex.currency === amount.currency,
|
|
|
|
);
|
|
|
|
|
|
|
|
const thisExchange: string | undefined =
|
|
|
|
customExchange ??
|
|
|
|
uriInfo.defaultExchangeBaseUrl ??
|
|
|
|
(thisCurrencyExchanges[0]
|
|
|
|
? thisCurrencyExchanges[0].exchangeBaseUrl
|
|
|
|
: undefined);
|
|
|
|
|
|
|
|
if (!thisExchange) throw Error("ERROR_NO-DEFAULT-EXCHANGE");
|
|
|
|
|
|
|
|
return { amount, thisExchange, thisCurrencyExchanges };
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
[!uriInfoHook || uriInfoHook.hasError ? undefined : uriInfoHook],
|
|
|
|
);
|
|
|
|
|
|
|
|
const terms = useAsyncAsHook(
|
|
|
|
async () => {
|
|
|
|
if (
|
|
|
|
!exchangeAndAmount ||
|
|
|
|
exchangeAndAmount.hasError ||
|
|
|
|
!exchangeAndAmount.response
|
|
|
|
)
|
|
|
|
return;
|
|
|
|
const { thisExchange } = exchangeAndAmount.response;
|
|
|
|
const exchangeTos = await api.getExchangeTos(thisExchange, ["text/xml"]);
|
|
|
|
|
|
|
|
const state = buildTermsOfServiceState(exchangeTos);
|
|
|
|
|
|
|
|
return { state };
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
[
|
|
|
|
!exchangeAndAmount || exchangeAndAmount.hasError
|
|
|
|
? undefined
|
|
|
|
: exchangeAndAmount,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
const info = useAsyncAsHook(
|
|
|
|
async () => {
|
|
|
|
if (
|
|
|
|
!exchangeAndAmount ||
|
|
|
|
exchangeAndAmount.hasError ||
|
|
|
|
!exchangeAndAmount.response
|
|
|
|
)
|
|
|
|
return;
|
|
|
|
const { thisExchange, amount } = exchangeAndAmount.response;
|
|
|
|
|
|
|
|
const info = await api.getExchangeWithdrawalInfo({
|
|
|
|
exchangeBaseUrl: thisExchange,
|
|
|
|
amount,
|
|
|
|
tosAcceptedFormat: ["text/xml"],
|
|
|
|
});
|
|
|
|
|
|
|
|
const withdrawalFee = Amounts.sub(
|
|
|
|
Amounts.parseOrThrow(info.withdrawalAmountRaw),
|
|
|
|
Amounts.parseOrThrow(info.withdrawalAmountEffective),
|
|
|
|
).amount;
|
2021-11-15 15:18:58 +01:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
return { info, withdrawalFee };
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
[
|
|
|
|
!exchangeAndAmount || exchangeAndAmount.hasError
|
|
|
|
? undefined
|
|
|
|
: exchangeAndAmount,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
const [reviewing, setReviewing] = useState<boolean>(false);
|
|
|
|
const [reviewed, setReviewed] = useState<boolean>(false);
|
|
|
|
|
|
|
|
const [withdrawError, setWithdrawError] = useState<TalerError | undefined>(
|
2021-11-24 13:52:58 +01:00
|
|
|
undefined,
|
|
|
|
);
|
2022-04-11 16:36:32 +02:00
|
|
|
const [confirmDisabled, setConfirmDisabled] = useState<boolean>(false);
|
2021-11-24 13:52:58 +01:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
const [showExchangeSelection, setShowExchangeSelection] = useState(false);
|
|
|
|
const [nextExchange, setNextExchange] = useState<string | undefined>();
|
|
|
|
|
|
|
|
if (!uriInfoHook || uriInfoHook.hasError) {
|
|
|
|
return {
|
|
|
|
status: "loading-uri",
|
|
|
|
hook: uriInfoHook,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!exchangeAndAmount || exchangeAndAmount.hasError) {
|
|
|
|
return {
|
|
|
|
status: "loading-exchange",
|
|
|
|
hook: exchangeAndAmount,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (!exchangeAndAmount.response) {
|
|
|
|
return {
|
|
|
|
status: "loading-exchange",
|
|
|
|
hook: undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const { thisExchange, thisCurrencyExchanges, amount } =
|
|
|
|
exchangeAndAmount.response;
|
2022-02-18 20:54:15 +01:00
|
|
|
|
2022-03-29 14:58:06 +02:00
|
|
|
async function doWithdrawAndCheckError(): Promise<void> {
|
2022-02-18 20:54:15 +01:00
|
|
|
try {
|
|
|
|
setConfirmDisabled(true);
|
2022-04-11 16:36:32 +02:00
|
|
|
if (!talerWithdrawUri) return;
|
|
|
|
const res = await api.acceptWithdrawal(talerWithdrawUri, thisExchange);
|
|
|
|
if (res.confirmTransferUrl) {
|
|
|
|
document.location.href = res.confirmTransferUrl;
|
|
|
|
}
|
2022-02-18 20:54:15 +01:00
|
|
|
} catch (e) {
|
2022-03-22 21:16:38 +01:00
|
|
|
if (e instanceof TalerError) {
|
2022-02-18 20:54:15 +01:00
|
|
|
setWithdrawError(e);
|
|
|
|
}
|
|
|
|
setConfirmDisabled(false);
|
|
|
|
}
|
|
|
|
}
|
2021-10-11 20:59:55 +02:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
const exchanges = thisCurrencyExchanges.reduce(
|
|
|
|
(prev, ex) => ({ ...prev, [ex.exchangeBaseUrl]: ex.exchangeBaseUrl }),
|
|
|
|
{},
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!info || info.hasError) {
|
|
|
|
return {
|
|
|
|
status: "loading-info",
|
|
|
|
hook: info,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (!info.response) {
|
|
|
|
return {
|
|
|
|
status: "loading-info",
|
|
|
|
hook: undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const exchangeHandler: SelectFieldHandler = {
|
|
|
|
onChange: setNextExchange,
|
|
|
|
value: nextExchange || thisExchange,
|
|
|
|
list: exchanges,
|
|
|
|
isDirty: nextExchange !== thisExchange,
|
|
|
|
};
|
|
|
|
|
|
|
|
const editExchange: ButtonHandler = {
|
|
|
|
onClick: async () => {
|
|
|
|
setShowExchangeSelection(true);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const cancelEditExchange: ButtonHandler = {
|
|
|
|
onClick: async () => {
|
|
|
|
setShowExchangeSelection(false);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const confirmEditExchange: ButtonHandler = {
|
|
|
|
onClick: async () => {
|
|
|
|
setCustomExchange(exchangeHandler.value);
|
|
|
|
setShowExchangeSelection(false);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const { withdrawalFee } = info.response;
|
|
|
|
const toBeReceived = Amounts.sub(amount, withdrawalFee).amount;
|
|
|
|
|
|
|
|
const { state: termsState } = (!terms
|
|
|
|
? undefined
|
|
|
|
: terms.hasError
|
|
|
|
? undefined
|
|
|
|
: terms.response) || { state: undefined };
|
|
|
|
|
|
|
|
async function onAccept(accepted: boolean): Promise<void> {
|
|
|
|
if (!termsState) return;
|
|
|
|
|
|
|
|
try {
|
|
|
|
await api.setExchangeTosAccepted(
|
|
|
|
thisExchange,
|
|
|
|
accepted ? termsState.version : undefined,
|
|
|
|
);
|
|
|
|
setReviewed(accepted);
|
|
|
|
} catch (e) {
|
|
|
|
if (e instanceof Error) {
|
|
|
|
//FIXME: uncomment this and display error
|
|
|
|
// setErrorAccepting(e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
status: "success",
|
|
|
|
hook: undefined,
|
|
|
|
exchange: exchangeHandler,
|
|
|
|
editExchange,
|
|
|
|
cancelEditExchange,
|
|
|
|
confirmEditExchange,
|
|
|
|
showExchangeSelection,
|
|
|
|
toBeReceived,
|
|
|
|
withdrawalFee,
|
|
|
|
chosenAmount: amount,
|
|
|
|
doWithdrawal: {
|
|
|
|
onClick: doWithdrawAndCheckError,
|
|
|
|
error: withdrawError,
|
|
|
|
disabled: confirmDisabled,
|
|
|
|
},
|
|
|
|
tosProps: !termsState
|
|
|
|
? undefined
|
|
|
|
: {
|
|
|
|
onAccept,
|
|
|
|
onReview: setReviewing,
|
|
|
|
reviewed: reviewed,
|
|
|
|
reviewing: reviewing,
|
|
|
|
terms: termsState,
|
|
|
|
},
|
|
|
|
mustAcceptFirst:
|
|
|
|
termsState !== undefined &&
|
|
|
|
(termsState.status === "changed" || termsState.status === "new"),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function View({ state }: { state: Success }): VNode {
|
|
|
|
const { i18n } = useTranslationContext();
|
2019-08-29 23:12:55 +02:00
|
|
|
return (
|
2021-09-17 20:48:33 +02:00
|
|
|
<WalletAction>
|
2021-09-08 20:30:32 +02:00
|
|
|
<LogoHeader />
|
2022-03-28 19:03:59 +02:00
|
|
|
<SubTitle>
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>Digital cash withdrawal</i18n.Translate>
|
2022-03-28 19:03:59 +02:00
|
|
|
</SubTitle>
|
2022-02-18 20:54:15 +01:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
{state.doWithdrawal.error && (
|
2022-02-18 20:54:15 +01:00
|
|
|
<ErrorTalerOperation
|
2022-02-23 19:18:37 +01:00
|
|
|
title={
|
2022-02-23 19:44:14 +01:00
|
|
|
<i18n.Translate>
|
|
|
|
Could not finish the withdrawal operation
|
|
|
|
</i18n.Translate>
|
2022-02-23 19:18:37 +01:00
|
|
|
}
|
2022-04-11 16:36:32 +02:00
|
|
|
error={state.doWithdrawal.error.errorDetail}
|
2022-02-18 20:54:15 +01:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2021-09-08 20:30:32 +02:00
|
|
|
<section>
|
2021-11-15 15:18:58 +01:00
|
|
|
<Part
|
2022-02-23 19:44:14 +01:00
|
|
|
title={<i18n.Translate>Total to withdraw</i18n.Translate>}
|
2022-04-11 16:36:32 +02:00
|
|
|
text={<Amount value={state.toBeReceived} />}
|
2021-11-15 15:18:58 +01:00
|
|
|
kind="positive"
|
|
|
|
/>
|
2022-04-11 16:36:32 +02:00
|
|
|
{Amounts.isNonZero(state.withdrawalFee) && (
|
2021-11-24 12:57:26 +01:00
|
|
|
<Fragment>
|
|
|
|
<Part
|
2022-02-23 19:44:14 +01:00
|
|
|
title={<i18n.Translate>Chosen amount</i18n.Translate>}
|
2022-04-11 16:36:32 +02:00
|
|
|
text={<Amount value={state.chosenAmount} />}
|
2021-11-24 12:57:26 +01:00
|
|
|
kind="neutral"
|
|
|
|
/>
|
|
|
|
<Part
|
2022-02-23 19:44:14 +01:00
|
|
|
title={<i18n.Translate>Exchange fee</i18n.Translate>}
|
2022-04-11 16:36:32 +02:00
|
|
|
text={<Amount value={state.withdrawalFee} />}
|
2021-11-24 12:57:26 +01:00
|
|
|
kind="negative"
|
|
|
|
/>
|
|
|
|
</Fragment>
|
2021-11-15 15:18:58 +01:00
|
|
|
)}
|
2022-04-11 16:36:32 +02:00
|
|
|
<Part
|
|
|
|
title={<i18n.Translate>Exchange</i18n.Translate>}
|
|
|
|
text={state.exchange.value}
|
|
|
|
kind="neutral"
|
|
|
|
big
|
|
|
|
/>
|
|
|
|
{state.showExchangeSelection ? (
|
|
|
|
<Fragment>
|
|
|
|
<div>
|
|
|
|
<SelectList
|
|
|
|
label={<i18n.Translate>Known exchanges</i18n.Translate>}
|
|
|
|
list={state.exchange.list}
|
|
|
|
value={state.exchange.value}
|
|
|
|
name="switchingExchange"
|
|
|
|
onChange={state.exchange.onChange}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-03-15 15:39:42 +01:00
|
|
|
<LinkSuccess
|
|
|
|
upperCased
|
2022-04-11 16:36:32 +02:00
|
|
|
style={{ fontSize: "small" }}
|
|
|
|
onClick={state.confirmEditExchange.onClick}
|
2022-03-15 15:39:42 +01:00
|
|
|
>
|
2022-04-11 16:36:32 +02:00
|
|
|
{state.exchange.isDirty ? (
|
|
|
|
<i18n.Translate>Confirm exchange selection</i18n.Translate>
|
|
|
|
) : (
|
|
|
|
<i18n.Translate>Cancel exchange selection</i18n.Translate>
|
|
|
|
)}
|
2021-11-15 15:18:58 +01:00
|
|
|
</LinkSuccess>
|
2022-04-11 16:36:32 +02:00
|
|
|
</Fragment>
|
|
|
|
) : (
|
|
|
|
<LinkSuccess
|
|
|
|
style={{ fontSize: "small" }}
|
2021-10-13 14:54:18 +02:00
|
|
|
upperCased
|
2022-04-11 16:36:32 +02:00
|
|
|
onClick={state.editExchange.onClick}
|
2021-10-13 14:54:18 +02:00
|
|
|
>
|
2022-04-11 16:36:32 +02:00
|
|
|
<i18n.Translate>Edit exchange</i18n.Translate>
|
|
|
|
</LinkSuccess>
|
2021-11-15 15:18:58 +01:00
|
|
|
)}
|
2021-09-08 20:30:32 +02:00
|
|
|
</section>
|
2022-04-11 16:36:32 +02:00
|
|
|
{state.tosProps && <TermsOfServiceSection {...state.tosProps} />}
|
|
|
|
{state.tosProps ? (
|
|
|
|
<section>
|
|
|
|
{(state.tosProps.terms.status === "accepted" ||
|
|
|
|
(state.mustAcceptFirst && state.tosProps.reviewed)) && (
|
|
|
|
<ButtonSuccess
|
|
|
|
upperCased
|
|
|
|
disabled={state.doWithdrawal.disabled}
|
|
|
|
onClick={state.doWithdrawal.onClick}
|
|
|
|
>
|
|
|
|
<i18n.Translate>Confirm withdrawal</i18n.Translate>
|
|
|
|
</ButtonSuccess>
|
|
|
|
)}
|
|
|
|
{state.tosProps.terms.status === "notfound" && (
|
|
|
|
<ButtonWarning
|
|
|
|
upperCased
|
|
|
|
disabled={state.doWithdrawal.disabled}
|
|
|
|
onClick={state.doWithdrawal.onClick}
|
|
|
|
>
|
|
|
|
<i18n.Translate>Withdraw anyway</i18n.Translate>
|
|
|
|
</ButtonWarning>
|
|
|
|
)}
|
|
|
|
</section>
|
|
|
|
) : (
|
|
|
|
<section>
|
|
|
|
<i18n.Translate>Loading terms of service...</i18n.Translate>
|
|
|
|
</section>
|
|
|
|
)}
|
2021-08-19 05:34:47 +02:00
|
|
|
</WalletAction>
|
2021-11-15 15:18:58 +01:00
|
|
|
);
|
2021-05-31 16:34:48 +02:00
|
|
|
}
|
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
export function WithdrawPage({ talerWithdrawUri }: Props): VNode {
|
2022-03-14 19:20:32 +01:00
|
|
|
const { i18n } = useTranslationContext();
|
2021-11-22 21:34:27 +01:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
const state = useComponentState(talerWithdrawUri, wxApi);
|
2021-11-22 21:34:27 +01:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
if (!talerWithdrawUri) {
|
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
<i18n.Translate>missing withdraw uri</i18n.Translate>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
2021-10-11 20:59:55 +02:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
if (!state) {
|
2022-01-20 17:12:28 +01:00
|
|
|
return <Loading />;
|
2021-10-11 20:59:55 +02:00
|
|
|
}
|
2022-04-11 16:36:32 +02:00
|
|
|
|
|
|
|
console.log(state);
|
|
|
|
if (state.status === "loading-uri") {
|
|
|
|
if (!state.hook) return <Loading />;
|
|
|
|
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
2022-01-20 17:12:28 +01:00
|
|
|
<LoadingError
|
2022-02-23 19:44:14 +01:00
|
|
|
title={
|
2022-04-11 16:36:32 +02:00
|
|
|
<i18n.Translate>Could not get the info from the URI</i18n.Translate>
|
2022-02-23 19:44:14 +01:00
|
|
|
}
|
2022-04-11 16:36:32 +02:00
|
|
|
error={state.hook}
|
2022-01-20 17:12:28 +01:00
|
|
|
/>
|
2021-11-15 15:18:58 +01:00
|
|
|
);
|
2021-08-13 23:04:05 +02:00
|
|
|
}
|
2022-04-11 16:36:32 +02:00
|
|
|
if (state.status === "loading-exchange") {
|
|
|
|
if (!state.hook) return <Loading />;
|
2021-05-31 16:34:48 +02:00
|
|
|
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
2022-04-11 16:36:32 +02:00
|
|
|
<LoadingError
|
|
|
|
title={<i18n.Translate>Could not get exchange</i18n.Translate>}
|
|
|
|
error={state.hook}
|
|
|
|
/>
|
2021-11-15 15:18:58 +01:00
|
|
|
);
|
2021-10-11 20:59:55 +02:00
|
|
|
}
|
2022-04-11 16:36:32 +02:00
|
|
|
if (state.status === "loading-info") {
|
|
|
|
if (!state.hook) return <Loading />;
|
2021-11-15 15:18:58 +01:00
|
|
|
return (
|
2022-01-20 17:12:28 +01:00
|
|
|
<LoadingError
|
2022-02-23 19:44:14 +01:00
|
|
|
title={
|
2022-04-11 16:36:32 +02:00
|
|
|
<i18n.Translate>Could not get info of withdrawal</i18n.Translate>
|
2022-02-23 19:44:14 +01:00
|
|
|
}
|
2022-04-11 16:36:32 +02:00
|
|
|
error={state.hook}
|
2022-01-20 17:12:28 +01:00
|
|
|
/>
|
2021-11-15 15:18:58 +01:00
|
|
|
);
|
2021-10-11 20:59:55 +02:00
|
|
|
}
|
2022-01-20 17:12:28 +01:00
|
|
|
|
2022-04-11 16:36:32 +02:00
|
|
|
return <View state={state} />;
|
2021-10-11 20:59:55 +02:00
|
|
|
}
|