2023-02-25 18:11:23 +01:00
|
|
|
import React, { useEffect } from "react";
|
|
|
|
import { memoize } from "../tools/memoize";
|
2022-10-16 00:49:49 +02:00
|
|
|
import { clsx } from "../tools/clsx";
|
2022-07-31 18:57:30 +02:00
|
|
|
import { Evt } from "evt";
|
|
|
|
import { useRerenderOnStateChange } from "evt/hooks";
|
2022-07-31 22:30:32 +02:00
|
|
|
import { assert } from "tsafe/assert";
|
|
|
|
import { fallbackLanguageTag } from "../i18n";
|
2023-02-25 18:11:23 +01:00
|
|
|
import { useConst } from "../tools/useConst";
|
|
|
|
import { useConstCallback } from "../tools/useConstCallback";
|
2022-09-09 17:24:43 +02:00
|
|
|
import { Markdown } from "../tools/Markdown";
|
2022-10-13 11:58:31 +02:00
|
|
|
import type { Extends } from "tsafe";
|
2023-02-25 18:26:39 +01:00
|
|
|
import type { PageProps } from "../KcProps";
|
2023-03-16 23:02:06 +01:00
|
|
|
import type { KcContextBase } from "../kcContext";
|
2023-02-25 18:11:23 +01:00
|
|
|
import type { I18nBase } from "../i18n";
|
2022-07-31 18:57:30 +02:00
|
|
|
|
2023-02-27 11:55:25 +01:00
|
|
|
export default function Terms(props: PageProps<Extract<KcContextBase, { pageId: "terms.ftl" }>, I18nBase>) {
|
2023-02-25 18:11:23 +01:00
|
|
|
const { kcContext, i18n, doFetchDefaultThemeResources = true, Template, ...kcProps } = props;
|
2021-04-08 15:41:40 +02:00
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
const { msg, msgStr } = i18n;
|
2021-04-08 15:41:40 +02:00
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
useRerenderOnStateChange(evtTermMarkdown);
|
2021-04-08 15:41:40 +02:00
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
const { url } = kcContext;
|
|
|
|
|
|
|
|
if (evtTermMarkdown.state === undefined) {
|
|
|
|
return null;
|
2022-09-27 21:30:33 +02:00
|
|
|
}
|
2022-10-13 11:58:31 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Template
|
|
|
|
{...{ kcContext, i18n, doFetchDefaultThemeResources, ...kcProps }}
|
|
|
|
displayMessage={false}
|
|
|
|
headerNode={msg("termsTitle")}
|
|
|
|
formNode={
|
|
|
|
<>
|
|
|
|
<div id="kc-terms-text">{evtTermMarkdown.state && <Markdown>{evtTermMarkdown.state}</Markdown>}</div>
|
|
|
|
<form className="form-actions" action={url.loginAction} method="POST">
|
|
|
|
<input
|
2022-10-16 00:49:49 +02:00
|
|
|
className={clsx(
|
2022-10-13 11:58:31 +02:00
|
|
|
kcProps.kcButtonClass,
|
|
|
|
kcProps.kcButtonClass,
|
|
|
|
kcProps.kcButtonClass,
|
|
|
|
kcProps.kcButtonPrimaryClass,
|
|
|
|
kcProps.kcButtonLargeClass
|
|
|
|
)}
|
|
|
|
name="accept"
|
|
|
|
id="kc-accept"
|
|
|
|
type="submit"
|
|
|
|
value={msgStr("doAccept")}
|
|
|
|
/>
|
|
|
|
<input
|
2022-10-16 00:49:49 +02:00
|
|
|
className={clsx(kcProps.kcButtonClass, kcProps.kcButtonDefaultClass, kcProps.kcButtonLargeClass)}
|
2022-10-13 11:58:31 +02:00
|
|
|
name="cancel"
|
|
|
|
id="kc-decline"
|
|
|
|
type="submit"
|
|
|
|
value={msgStr("doDecline")}
|
|
|
|
/>
|
|
|
|
</form>
|
|
|
|
<div className="clearfix" />
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
2023-02-25 18:11:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const evtTermMarkdown = Evt.create<string | undefined>(undefined);
|