2024-06-09 08:27:07 +02:00
|
|
|
import { getKcClsx } from "keycloakify/login/lib/kcClsx";
|
2024-06-05 21:13:58 +02:00
|
|
|
import type { PageProps } from "keycloakify/login/pages/PageProps";
|
|
|
|
import type { KcContext } from "../KcContext";
|
2024-06-09 11:20:45 +02:00
|
|
|
import type { I18n } from "../i18n";
|
2024-09-29 04:35:02 -04:00
|
|
|
import { kcSanitize } from "keycloakify/lib/kcSanitize";
|
2024-05-10 21:40:23 +02:00
|
|
|
|
2024-06-09 11:20:45 +02:00
|
|
|
export default function Code(props: PageProps<Extract<KcContext, { pageId: "code.ftl" }>, I18n>) {
|
|
|
|
const { kcContext, i18n, doUseDefaultCss, Template, classes } = props;
|
2024-05-10 21:40:23 +02:00
|
|
|
|
2024-06-09 08:27:07 +02:00
|
|
|
const { kcClsx } = getKcClsx({
|
2024-05-10 21:40:23 +02:00
|
|
|
doUseDefaultCss,
|
|
|
|
classes
|
|
|
|
});
|
|
|
|
|
|
|
|
const { code } = kcContext;
|
|
|
|
|
2024-06-09 11:20:45 +02:00
|
|
|
const { msg } = i18n;
|
2024-05-10 21:40:23 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Template
|
2024-06-09 08:27:07 +02:00
|
|
|
kcContext={kcContext}
|
2024-06-09 11:20:45 +02:00
|
|
|
i18n={i18n}
|
2024-06-09 08:27:07 +02:00
|
|
|
doUseDefaultCss={doUseDefaultCss}
|
|
|
|
classes={classes}
|
2024-05-10 21:40:23 +02:00
|
|
|
headerNode={code.success ? msg("codeSuccessTitle") : msg("codeErrorTitle", code.error)}
|
|
|
|
>
|
|
|
|
<div id="kc-code">
|
|
|
|
{code.success ? (
|
|
|
|
<>
|
|
|
|
<p>{msg("copyCodeInstruction")}</p>
|
2024-06-09 08:27:07 +02:00
|
|
|
<input id="code" className={kcClsx("kcTextareaClass")} defaultValue={code.code} />
|
2024-05-10 21:40:23 +02:00
|
|
|
</>
|
|
|
|
) : (
|
2024-09-29 04:35:02 -04:00
|
|
|
code.error && (
|
|
|
|
<p
|
|
|
|
id="error"
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: kcSanitize(code.error)
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
2024-05-10 21:40:23 +02:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</Template>
|
|
|
|
);
|
|
|
|
}
|