From 08959f83bc9f6d5df93cb6c2d34b671bf419d05a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 14 Mar 2022 15:20:32 -0300 Subject: take translator from transaltion context --- .../taler-wallet-webextension/src/cta/Deposit.tsx | 5 +- packages/taler-wallet-webextension/src/cta/Pay.tsx | 8 +- .../taler-wallet-webextension/src/cta/Refund.tsx | 5 +- .../src/cta/TermsOfServiceSection.tsx | 3 +- packages/taler-wallet-webextension/src/cta/Tip.tsx | 5 +- .../taler-wallet-webextension/src/cta/Withdraw.tsx | 8 +- .../src/cta/reset-required.tsx | 112 --------------------- .../src/cta/return-coins.tsx | 3 +- 8 files changed, 23 insertions(+), 126 deletions(-) delete mode 100644 packages/taler-wallet-webextension/src/cta/reset-required.tsx (limited to 'packages/taler-wallet-webextension/src/cta') diff --git a/packages/taler-wallet-webextension/src/cta/Deposit.tsx b/packages/taler-wallet-webextension/src/cta/Deposit.tsx index 82d898d77..ac6c1fd6d 100644 --- a/packages/taler-wallet-webextension/src/cta/Deposit.tsx +++ b/packages/taler-wallet-webextension/src/cta/Deposit.tsx @@ -22,7 +22,6 @@ /** * Imports. */ -// import * as i18n from "../i18n"; import { AmountJson, @@ -31,7 +30,6 @@ import { ConfirmPayResult, ConfirmPayResultType, ContractTerms, - i18n, NotificationType, PreparePayResult, PreparePayResultType, @@ -49,6 +47,7 @@ import { WalletAction, WarningBox, } from "../components/styled"; +import { useTranslationContext } from "../context/translation"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; import * as wxApi from "../wxApi"; @@ -58,6 +57,7 @@ interface Props { } export function DepositPage({ talerPayUri, goBack }: Props): VNode { + const { i18n } = useTranslationContext(); const [payStatus, setPayStatus] = useState( undefined, ); @@ -199,6 +199,7 @@ export function PaymentRequestView({ }: PaymentRequestViewProps): VNode { let totalFees: AmountJson = Amounts.getZero(payStatus.amountRaw); const contractTerms: ContractTerms = payStatus.contractTerms; + const { i18n } = useTranslationContext(); return ( diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx b/packages/taler-wallet-webextension/src/cta/Pay.tsx index 4fe44dcff..ba31f4c34 100644 --- a/packages/taler-wallet-webextension/src/cta/Pay.tsx +++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx @@ -22,7 +22,6 @@ /** * Imports. */ -// import * as i18n from "../i18n"; import { AmountJson, @@ -32,12 +31,10 @@ import { ConfirmPayResultDone, ConfirmPayResultType, ContractTerms, - i18n, NotificationType, PreparePayResult, PreparePayResultType, Product, - Translate, } from "@gnu-taler/taler-util"; import { OperationFailedError } from "@gnu-taler/taler-wallet-core"; import { Fragment, h, VNode } from "preact"; @@ -50,13 +47,13 @@ import { Part } from "../components/Part"; import { QR } from "../components/QR"; import { ButtonSuccess, - LightText, LinkSuccess, SmallLightText, SuccessBox, WalletAction, WarningBox, } from "../components/styled"; +import { useTranslationContext } from "../context/translation"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; import * as wxApi from "../wxApi"; @@ -89,6 +86,7 @@ export function PayPage({ goToWalletManualWithdraw, goBack, }: Props): VNode { + const { i18n } = useTranslationContext(); const [payResult, setPayResult] = useState( undefined, ); @@ -166,6 +164,7 @@ export function PaymentRequestView({ goToWalletManualWithdraw, balance, }: PaymentRequestViewProps): VNode { + const { i18n } = useTranslationContext(); let totalFees: AmountJson = Amounts.getZero(payStatus.amountRaw); const contractTerms: ContractTerms = payStatus.contractTerms; @@ -412,6 +411,7 @@ export function PaymentRequestView({ } function ProductList({ products }: { products: Product[] }): VNode { + const { i18n } = useTranslationContext(); return ( diff --git a/packages/taler-wallet-webextension/src/cta/Refund.tsx b/packages/taler-wallet-webextension/src/cta/Refund.tsx index 8ce008bcd..efc436bc8 100644 --- a/packages/taler-wallet-webextension/src/cta/Refund.tsx +++ b/packages/taler-wallet-webextension/src/cta/Refund.tsx @@ -20,9 +20,10 @@ * @author sebasjm */ -import { Amounts, ApplyRefundResponse, i18n } from "@gnu-taler/taler-util"; +import { Amounts, ApplyRefundResponse } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; +import { useTranslationContext } from "../context/translation"; import { AmountView } from "../renderHtml"; import * as wxApi from "../wxApi"; @@ -33,6 +34,7 @@ export interface ViewProps { applyResult: ApplyRefundResponse; } export function View({ applyResult }: ViewProps): VNode { + const { i18n } = useTranslationContext(); return (

GNU Taler Wallet

