2023-02-25 18:11:23 +01:00
|
|
|
import React, { useState } from "react";
|
2022-10-16 00:49:49 +02:00
|
|
|
import { clsx } from "../tools/clsx";
|
2022-09-09 02:07:29 +02:00
|
|
|
import { UserProfileFormFields } from "./shared/UserProfileCommons";
|
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";
|
2021-10-11 03:25:02 +02:00
|
|
|
|
2023-02-27 11:55:25 +01:00
|
|
|
export default function RegisterUserProfile(props: PageProps<Extract<KcContextBase, { pageId: "register-user-profile.ftl" }>, I18nBase>) {
|
2023-02-25 18:11:23 +01:00
|
|
|
const { kcContext, i18n, doFetchDefaultThemeResources = true, Template, ...kcProps } = props;
|
2021-10-11 03:25:02 +02:00
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
const { url, messagesPerField, recaptchaRequired, recaptchaSiteKey } = kcContext;
|
2021-10-25 21:26:08 +02:00
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
const { msg, msgStr } = i18n;
|
2021-10-25 21:26:08 +02:00
|
|
|
|
2022-10-13 11:58:31 +02:00
|
|
|
const [isFomSubmittable, setIsFomSubmittable] = useState(false);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Template
|
|
|
|
{...{ kcContext, i18n, doFetchDefaultThemeResources, ...kcProps }}
|
|
|
|
displayMessage={messagesPerField.exists("global")}
|
|
|
|
displayRequiredFields={true}
|
|
|
|
headerNode={msg("registerTitle")}
|
|
|
|
formNode={
|
2022-10-16 00:49:49 +02:00
|
|
|
<form id="kc-register-form" className={clsx(kcProps.kcFormClass)} action={url.registrationAction} method="post">
|
2022-10-13 11:58:31 +02:00
|
|
|
<UserProfileFormFields kcContext={kcContext} onIsFormSubmittableValueChange={setIsFomSubmittable} i18n={i18n} {...kcProps} />
|
|
|
|
{recaptchaRequired && (
|
|
|
|
<div className="form-group">
|
2022-10-16 00:49:49 +02:00
|
|
|
<div className={clsx(kcProps.kcInputWrapperClass)}>
|
2022-10-13 11:58:31 +02:00
|
|
|
<div className="g-recaptcha" data-size="compact" data-sitekey={recaptchaSiteKey} />
|
2021-10-11 21:35:40 +02:00
|
|
|
</div>
|
2022-10-13 11:58:31 +02:00
|
|
|
</div>
|
|
|
|
)}
|
2022-10-16 00:49:49 +02:00
|
|
|
<div className={clsx(kcProps.kcFormGroupClass)} style={{ "marginBottom": 30 }}>
|
|
|
|
<div id="kc-form-options" className={clsx(kcProps.kcFormOptionsClass)}>
|
|
|
|
<div className={clsx(kcProps.kcFormOptionsWrapperClass)}>
|
2022-10-13 11:58:31 +02:00
|
|
|
<span>
|
|
|
|
<a href={url.loginUrl}>{msg("backToLogin")}</a>
|
|
|
|
</span>
|
2021-10-11 21:35:40 +02:00
|
|
|
</div>
|
2022-10-13 11:58:31 +02:00
|
|
|
</div>
|
2021-10-11 03:25:02 +02:00
|
|
|
|
2022-10-16 00:49:49 +02:00
|
|
|
<div id="kc-form-buttons" className={clsx(kcProps.kcFormButtonsClass)}>
|
2022-10-13 11:58:31 +02:00
|
|
|
<input
|
2022-10-16 00:49:49 +02:00
|
|
|
className={clsx(
|
2022-10-13 11:58:31 +02:00
|
|
|
kcProps.kcButtonClass,
|
|
|
|
kcProps.kcButtonPrimaryClass,
|
|
|
|
kcProps.kcButtonBlockClass,
|
|
|
|
kcProps.kcButtonLargeClass
|
|
|
|
)}
|
|
|
|
type="submit"
|
|
|
|
value={msgStr("doRegister")}
|
|
|
|
disabled={!isFomSubmittable}
|
|
|
|
/>
|
2021-10-11 21:35:40 +02:00
|
|
|
</div>
|
2022-10-13 11:58:31 +02:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
2023-02-25 18:11:23 +01:00
|
|
|
}
|