diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta')
8 files changed, 23 insertions, 126 deletions
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<PreparePayResult | undefined>( 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 ( <WalletAction> 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<ConfirmPayResult | undefined>( 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 ( <Fragment> <SmallLightText style={{ margin: ".5em" }}> 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 ( <section class="main"> <h1>GNU Taler Wallet</h1> @@ -71,6 +73,7 @@ export function RefundPage({ talerRefundUri }: Props): VNode { const [applyResult, setApplyResult] = useState< ApplyRefundResponse | undefined >(undefined); + const { i18n } = useTranslationContext(); const [errMsg, setErrMsg] = useState<string | undefined>(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 <dold@taler.net> */ -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 ( <section class="main"> <h1>GNU Taler Wallet</h1> @@ -77,6 +79,7 @@ export function View({ } export function TipPage({ talerTipUri }: Props): VNode { + const { i18n } = useTranslationContext(); const [updateCounter, setUpdateCounter] = useState<number>(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<string | undefined>( undefined, ); - // const [errorAccepting, setErrorAccepting] = useState<string | undefined>( - // undefined, - // ); const [reviewing, setReviewing] = useState<boolean>(false); const [reviewed, setReviewed] = useState<boolean>(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 <http://www.gnu.org/licenses/> - */ - -/** - * 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<any, State> { - constructor(props: any) { - super(props); - this.state = { checked: false, resetRequired: true }; - setInterval(() => this.update(), 500); - } - async update(): Promise<void> { - const res = await wxApi.checkUpgrade(); - this.setState({ resetRequired: res.dbResetRequired }); - } - render(): VNode { - if (this.state.resetRequired) { - return ( - <div> - <h1> - <i18n.Translate>Manual Reset Required</i18n.Translate> - </h1> - <p> - <i18n.Translate> - The wallet's database in your browser is incompatible with - the currently installed wallet. Please reset manually. - </i18n.Translate> - </p> - <p> - <i18n.Translate> - Once the database format has stabilized, we will provide automatic - upgrades. - </i18n.Translate> - </p> - <input - id="check" - type="checkbox" - checked={this.state.checked} - onChange={() => { - this.setState((prev) => ({ checked: prev.checked })); - }} - />{" "} - <label htmlFor="check"> - <i18n.Translate> - I understand that I will lose all my data - </i18n.Translate> - </label> - <br /> - <button - class="pure-button" - disabled={!this.state.checked} - onClick={() => wxApi.resetDb()} - > - <i18n.Translate>Reset</i18n.Translate> - </button> - </div> - ); - } - return ( - <div> - <h1> - <i18n.Translate>Everything is fine!</i18n.Translate> - </h1> - <p> - <i18n.Translate> - A reset is not required anymore, you can close this page. - </i18n.Translate> - </p> - </div> - ); - } -} - -/** - * @deprecated to be removed - */ -export function createResetRequiredPage(): VNode { - return <ResetNotification />; -} 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 <http://www.gnu.org/licenses/> */ -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 ( <span> <i18n.Translate>Not implemented yet.</i18n.Translate> |