diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/components')
-rw-r--r-- | packages/taler-wallet-webextension/src/components/TermsOfService/utils.ts | 27 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx | 9 |
2 files changed, 8 insertions, 28 deletions
diff --git a/packages/taler-wallet-webextension/src/components/TermsOfService/utils.ts b/packages/taler-wallet-webextension/src/components/TermsOfService/utils.ts index 5766883ae..a106c3d85 100644 --- a/packages/taler-wallet-webextension/src/components/TermsOfService/utils.ts +++ b/packages/taler-wallet-webextension/src/components/TermsOfService/utils.ts @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { GetExchangeTosResult } from "@gnu-taler/taler-util"; +import { ExchangeTosStatus, GetExchangeTosResult } from "@gnu-taler/taler-util"; export function buildTermsOfServiceState( tos: GetExchangeTosResult, @@ -24,26 +24,7 @@ export function buildTermsOfServiceState( tos.content, ); - const status: TermsStatus = buildTermsOfServiceStatus( - tos.content, - tos.acceptedEtag, - tos.currentEtag, - ); - - return { content, status, version: tos.currentEtag }; -} -export function buildTermsOfServiceStatus( - content: string | undefined, - acceptedVersion: string | undefined, - currentVersion: string | undefined, -): TermsStatus { - return !content - ? "notfound" - : !acceptedVersion - ? "new" - : acceptedVersion !== currentVersion - ? "changed" - : "accepted"; + return { content, status: tos.tosStatus, version: tos.currentEtag }; } function parseTermsOfServiceContent( @@ -91,12 +72,10 @@ function parseTermsOfServiceContent( export type TermsState = { content: TermsDocument | undefined; - status: TermsStatus; + status: ExchangeTosStatus; version: string; }; -type TermsStatus = "new" | "accepted" | "changed" | "notfound"; - export type TermsDocument = | TermsDocumentXml | TermsDocumentHtml diff --git a/packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx b/packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx index c7f8ccb78..a7e03fd01 100644 --- a/packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx +++ b/packages/taler-wallet-webextension/src/components/TermsOfService/views.tsx @@ -29,6 +29,7 @@ import { 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(); @@ -100,7 +101,7 @@ export function ShowButtonsNonAcceptedTosView({ if (!ableToReviewTermsOfService) { return ( <Fragment> - {terms.status === "notfound" && ( + {terms.status === ExchangeTosStatus.NotFound && ( <section style={{ justifyContent: "space-around", display: "flex" }}> <WarningText> <i18n.Translate> @@ -115,7 +116,7 @@ export function ShowButtonsNonAcceptedTosView({ return ( <Fragment> - {terms.status === "notfound" && ( + {terms.status === ExchangeTosStatus.NotFound && ( <section style={{ justifyContent: "space-around", display: "flex" }}> <WarningText> <i18n.Translate> @@ -163,7 +164,7 @@ export function ShowTosContentView({ return ( <Fragment> - {terms.status !== "notfound" && !terms.content && ( + {terms.status !== ExchangeTosStatus.NotFound && !terms.content && ( <section style={{ justifyContent: "space-around", display: "flex" }}> <WarningBox> <i18n.Translate> @@ -204,7 +205,7 @@ export function ShowTosContentView({ </LinkSuccess> </section> )} - {termsAccepted && terms.status !== "notfound" && ( + {termsAccepted && terms.status !== ExchangeTosStatus.NotFound && ( <section style={{ justifyContent: "space-around", display: "flex" }}> <CheckboxOutlined name="terms" |