aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-10-14 11:40:38 -0300
committerSebastian <sebasjm@gmail.com>2022-10-14 11:41:53 -0300
commitda9ec5eb16298d8ca5690800eca1c15f5a6cfaa5 (patch)
tree56b637054c94462cada2a067cfb7cce46fefe651 /packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
parentca8da4ed380b308abdc894145c7e1a102bfd6cf0 (diff)
downloadwallet-core-da9ec5eb16298d8ca5690800eca1c15f5a6cfaa5.tar.xz
refactored terms of service to remove duplicated code
prettfied some sources
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx')
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx79
1 files changed, 34 insertions, 45 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
index 1e8284739..44c7db83f 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
@@ -15,30 +15,28 @@
*/
import { Fragment, h, VNode } from "preact";
+import { useState } from "preact/hooks";
+import { Amount } from "../../components/Amount.js";
import { ErrorTalerOperation } from "../../components/ErrorTalerOperation.js";
import { LoadingError } from "../../components/LoadingError.js";
import { LogoHeader } from "../../components/LogoHeader.js";
import { Part } from "../../components/Part.js";
+import { QR } from "../../components/QR.js";
import { SelectList } from "../../components/SelectList.js";
import {
Input,
Link,
LinkSuccess,
SubTitle,
- SuccessBox,
SvgIcon,
WalletAction,
} from "../../components/styled/index.js";
import { useTranslationContext } from "../../context/translation.js";
import { Button } from "../../mui/Button.js";
+import editIcon from "../../svg/edit_24px.svg";
import { ExchangeDetails, WithdrawDetails } from "../../wallet/Transaction.js";
-import { TermsOfServiceSection } from "../TermsOfServiceSection.js";
+import { TermsOfService } from "../TermsOfService/index.js";
import { State } from "./index.js";
-import editIcon from "../../svg/edit_24px.svg";
-import { Amount } from "../../components/Amount.js";
-import { QR } from "../../components/QR.js";
-import { useState } from "preact/hooks";
-import { ErrorMessage } from "../../components/ErrorMessage.js";
export function LoadingUriView({ error }: State.LoadingUriError): VNode {
const { i18n } = useTranslationContext();
@@ -66,6 +64,9 @@ export function LoadingInfoView({ error }: State.LoadingInfoError): VNode {
export function SuccessView(state: State.Success): VNode {
const { i18n } = useTranslationContext();
+ const currentTosVersionIsAccepted =
+ state.currentExchange.tos.acceptedVersion ===
+ state.currentExchange.tos.currentVersion;
return (
<WalletAction>
<LogoHeader />
@@ -103,7 +104,9 @@ export function SuccessView(state: State.Success): VNode {
</Button>
</div>
}
- text={<ExchangeDetails exchange={state.exchangeUrl} />}
+ text={
+ <ExchangeDetails exchange={state.currentExchange.exchangeBaseUrl} />
+ }
kind="neutral"
big
/>
@@ -130,43 +133,29 @@ export function SuccessView(state: State.Success): VNode {
</Input>
)}
</section>
- {state.tosProps && <TermsOfServiceSection {...state.tosProps} />}
- {state.tosProps ? (
- <Fragment>
- <section>
- {(state.tosProps.terms.status === "accepted" ||
- (state.mustAcceptFirst && state.tosProps.reviewed)) && (
- <Button
- variant="contained"
- color="success"
- disabled={!state.doWithdrawal.onClick}
- onClick={state.doWithdrawal.onClick}
- >
- <i18n.Translate>
- Withdraw &nbsp; <Amount value={state.toBeReceived} />
- </i18n.Translate>
- </Button>
- )}
- {state.tosProps.terms.status === "notfound" && (
- <Button
- variant="contained"
- color="warning"
- disabled={!state.doWithdrawal.onClick}
- onClick={state.doWithdrawal.onClick}
- >
- <i18n.Translate>Withdraw anyway</i18n.Translate>
- </Button>
- )}
- </section>
- {state.talerWithdrawUri ? (
- <WithdrawWithMobile talerWithdrawUri={state.talerWithdrawUri} />
- ) : undefined}
- </Fragment>
- ) : (
- <section>
- <i18n.Translate>Loading terms of service...</i18n.Translate>
- </section>
- )}
+
+ <section>
+ {currentTosVersionIsAccepted ? (
+ <Button
+ variant="contained"
+ color="success"
+ disabled={!state.doWithdrawal.onClick}
+ onClick={state.doWithdrawal.onClick}
+ >
+ <i18n.Translate>
+ Withdraw &nbsp; <Amount value={state.toBeReceived} />
+ </i18n.Translate>
+ </Button>
+ ) : (
+ <TermsOfService
+ exchangeUrl={state.currentExchange.exchangeBaseUrl}
+ onChange={state.onTosUpdate}
+ />
+ )}
+ </section>
+ {state.talerWithdrawUri ? (
+ <WithdrawWithMobile talerWithdrawUri={state.talerWithdrawUri} />
+ ) : undefined}
<section>
<Link upperCased onClick={state.cancel}>
<i18n.Translate>Cancel</i18n.Translate>