From af7b107f455b01e136db2211c357cc59a506139a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 1 Jun 2022 15:47:47 -0300 Subject: mui button impl --- .../src/popup/Application.tsx | 26 ++++++----- .../src/popup/BalancePage.tsx | 32 +++++++------ .../src/popup/NoBalanceHelp.tsx | 2 +- .../src/popup/TalerActionFound.tsx | 52 +++++++++++++++------- 4 files changed, 67 insertions(+), 45 deletions(-) (limited to 'packages/taler-wallet-webextension/src/popup') diff --git a/packages/taler-wallet-webextension/src/popup/Application.tsx b/packages/taler-wallet-webextension/src/popup/Application.tsx index 72579b05b..ba2886a41 100644 --- a/packages/taler-wallet-webextension/src/popup/Application.tsx +++ b/packages/taler-wallet-webextension/src/popup/Application.tsx @@ -61,7 +61,7 @@ export function Application(): VNode { - route(Pages.balance_transaction.replace(":tid", txId)) + redirectTo(Pages.balance_transaction.replace(":tid", txId)) } /> @@ -74,15 +74,19 @@ export function Application(): VNode { path={Pages.balance} component={BalancePage} goToWalletManualWithdraw={() => - route( + redirectTo( Pages.balance_manual_withdraw.replace(":currency?", ""), ) } goToWalletDeposit={(currency: string) => - route(Pages.balance_deposit.replace(":currency", currency)) + redirectTo( + Pages.balance_deposit.replace(":currency", currency), + ) } goToWalletHistory={(currency: string) => - route(Pages.balance_history.replace(":currency?", currency)) + redirectTo( + Pages.balance_history.replace(":currency?", currency), + ) } /> @@ -96,7 +100,7 @@ export function Application(): VNode { url={decodeURIComponent(action)} onDismiss={() => { setDismissed(true); - route(Pages.balance); + return redirectTo(Pages.balance); }} /> ); @@ -106,16 +110,12 @@ export function Application(): VNode { { - route(Pages.backup_provider_add); - }} + onAddProvider={() => redirectTo(Pages.backup_provider_add)} /> { - route(Pages.backup); - }} + onBack={() => redirectTo(Pages.backup)} /> { + route(location); +} + function Redirect({ to }: { to: string }): null { useEffect(() => { route(to, true); diff --git a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx index 966782bbe..ea202681c 100644 --- a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx +++ b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx @@ -22,17 +22,17 @@ import { JustInDevMode } from "../components/JustInDevMode.js"; import { Loading } from "../components/Loading.js"; import { LoadingError } from "../components/LoadingError.js"; import { MultiActionButton } from "../components/MultiActionButton.js"; -import { ButtonBoxPrimary, ButtonPrimary } from "../components/styled/index.js"; import { useTranslationContext } from "../context/translation.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; +import { Button } from "../mui/Button.js"; import { AddNewActionView } from "../wallet/AddNewActionView.js"; import * as wxApi from "../wxApi.js"; import { NoBalanceHelp } from "./NoBalanceHelp.js"; export interface Props { - goToWalletDeposit: (currency: string) => void; - goToWalletHistory: (currency: string) => void; - goToWalletManualWithdraw: () => void; + goToWalletDeposit: (currency: string) => Promise; + goToWalletHistory: (currency: string) => Promise; + goToWalletManualWithdraw: () => Promise; } export function BalancePage({ goToWalletManualWithdraw, @@ -65,7 +65,7 @@ export function BalancePage({ } if (addingAction) { - return setAddingAction(false)} />; + return setAddingAction(false)} />; } return ( @@ -74,16 +74,16 @@ export function BalancePage({ goToWalletManualWithdraw={goToWalletManualWithdraw} goToWalletDeposit={goToWalletDeposit} goToWalletHistory={goToWalletHistory} - goToAddAction={() => setAddingAction(true)} + goToAddAction={async () => setAddingAction(true)} /> ); } export interface BalanceViewProps { balances: Balance[]; - goToWalletManualWithdraw: () => void; - goToAddAction: () => void; - goToWalletDeposit: (currency: string) => void; - goToWalletHistory: (currency: string) => void; + goToWalletManualWithdraw: () => Promise; + goToAddAction: () => Promise; + goToWalletDeposit: (currency: string) => Promise; + goToWalletHistory: (currency: string) => Promise; } export function BalanceView({ @@ -113,22 +113,20 @@ export function BalanceView({ />
- + {currencyWithNonZeroAmount.length > 0 && ( ( - Deposit {{s}} - )} + label={(s) => Deposit {s}} actions={currencyWithNonZeroAmount} onClick={(c) => goToWalletDeposit(c)} /> )} - +
diff --git a/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx b/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx index ddce93cd8..20f44b5dc 100644 --- a/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx +++ b/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx @@ -8,7 +8,7 @@ import { Typography } from "../mui/Typography.js"; export function NoBalanceHelp({ goToWalletManualWithdraw, }: { - goToWalletManualWithdraw: () => void; + goToWalletManualWithdraw: () => Promise; }): VNode { return ( void; + onDismiss: () => Promise; } export function TalerActionFound({ url, onDismiss }: Props): VNode { const uriType = classifyTalerUri(url); const { i18n } = useTranslationContext(); - function redirectToWallet(): void { + async function redirectToWallet(): Promise { platform.openWalletURIFromPopup(url); } return ( @@ -51,9 +52,13 @@ export function TalerActionFound({ url, onDismiss }: Props): VNode {

This page has pay action.

- + )} {uriType === TalerUriType.TalerWithdraw && ( @@ -63,9 +68,13 @@ export function TalerActionFound({ url, onDismiss }: Props): VNode { This page has a withdrawal action.

- + )} {uriType === TalerUriType.TalerTip && ( @@ -73,9 +82,13 @@ export function TalerActionFound({ url, onDismiss }: Props): VNode {

This page has a tip action.

- + )} {uriType === TalerUriType.TalerNotifyReserve && ( @@ -85,9 +98,13 @@ export function TalerActionFound({ url, onDismiss }: Props): VNode { This page has a notify reserve action.

- + )} {uriType === TalerUriType.TalerRefund && ( @@ -95,9 +112,13 @@ export function TalerActionFound({ url, onDismiss }: Props): VNode {

This page has a refund action.

- + )} {uriType === TalerUriType.Unknown && ( @@ -113,10 +134,9 @@ export function TalerActionFound({ url, onDismiss }: Props): VNode { ); -- cgit v1.2.3