diff options
author | Sebastian <sebasjm@gmail.com> | 2023-11-30 11:08:56 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-11-30 11:08:56 -0300 |
commit | 7b62d04f2c3fec5ee1a67650da4b4087cae7b4dd (patch) | |
tree | 326ea9ed4855044950c6abe3c37f32e16121b176 | |
parent | d5a46a3bc4025d9c2abd2d73831bf033272f174d (diff) | |
download | wallet-core-7b62d04f2c3fec5ee1a67650da4b4087cae7b4dd.tar.gz wallet-core-7b62d04f2c3fec5ee1a67650da4b4087cae7b4dd.tar.bz2 wallet-core-7b62d04f2c3fec5ee1a67650da4b4087cae7b4dd.zip |
alt currency WIP
4 files changed, 56 insertions, 3 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts index f80e5a648..3dc2b7f3d 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts @@ -18,6 +18,7 @@ import { AmountJson, AmountString, ExchangeListItem, + WithdrawalExchangeAccountDetails, } from "@gnu-taler/taler-util"; import { Loading } from "../../components/Loading.js"; import { State as SelectExchangeState } from "../../hooks/useSelectedExchange.js"; @@ -91,6 +92,7 @@ export namespace State { doWithdrawal: ButtonHandler; doSelectExchange: ButtonHandler; + accounts: WithdrawalExchangeAccountDetails[]; ageRestriction?: SelectFieldHandler; diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts index a3855c2f4..46d221766 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts @@ -324,10 +324,11 @@ function exchangeSelectionState( raw: Amounts.parseOrThrow(info.amountRaw), effective: Amounts.parseOrThrow(info.amountEffective), }; - + return { amount: withdrawAmount, ageRestrictionOptions: info.ageRestrictionOptions, + accounts: info.withdrawalAccountList }; }, []); @@ -335,7 +336,7 @@ function exchangeSelectionState( undefined, ); const [doingWithdraw, setDoingWithdraw] = useState<boolean>(false); - + async function doWithdrawAndCheckError(): Promise<void> { try { setDoingWithdraw(true); @@ -406,6 +407,7 @@ function exchangeSelectionState( doSelectExchange: selectedExchange.doSelect, currentExchange, toBeReceived, + accounts: amountHook.response.accounts, withdrawalFee, chosenAmount, talerWithdrawUri, diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/stories.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw/stories.tsx index 29f7e0a30..df70a5c95 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/stories.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/stories.tsx @@ -64,6 +64,7 @@ export const TermsOfServiceNotYetLoaded = tests.createExample(SuccessView, { fraction: 0, value: 1, }, + accounts: [], }); export const WithSomeFee = tests.createExample(SuccessView, { @@ -90,6 +91,7 @@ export const WithSomeFee = tests.createExample(SuccessView, { value: 1, }, doSelectExchange: {}, + accounts: [], }); export const WithoutFee = tests.createExample(SuccessView, { @@ -116,6 +118,7 @@ export const WithoutFee = tests.createExample(SuccessView, { fraction: 0, value: 2, }, + accounts: [], }); export const EditExchangeUntouched = tests.createExample(SuccessView, { @@ -142,6 +145,7 @@ export const EditExchangeUntouched = tests.createExample(SuccessView, { fraction: 0, value: 2, }, + accounts: [], }); export const EditExchangeModified = tests.createExample(SuccessView, { @@ -168,6 +172,7 @@ export const EditExchangeModified = tests.createExample(SuccessView, { fraction: 0, value: 2, }, + accounts: [], }); export const WithAgeRestriction = tests.createExample(SuccessView, { @@ -195,4 +200,32 @@ export const WithAgeRestriction = tests.createExample(SuccessView, { fraction: 0, value: 2, }, + accounts: [], +}); + +export const WithAlternateCurrencies = tests.createExample(SuccessView, { + error: undefined, + status: "success", + chosenAmount: { + currency: "USD", + value: 2, + fraction: 10000000, + }, + accounts: [], + doWithdrawal: { onClick: nullFunction }, + currentExchange: { + exchangeBaseUrl: "https://exchange.demo.taler.net", + tos: {}, + } as Partial<ExchangeListItem> as any, + withdrawalFee: { + currency: "USD", + fraction: 10000000, + value: 1, + }, + doSelectExchange: {}, + toBeReceived: { + currency: "USD", + fraction: 0, + value: 1, + }, }); diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx index 8a01edaaf..aa8b58707 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx @@ -39,7 +39,8 @@ export function SuccessView(state: State.Success): VNode { const { i18n } = useTranslationContext(); const currentTosVersionIsAccepted = state.currentExchange.tosStatus === ExchangeTosStatus.Accepted; - return ( + const altCurrencies = state.accounts.filter(a => !!a.currencySpecification).map(a => a.currencySpecification!.name) + return ( <Fragment> <section style={{ textAlign: "left" }}> <Part @@ -66,6 +67,21 @@ export function SuccessView(state: State.Success): VNode { kind="neutral" big /> + <p> + This exchange allows alternative currency + </p> + <p> + <Button + variant="outlined" + > + EUR + </Button> + <Button + variant="outlined" + > + ARS + </Button> + </p> <Part title={i18n.str`Details`} text={ |