@@ -71,6 +73,7 @@ export function RefundPage({ talerRefundUri }: Props): VNode { const [applyResult, setApplyResult] = useState< ApplyRefundResponse | undefined >(undefined); + const { i18n } = useTranslationContext(); const [errMsg, setErrMsg] = useState(undefined); useEffect(() => { diff --git a/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx b/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx index 1244b7915..cafc43c6f 100644 --- a/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx +++ b/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx @@ -1,4 +1,3 @@ -import { i18n, Translate } from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; import { CheckboxOutlined } from "../components/CheckboxOutlined"; import { ExchangeXmlTos } from "../components/ExchangeToS"; @@ -10,6 +9,7 @@ import { WarningBox, WarningText, } from "../components/styled"; +import { useTranslationContext } from "../context/translation"; import { TermsState } from "../utils/index"; interface Props { @@ -26,6 +26,7 @@ export function TermsOfServiceSection({ onAccept, onReview, }: Props): VNode { + const { i18n } = useTranslationContext(); if (!reviewing) { if (!reviewed) { if (!onReview) { diff --git a/packages/taler-wallet-webextension/src/cta/Tip.tsx b/packages/taler-wallet-webextension/src/cta/Tip.tsx index ff86ce8c7..71aa04a2b 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip.tsx +++ b/packages/taler-wallet-webextension/src/cta/Tip.tsx @@ -20,10 +20,11 @@ * @author sebasjm */ -import { PrepareTipResult, i18n } from "@gnu-taler/taler-util"; +import { PrepareTipResult } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; import { Loading } from "../components/Loading"; +import { useTranslationContext } from "../context/translation"; import { AmountView } from "../renderHtml"; import * as wxApi from "../wxApi"; @@ -40,6 +41,7 @@ export function View({ onAccept, onIgnore, }: ViewProps): VNode { + const { i18n } = useTranslationContext(); return (

GNU Taler Wallet

@@ -77,6 +79,7 @@ export function View({ } export function TipPage({ talerTipUri }: Props): VNode { + const { i18n } = useTranslationContext(); const [updateCounter, setUpdateCounter] = useState(0); const [prepareTipResult, setPrepareTipResult] = useState< PrepareTipResult | undefined diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx index 7c9745ddc..8535c67eb 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx @@ -25,7 +25,6 @@ import { AmountJson, Amounts, ExchangeListItem, - i18n, Translate, WithdrawUriInfoResponse, } from "@gnu-taler/taler-util"; @@ -52,6 +51,7 @@ import { } from "../utils/index"; import * as wxApi from "../wxApi"; import { TermsOfServiceSection } from "./TermsOfServiceSection"; +import { useTranslationContext } from "../context/translation"; interface Props { talerWithdrawUri?: string; @@ -84,6 +84,7 @@ export function View({ onAccept, reviewed, }: ViewProps): VNode { + const { i18n } = useTranslationContext(); const [withdrawError, setWithdrawError] = useState< OperationFailedError | undefined >(undefined); @@ -236,12 +237,10 @@ export function WithdrawPageWithParsedURI({ uri: string; uriInfo: WithdrawUriInfoResponse; }): VNode { + const { i18n } = useTranslationContext(); const [customExchange, setCustomExchange] = useState( undefined, ); - // const [errorAccepting, setErrorAccepting] = useState( - // undefined, - // ); const [reviewing, setReviewing] = useState(false); const [reviewed, setReviewed] = useState(false); @@ -332,6 +331,7 @@ export function WithdrawPageWithParsedURI({ ); } export function WithdrawPage({ talerWithdrawUri }: Props): VNode { + const { i18n } = useTranslationContext(); const uriInfoHook = useAsyncAsHook(() => !talerWithdrawUri ? Promise.reject(undefined) diff --git a/packages/taler-wallet-webextension/src/cta/reset-required.tsx b/packages/taler-wallet-webextension/src/cta/reset-required.tsx deleted file mode 100644 index 350c32d76..000000000 --- a/packages/taler-wallet-webextension/src/cta/reset-required.tsx +++ /dev/null @@ -1,112 +0,0 @@ -/* - This file is part of TALER - (C) 2017 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 - */ - -/** - * Page to inform the user when a database reset is required. - * - * @author sebasjm - */ - -import { i18n } from "@gnu-taler/taler-util"; -import { Component, h, VNode } from "preact"; -import * as wxApi from "../wxApi"; - -interface State { - /** - * Did the user check the confirmation check box? - */ - checked: boolean; - - /** - * Do we actually need to reset the db? - */ - resetRequired: boolean; -} - -class ResetNotification extends Component { - constructor(props: any) { - super(props); - this.state = { checked: false, resetRequired: true }; - setInterval(() => this.update(), 500); - } - async update(): Promise { - const res = await wxApi.checkUpgrade(); - this.setState({ resetRequired: res.dbResetRequired }); - } - render(): VNode { - if (this.state.resetRequired) { - return ( -
-

- Manual Reset Required -

-

- - The wallet's database in your browser is incompatible with - the currently installed wallet. Please reset manually. - -

-

- - Once the database format has stabilized, we will provide automatic - upgrades. - -

- { - this.setState((prev) => ({ checked: prev.checked })); - }} - />{" "} - -
- -
- ); - } - return ( -
-

- Everything is fine! -

-

- - A reset is not required anymore, you can close this page. - -

-
- ); - } -} - -/** - * @deprecated to be removed - */ -export function createResetRequiredPage(): VNode { - return ; -} diff --git a/packages/taler-wallet-webextension/src/cta/return-coins.tsx b/packages/taler-wallet-webextension/src/cta/return-coins.tsx index 1d688fa06..e7a784e2c 100644 --- a/packages/taler-wallet-webextension/src/cta/return-coins.tsx +++ b/packages/taler-wallet-webextension/src/cta/return-coins.tsx @@ -14,8 +14,8 @@ TALER; see the file COPYING. If not, see */ -import { i18n } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; +import { useTranslationContext } from "../context/translation"; /** * Return coins to own bank account. * @@ -26,6 +26,7 @@ import { h, VNode } from "preact"; * Imports. */ export function createReturnCoinsPage(): VNode { + const { i18n } = useTranslationContext(); return ( Not implemented yet. -- cgit v1.2.3