summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx')
-rw-r--r--packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx233
1 files changed, 117 insertions, 116 deletions
diff --git a/packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx b/packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx
index a7e03fd01..40cfba3bc 100644
--- a/packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx
+++ b/packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx
@@ -14,78 +14,58 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+import { ExchangeTosStatus } from "@gnu-taler/taler-util";
+import { useTranslationContext } from "@gnu-taler/web-util/browser";
import { Fragment, h, VNode } from "preact";
-import { LoadingError } from "../../components/LoadingError.js";
-import { useTranslationContext } from "../../context/translation.js";
-import { TermsDocument, TermsState } from "./utils.js";
-import { State } from "./index.js";
import { CheckboxOutlined } from "../../components/CheckboxOutlined.js";
+import { ExchangeXmlTos } from "../../components/ExchangeToS.js";
import {
+ Input,
LinkSuccess,
- TermsOfService,
- WarningBox,
- WarningText,
+ TermsOfServiceStyle,
+ WarningBox
} from "../../components/styled/index.js";
-import { ExchangeXmlTos } from "../../components/ExchangeToS.js";
-import { ToggleHandler } from "../../mui/handlers.js";
import { Button } from "../../mui/Button.js";
-import { ExchangeTosStatus } from "@gnu-taler/taler-util";
-
-export function LoadingUriView({ error }: State.LoadingUriError): VNode {
- const { i18n } = useTranslationContext();
-
- return (
- <LoadingError
- title={<i18n.Translate>Could not load</i18n.Translate>}
- error={error}
- />
- );
-}
-
-export function ErrorAcceptingView({ error }: State.ErrorAccepting): VNode {
- const { i18n } = useTranslationContext();
-
- return (
- <LoadingError
- title={<i18n.Translate>Could not load</i18n.Translate>}
- error={error}
- />
- );
-}
+import { State } from "./index.js";
+import { SelectList } from "../SelectList.js";
+import { EnabledBySettings } from "../EnabledBySettings.js";
export function ShowButtonsAcceptedTosView({
termsAccepted,
showingTermsOfService,
- terms,
+ children,
}: State.ShowButtonsAccepted): VNode {
const { i18n } = useTranslationContext();
- const ableToReviewTermsOfService =
- showingTermsOfService.button.onClick !== undefined;
return (
<Fragment>
- {ableToReviewTermsOfService && (
- <section style={{ justifyContent: "space-around", display: "flex" }}>
- <LinkSuccess
- upperCased
- onClick={showingTermsOfService.button.onClick}
- >
- <i18n.Translate>Show terms of service</i18n.Translate>
- </LinkSuccess>
- </section>
+ {showingTermsOfService.button.onClick !== undefined && (
+ <Fragment>
+ <section style={{ justifyContent: "space-around", display: "flex" }}>
+ <LinkSuccess
+ upperCased
+ onClick={showingTermsOfService.button.onClick}
+ >
+ <i18n.Translate>Show terms of service</i18n.Translate>
+ </LinkSuccess>
+ </section>
+ {termsAccepted.button.onClick !== undefined && (
+ <section style={{ justifyContent: "space-around", display: "flex" }}>
+ <CheckboxOutlined
+ name="terms"
+ enabled={termsAccepted.value}
+ label={
+ <i18n.Translate>
+ I accept the exchange terms of service
+ </i18n.Translate>
+ }
+ onToggle={termsAccepted.button.onClick}
+ />
+ </section>
+ )}
+ </Fragment>
)}
- <section style={{ justifyContent: "space-around", display: "flex" }}>
- <CheckboxOutlined
- name="terms"
- enabled={termsAccepted.value}
- label={
- <i18n.Translate>
- I accept the exchange terms of service
- </i18n.Translate>
- }
- onToggle={termsAccepted.button.onClick}
- />
- </section>
+ {children}
</Fragment>
);
}
@@ -95,28 +75,28 @@ export function ShowButtonsNonAcceptedTosView({
terms,
}: State.ShowButtonsNotAccepted): VNode {
const { i18n } = useTranslationContext();
- const ableToReviewTermsOfService =
- showingTermsOfService.button.onClick !== undefined;
+ // const ableToReviewTermsOfService =
+ // showingTermsOfService.button.onClick !== undefined;
- if (!ableToReviewTermsOfService) {
- return (
- <Fragment>
- {terms.status === ExchangeTosStatus.NotFound && (
- <section style={{ justifyContent: "space-around", display: "flex" }}>
- <WarningText>
- <i18n.Translate>
- Exchange doesn&apos;t have terms of service
- </i18n.Translate>
- </WarningText>
- </section>
- )}
- </Fragment>
- );
- }
+ // if (!ableToReviewTermsOfService) {
+ // return (
+ // <Fragment>
+ // {terms.status === ExchangeTosStatus.Pending && (
+ // <section style={{ justifyContent: "space-around", display: "flex" }}>
+ // <WarningText>
+ // <i18n.Translate>
+ // Exchange doesn&apos;t have terms of service
+ // </i18n.Translate>
+ // </WarningText>
+ // </section>
+ // )}
+ // </Fragment>
+ // );
+ // }
return (
<Fragment>
- {terms.status === ExchangeTosStatus.NotFound && (
+ {/* {terms.status === ExchangeTosStatus.NotFound && (
<section style={{ justifyContent: "space-around", display: "flex" }}>
<WarningText>
<i18n.Translate>
@@ -124,31 +104,16 @@ export function ShowButtonsNonAcceptedTosView({
</i18n.Translate>
</WarningText>
</section>
- )}
- {terms.status === "new" && (
- <section style={{ justifyContent: "space-around", display: "flex" }}>
- <Button
- variant="contained"
- color="success"
- onClick={showingTermsOfService.button.onClick}
- >
- <i18n.Translate>Review exchange terms of service</i18n.Translate>
- </Button>
- </section>
- )}
- {terms.status === "changed" && (
- <section style={{ justifyContent: "space-around", display: "flex" }}>
- <Button
- variant="contained"
- color="success"
- onClick={showingTermsOfService.button.onClick}
- >
- <i18n.Translate>
- Review new version of terms of service
- </i18n.Translate>
- </Button>
- </section>
- )}
+ )} */}
+ <section style={{ justifyContent: "space-around", display: "flex" }}>
+ <Button
+ variant="contained"
+ color="success"
+ onClick={showingTermsOfService.button.onClick}
+ >
+ <i18n.Translate>Review exchange terms of service</i18n.Translate>
+ </Button>
+ </section>
</Fragment>
);
}
@@ -157,36 +122,72 @@ export function ShowTosContentView({
termsAccepted,
showingTermsOfService,
terms,
+ tosLang,
+ tosFormat,
}: State.ShowContent): VNode {
const { i18n } = useTranslationContext();
const ableToReviewTermsOfService =
- showingTermsOfService?.button.onClick !== undefined;
+ termsAccepted.button.onClick !== undefined;
return (
- <Fragment>
- {terms.status !== ExchangeTosStatus.NotFound && !terms.content && (
+ <section>
+ <Input style={{ display: "flex", justifyContent: "end" }}>
+ <EnabledBySettings name="selectTosFormat">
+ <SelectList
+ label={i18n.str`Format`}
+ list={tosFormat.list}
+ name="format"
+ value={tosFormat.value}
+ onChange={tosFormat.onChange}
+ />
+ </EnabledBySettings>
+ <SelectList
+ label={i18n.str`Language`}
+ list={tosLang.list}
+ name="lang"
+ value={tosLang.value}
+ onChange={tosLang.onChange}
+ />
+ </Input>
+
+ {!terms.content && (
<section style={{ justifyContent: "space-around", display: "flex" }}>
<WarningBox>
<i18n.Translate>
- The exchange reply with a empty terms of service
+ The exchange replied with a empty terms of service
</i18n.Translate>
</WarningBox>
</section>
)}
{terms.content && (
<section style={{ justifyContent: "space-around", display: "flex" }}>
- {terms.content.type === "xml" && (
- <TermsOfService>
- <ExchangeXmlTos doc={terms.content.document} />
- </TermsOfService>
- )}
- {terms.content.type === "plain" && (
- <div style={{ textAlign: "left" }}>
- <pre>{terms.content.content}</pre>
- </div>
- )}
+ {terms.content.type === "xml" &&
+ (!terms.content.document ? (
+ <WarningBox>
+ <i18n.Translate>
+ No terms of service. The exchange replied with a empty
+ document
+ </i18n.Translate>
+ </WarningBox>
+ ) : (
+ <TermsOfServiceStyle>
+ <ExchangeXmlTos doc={terms.content.document} />
+ </TermsOfServiceStyle>
+ ))}
+ {terms.content.type === "plain" &&
+ (!terms.content.content ? (
+ <WarningBox>
+ <i18n.Translate>
+ No terms of service. The exchange replied with a empty text
+ </i18n.Translate>
+ </WarningBox>
+ ) : (
+ <div style={{ textAlign: "left" }}>
+ <pre>{terms.content.content}</pre>
+ </div>
+ ))}
{terms.content.type === "html" && (
- <iframe src={terms.content.href.toString()} />
+ <iframe style={{ width: "100%" }} srcDoc={terms.content.html} />
)}
{terms.content.type === "pdf" && (
<a href={terms.content.location.toString()} download="tos.pdf">
@@ -205,7 +206,7 @@ export function ShowTosContentView({
</LinkSuccess>
</section>
)}
- {termsAccepted && terms.status !== ExchangeTosStatus.NotFound && (
+ {termsAccepted.button.onClick && terms.status !== ExchangeTosStatus.Accepted && (
<section style={{ justifyContent: "space-around", display: "flex" }}>
<CheckboxOutlined
name="terms"
@@ -219,6 +220,6 @@ export function ShowTosContentView({
/>
</section>
)}
- </Fragment>
+ </section>
);
}