-
{i18n`Authorize withdrawal by solving challenge`}
-
- {i18n`What is`} {captchaNumbers.a} + {captchaNumbers.b} ?
- {
- captchaAnswer = e.currentTarget.value;
- }} />
-
-
- {
- if (captchaAnswer == (captchaNumbers.a + captchaNumbers.b).toString()) {
- confirmWithdrawalCall(
+ return (
+
+ {i18n`Confirm Withdrawal`}
+
+
+
+
+
+
+ A this point, a real bank would ask for an additional
+ authentication proof (PIN/TAN, one time password, ..), instead
+ of a simple calculation.
+
-
-
-
- A this point, a real bank would ask for an additional
- authentication proof (PIN/TAN, one time password, ..), instead
- of a simple calculation.
-
-
-
- );
+
+
+ );
}
-function QrCodeSection({ talerWithdrawUri, abortButton }: { talerWithdrawUri: string, abortButton: h.JSX.Element }) {
+function QrCodeSection({
+ talerWithdrawUri,
+ abortButton,
+}: {
+ talerWithdrawUri: string;
+ abortButton: h.JSX.Element;
+}) {
const i18n = useTranslator();
useEffect(() => {
//Taler Wallet WebExtension is listening to headers response and tab updates.
//In the SPA there is no header response with the Taler URI so
//this hack manually triggers the tab update after the QR is in the DOM.
- window.location.href = `${window.location.href.split('#')[0]}#`
- }, [])
+ window.location.href = `${window.location.href.split("#")[0]}#`;
+ }, []);
- return
- {i18n`Charge Taler Wallet`}
- {i18n`You can use this QR code to withdraw to your mobile wallet:`}
- {QR({ text: talerWithdrawUri })}
- Click {i18n`this link`} to open your Taler wallet!
-
- {abortButton}
-
+ return (
+
+ {i18n`Charge Taler Wallet`}
+ {i18n`You can use this QR code to withdraw to your mobile wallet:`}
+ {QR({ text: talerWithdrawUri })}
+
+ Click {i18n`this link`} to
+ open your Taler wallet!
+
+
+ {abortButton}
+
+ );
}
/**
@@ -1220,86 +1371,94 @@ function QrCodeSection({ talerWithdrawUri, abortButton }: { talerWithdrawUri: st
function TalerWithdrawalQRCode(Props: any): VNode {
// turns true when the wallet POSTed the reserve details:
const [pageState, pageStateSetter] = useContext(PageContext);
- const {
- withdrawalId,
- talerWithdrawUri,
- accountLabel,
- backendState } = Props;
+ const { withdrawalId, talerWithdrawUri, accountLabel, backendState } = Props;
const i18n = useTranslator();
- const abortButton = {
- pageStateSetter((prevState: PageStateType) => {
- const { withdrawalId, talerWithdrawUri, ...rest } = prevState;
- return { ...rest, withdrawalInProgress: false };
- })
- }}>{i18n`Abort`}
+ const abortButton = (
+ {
+ pageStateSetter((prevState: PageStateType) => {
+ const { withdrawalId, talerWithdrawUri, ...rest } = prevState;
+ return { ...rest, withdrawalInProgress: false };
+ });
+ }}
+ >{i18n`Abort`}
+ );
console.log(`Showing withdraw URI: ${talerWithdrawUri}`);
// waiting for the wallet:
- const { data, error, mutate } = useSWR(`integration-api/withdrawal-operation/${withdrawalId}`);
+ const { data, error, mutate } = useSWR(
+ `integration-api/withdrawal-operation/${withdrawalId}`,
+ );
- if (typeof error !== 'undefined') {
- console.log(`withdrawal (${withdrawalId}) was never (correctly) created at the bank...`, error);
+ if (typeof error !== "undefined") {
+ console.log(
+ `withdrawal (${withdrawalId}) was never (correctly) created at the bank...`,
+ error,
+ );
pageStateSetter((prevState: PageStateType) => ({
...prevState,
hasError: true,
- error: i18n`withdrawal (${withdrawalId}) was never (correctly) created at the bank...`
- }))
- return ( {abortButton} );
+ error: i18n`withdrawal (${withdrawalId}) was never (correctly) created at the bank...`,
+ }));
+ return (
+
+
+
+ {abortButton}
+
+ );
}
// data didn't arrive yet and wallet didn't communicate:
- if (typeof data === 'undefined')
- return {i18n`Waiting the bank to create the operaion...`}
-
+ if (typeof data === "undefined")
+ return {i18n`Waiting the bank to create the operaion...`}
;
/**
* Wallet didn't communicate withdrawal details yet:
*/
- console.log('withdrawal status', data);
+ console.log("withdrawal status", data);
if (data.aborted)
pageStateSetter((prevState: PageStateType) => {
- const {
- withdrawalId,
- talerWithdrawUri,
- ...rest } = prevState;
+ const { withdrawalId, talerWithdrawUri, ...rest } = prevState;
return {
...rest,
withdrawalInProgress: false,
hasError: true,
- error: i18n`This withdrawal was aborted!`
+ error: i18n`This withdrawal was aborted!`,
};
- })
-
+ });
if (!data.selection_done) {
setTimeout(() => mutate(), 1000); // check again after 1 second.
- return ( );
+ return (
+
+ );
}
/**
* Wallet POSTed the withdrawal details! Ask the
* user to authorize the operation (here CAPTCHA).
*/
- return ( );
+ return ;
}
-
-
function WalletWithdraw(Props: any): VNode {
const { backendState, pageStateSetter, focus } = Props;
const currency = useContext(CurrencyContext);
const i18n = useTranslator();
- let submitAmount = '5.00';
- const amountRegex = '^[0-9]+(\.[0-9]+)?$';
+ let submitAmount = "5.00";
+ const amountRegex = "^[0-9]+(.[0-9]+)?$";
- const ref = useRef(null)
+ const ref = useRef(null);
useEffect(() => {
if (focus) ref.current?.focus();
}, [focus]);
return (
-