summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wallet
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2021-10-11 15:59:55 -0300
committerSebastian <sebasjm@gmail.com>2021-10-11 15:59:55 -0300
commitbe8e3f4b1d090a536967f132a7fd4742bbcd5343 (patch)
treed184ba3cf40510009e4121c6daa5653e0be475b0 /packages/taler-wallet-webextension/src/wallet
parent78fb5f79a8690ee490c96b271dadd37f4c9442d6 (diff)
downloadwallet-core-be8e3f4b1d090a536967f132a7fd4742bbcd5343.tar.gz
wallet-core-be8e3f4b1d090a536967f132a7fd4742bbcd5343.tar.bz2
wallet-core-be8e3f4b1d090a536967f132a7fd4742bbcd5343.zip
fixing withdrawal process
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet')
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Balance.stories.tsx11
-rw-r--r--packages/taler-wallet-webextension/src/wallet/BalancePage.tsx2
-rw-r--r--packages/taler-wallet-webextension/src/wallet/History.tsx2
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Settings.tsx49
4 files changed, 35 insertions, 29 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/Balance.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Balance.stories.tsx
index 1b145345f..cccda203e 100644
--- a/packages/taler-wallet-webextension/src/wallet/Balance.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Balance.stories.tsx
@@ -35,14 +35,15 @@ export const NotYetLoaded = createExample(TestedComponent, {
export const GotError = createExample(TestedComponent, {
balance: {
- error: true
+ hasError: true,
+ message: 'Network error'
},
Linker: NullLink,
});
export const EmptyBalance = createExample(TestedComponent, {
balance: {
- error: false,
+ hasError: false,
response: {
balances: []
},
@@ -52,7 +53,7 @@ export const EmptyBalance = createExample(TestedComponent, {
export const SomeCoins = createExample(TestedComponent, {
balance: {
- error: false,
+ hasError: false,
response: {
balances: [{
available: 'USD:10.5',
@@ -68,7 +69,7 @@ export const SomeCoins = createExample(TestedComponent, {
export const SomeCoinsAndIncomingMoney = createExample(TestedComponent, {
balance: {
- error: false,
+ hasError: false,
response: {
balances: [{
available: 'USD:2.23',
@@ -84,7 +85,7 @@ export const SomeCoinsAndIncomingMoney = createExample(TestedComponent, {
export const SomeCoinsInTwoCurrencies = createExample(TestedComponent, {
balance: {
- error: false,
+ hasError: false,
response: {
balances: [{
available: 'USD:2',
diff --git a/packages/taler-wallet-webextension/src/wallet/BalancePage.tsx b/packages/taler-wallet-webextension/src/wallet/BalancePage.tsx
index e06e884ce..eb5a0447c 100644
--- a/packages/taler-wallet-webextension/src/wallet/BalancePage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/BalancePage.tsx
@@ -41,7 +41,7 @@ export function BalanceView({ balance, Linker, goToWalletManualWithdraw }: Balan
return <span />
}
- if (balance.error) {
+ if (balance.hasError) {
return (
<div>
<p>{i18n.str`Error: could not retrieve balance information.`}</p>
diff --git a/packages/taler-wallet-webextension/src/wallet/History.tsx b/packages/taler-wallet-webextension/src/wallet/History.tsx
index 2bb59fcdb..43b0a6630 100644
--- a/packages/taler-wallet-webextension/src/wallet/History.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/History.tsx
@@ -29,7 +29,7 @@ export function HistoryPage(props: any): JSX.Element {
TransactionsResponse | undefined
>(undefined);
const balance = useBalances()
- const balanceWithoutError = balance?.error ? [] : (balance?.response.balances || [])
+ const balanceWithoutError = balance?.hasError ? [] : (balance?.response.balances || [])
useEffect(() => {
const fetchData = async (): Promise<void> => {
diff --git a/packages/taler-wallet-webextension/src/wallet/Settings.tsx b/packages/taler-wallet-webextension/src/wallet/Settings.tsx
index 52e72ee2f..d1eb012fc 100644
--- a/packages/taler-wallet-webextension/src/wallet/Settings.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Settings.tsx
@@ -15,23 +15,29 @@
*/
-import { i18n } from "@gnu-taler/taler-util";
-import { VNode, h } from "preact";
+import { ExchangeListItem, i18n } from "@gnu-taler/taler-util";
+import { VNode, h, Fragment } from "preact";
import { Checkbox } from "../components/Checkbox";
import { EditableText } from "../components/EditableText";
import { SelectList } from "../components/SelectList";
+import { ButtonPrimary, ButtonSuccess, WalletBox } from "../components/styled";
import { useDevContext } from "../context/devContext";
import { useBackupDeviceName } from "../hooks/useBackupDeviceName";
import { useExtendedPermissions } from "../hooks/useExtendedPermissions";
+import { useAsyncAsHook } from "../hooks/useAsyncAsHook";
import { useLang } from "../hooks/useLang";
+import * as wxApi from "../wxApi";
export function SettingsPage(): VNode {
const [permissionsEnabled, togglePermissions] = useExtendedPermissions();
const { devMode, toggleDevMode } = useDevContext()
const { name, update } = useBackupDeviceName()
const [lang, changeLang] = useLang()
+ const exchangesHook = useAsyncAsHook(() => wxApi.listExchanges());
+
return <SettingsView
lang={lang} changeLang={changeLang}
+ knownExchanges={!exchangesHook || exchangesHook.hasError ? [] : exchangesHook.response.exchanges}
deviceName={name} setDeviceName={update}
permissionsEnabled={permissionsEnabled} togglePermissions={togglePermissions}
developerMode={devMode} toggleDeveloperMode={toggleDevMode}
@@ -47,6 +53,7 @@ export interface ViewProps {
togglePermissions: () => void;
developerMode: boolean;
toggleDeveloperMode: () => void;
+ knownExchanges: Array<ExchangeListItem>;
}
import { strings as messages } from '../i18n/strings'
@@ -65,26 +72,24 @@ const names: LangsNames = {
}
-export function SettingsView({ lang, changeLang, deviceName, setDeviceName, permissionsEnabled, togglePermissions, developerMode, toggleDeveloperMode }: ViewProps): VNode {
+export function SettingsView({ knownExchanges, lang, changeLang, deviceName, setDeviceName, permissionsEnabled, togglePermissions, developerMode, toggleDeveloperMode }: ViewProps): VNode {
return (
- <div>
- <section style={{ height: 300, overflow: 'auto' }}>
- <h2><i18n.Translate>Wallet</i18n.Translate></h2>
- <SelectList
- value={lang}
- onChange={changeLang}
- name="lang"
- list={names}
- label={i18n.str`Language`}
- description="(Choose your preferred lang)"
- />
- <EditableText
- value={deviceName}
- onChange={setDeviceName}
- name="device-id"
- label={i18n.str`Device name`}
- description="(This is how you will recognize the wallet in the backup provider)"
- />
+ <WalletBox>
+ <section>
+
+ <h2><i18n.Translate>Known exchanges</i18n.Translate></h2>
+ {!knownExchanges || !knownExchanges.length ? <div>
+ No exchange yet!
+ </div> :
+ <dl>
+ {knownExchanges.map(e => <Fragment>
+ <dt>{e.currency}</dt>
+ <dd>{e.exchangeBaseUrl}</dd>
+ <dd>{e.paytoUris}</dd>
+ </Fragment>)}
+ </dl>
+ }
+ <ButtonPrimary>add exchange</ButtonPrimary>
<h2><i18n.Translate>Permissions</i18n.Translate></h2>
<Checkbox label="Automatically open wallet based on page content"
name="perm"
@@ -98,6 +103,6 @@ export function SettingsView({ lang, changeLang, deviceName, setDeviceName, perm
enabled={developerMode} onToggle={toggleDeveloperMode}
/>
</section>
- </div>
+ </WalletBox>
)
} \ No newline at end of file