diff options
author | Sebastian <sebasjm@gmail.com> | 2022-12-07 16:07:42 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-12-07 16:08:20 -0300 |
commit | 46835d5155a561ddf9f3e21bbb81c823c3eab943 (patch) | |
tree | 51011d2bae21b66695e3854ed49b9c63f5f35255 /packages/demobank-ui/src/pages/home/PaytoWireTransferForm.tsx | |
parent | 1c6369677ab272196da314d95825273c6fff8d5f (diff) | |
download | wallet-core-46835d5155a561ddf9f3e21bbb81c823c3eab943.tar.xz |
no-fix: user logger instead of console.log
Diffstat (limited to 'packages/demobank-ui/src/pages/home/PaytoWireTransferForm.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/home/PaytoWireTransferForm.tsx | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/packages/demobank-ui/src/pages/home/PaytoWireTransferForm.tsx b/packages/demobank-ui/src/pages/home/PaytoWireTransferForm.tsx index e4fe386ff..bfb2f2fef 100644 --- a/packages/demobank-ui/src/pages/home/PaytoWireTransferForm.tsx +++ b/packages/demobank-ui/src/pages/home/PaytoWireTransferForm.tsx @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { Amounts, parsePaytoUri } from "@gnu-taler/taler-util"; +import { Amounts, Logger, parsePaytoUri } from "@gnu-taler/taler-util"; import { hooks } from "@gnu-taler/web-util/lib/index.browser"; import { h, VNode } from "preact"; import { StateUpdater, useEffect, useRef, useState } from "preact/hooks"; @@ -25,6 +25,8 @@ import { BackendState } from "../../hooks/backend.js"; import { prepareHeaders, undefinedIfEmpty } from "../../utils.js"; import { ShowInputErrorLabel } from "./ShowInputErrorLabel.js"; +const logger = new Logger("PaytoWireTransferForm"); + export function PaytoWireTransferForm({ focus, currency, @@ -162,7 +164,7 @@ export function PaytoWireTransferForm({ typeof submitData.amount === "undefined" || submitData.amount === "" ) { - console.log("Not all the fields were given."); + logger.error("Not all the fields were given."); pageStateSetter((prevState: PageStateType) => ({ ...prevState, @@ -209,7 +211,7 @@ export function PaytoWireTransferForm({ <a href="/account" onClick={() => { - console.log("switch to raw payto form"); + logger.trace("switch to raw payto form"); pageStateSetter((prevState) => ({ ...prevState, isRawPayto: true, @@ -272,7 +274,7 @@ export function PaytoWireTransferForm({ onClick={async () => { // empty string evaluates to false. if (!rawPaytoInput) { - console.log("Didn't get any raw Payto string!"); + logger.error("Didn't get any raw Payto string!"); return; } transactionData = { paytoUri: rawPaytoInput }; @@ -295,7 +297,7 @@ export function PaytoWireTransferForm({ <a href="/account" onClick={() => { - console.log("switch to wire-transfer-form"); + logger.trace("switch to wire-transfer-form"); pageStateSetter((prevState) => ({ ...prevState, isRawPayto: false, @@ -355,7 +357,7 @@ async function createTransactionCall( cleanUpForm: () => void, ): Promise<void> { if (backendState.status === "loggedOut") { - console.log("No credentials found."); + logger.error("No credentials found."); pageStateSetter((prevState) => ({ ...prevState, @@ -379,7 +381,7 @@ async function createTransactionCall( body: JSON.stringify(req), }); } catch (error) { - console.log("Could not POST transaction request to the bank", error); + logger.error("Could not POST transaction request to the bank", error); pageStateSetter((prevState) => ({ ...prevState, @@ -394,7 +396,7 @@ async function createTransactionCall( // POST happened, status not sure yet. if (!res.ok) { const response = await res.json(); - console.log( + logger.error( `Transfer creation gave response error: ${response} (${res.status})`, ); pageStateSetter((prevState) => ({ @@ -409,7 +411,7 @@ async function createTransactionCall( return; } // status is 200 OK here, tell the user. - console.log("Wire transfer created!"); + logger.trace("Wire transfer created!"); pageStateSetter((prevState) => ({ ...prevState, |