aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/components/TermsOfService/state.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-02-28 11:48:51 -0300
committerSebastian <sebasjm@gmail.com>2024-02-28 11:48:51 -0300
commit69e59db2f992878b9e166bba61071fd63499a370 (patch)
tree2d60c0a136ec6319043de1281b470fbf222700c8 /packages/taler-wallet-webextension/src/components/TermsOfService/state.ts
parent6dd011d2f6092b1fb8eee16eb5f026faf07b802f (diff)
downloadwallet-core-69e59db2f992878b9e166bba61071fd63499a370.tar.xz
allow selecting format in devmode
Diffstat (limited to 'packages/taler-wallet-webextension/src/components/TermsOfService/state.ts')
-rw-r--r--packages/taler-wallet-webextension/src/components/TermsOfService/state.ts23
1 files changed, 20 insertions, 3 deletions
diff --git a/packages/taler-wallet-webextension/src/components/TermsOfService/state.ts b/packages/taler-wallet-webextension/src/components/TermsOfService/state.ts
index 88d97af81..46df71523 100644
--- a/packages/taler-wallet-webextension/src/components/TermsOfService/state.ts
+++ b/packages/taler-wallet-webextension/src/components/TermsOfService/state.ts
@@ -16,13 +16,21 @@
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { useTranslationContext } from "@gnu-taler/web-util/browser";
-import { useState, useEffect } from "preact/hooks";
+import { useState } from "preact/hooks";
import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { Props, State } from "./index.js";
import { buildTermsOfServiceState } from "./utils.js";
+const supportedFormats = {
+ "text/html": "HTML",
+ "text/xml" : "XML",
+ "text/markdown" : "Markdown",
+ "text/plain" : "Plain text",
+ "text/pdf" : "PDF",
+}
+
export function useComponentState({ showEvenIfaccepted, exchangeUrl, readOnly, children }: Props): State {
const api = useBackendContext();
const [showContent, setShowContent] = useState<boolean>(!!readOnly);
@@ -30,6 +38,8 @@ export function useComponentState({ showEvenIfaccepted, exchangeUrl, readOnly, c
const [tosLang, setTosLang] = useState<string>()
const { pushAlertOnError } = useAlertContext();
+ const [format, setFormat] = useState("text/html")
+
const acceptedLang = tosLang ?? lang
/**
* For the exchange selected, bring the status of the terms of service
@@ -39,7 +49,7 @@ export function useComponentState({ showEvenIfaccepted, exchangeUrl, readOnly, c
WalletApiOperation.GetExchangeTos,
{
exchangeBaseUrl: exchangeUrl,
- acceptedFormat: ["text/xml"],
+ acceptedFormat: [format],
acceptLanguage: acceptedLang,
},
);
@@ -52,7 +62,7 @@ export function useComponentState({ showEvenIfaccepted, exchangeUrl, readOnly, c
const state = buildTermsOfServiceState(exchangeTos);
return { state, supportedLangs };
- }, [acceptedLang]);
+ }, [acceptedLang, format]);
if (!terms) {
return {
@@ -124,6 +134,13 @@ export function useComponentState({ showEvenIfaccepted, exchangeUrl, readOnly, c
terms: state,
showingTermsOfService: readOnly ? undefined : base.showingTermsOfService,
termsAccepted: base.termsAccepted,
+ tosFormat: {
+ onChange: pushAlertOnError(async (s) => {
+ setFormat(s)
+ }),
+ list: supportedFormats,
+ value: format ?? ""
+ },
tosLang: {
onChange: pushAlertOnError(async (s) => {
setTosLang(s)