Rename misnamed default exports, removing doInsertPasswordFields

This commit is contained in:
garronej 2022-09-09 10:24:50 +02:00
parent 86e6c4a419
commit bbaa90e997
4 changed files with 10 additions and 20 deletions

View File

@ -32,13 +32,7 @@ const RegisterUserProfile = memo(({ kcContext, i18n, ...props_ }: { kcContext: K
headerNode={msg("registerTitle")}
formNode={
<form id="kc-register-form" className={cx(props.kcFormClass)} action={url.registrationAction} method="post">
<UserProfileFormFields
kcContext={kcContext}
doInsertPasswordFields={true}
onIsFormSubmittableValueChange={setIsFomSubmittable}
i18n={i18n}
{...props}
/>
<UserProfileFormFields kcContext={kcContext} onIsFormSubmittableValueChange={setIsFomSubmittable} i18n={i18n} {...props} />
{recaptchaRequired && (
<div className="form-group">
<div className={cx(props.kcInputWrapperClass)}>

View File

@ -6,7 +6,7 @@ import { useCssAndCx } from "../tools/useCssAndCx";
import type { I18n } from "../i18n";
import { UserProfileFormFields } from "./shared/UserProfileCommons";
const LoginUpdateProfile = memo(({ kcContext, i18n, ...props }: { kcContext: KcContextBase.UpdateUserProfile; i18n: I18n } & KcProps) => {
const UpdateUserProfile = memo(({ kcContext, i18n, ...props }: { kcContext: KcContextBase.UpdateUserProfile; i18n: I18n } & KcProps) => {
const { cx } = useCssAndCx();
const { msg, msgStr } = i18n;
@ -22,13 +22,7 @@ const LoginUpdateProfile = memo(({ kcContext, i18n, ...props }: { kcContext: KcC
headerNode={msg("loginProfileTitle")}
formNode={
<form id="kc-update-profile-form" className={cx(props.kcFormClass)} action={url.loginAction} method="post">
<UserProfileFormFields
kcContext={kcContext}
doInsertPasswordFields={true}
onIsFormSubmittableValueChange={setIsFomSubmittable}
i18n={i18n}
{...props}
/>
<UserProfileFormFields kcContext={kcContext} onIsFormSubmittableValueChange={setIsFomSubmittable} i18n={i18n} {...props} />
<div className={cx(props.kcFormGroupClass)}>
<div id="kc-form-options" className={cx(props.kcFormOptionsClass)}>
@ -74,4 +68,4 @@ const LoginUpdateProfile = memo(({ kcContext, i18n, ...props }: { kcContext: KcC
);
});
export default LoginUpdateProfile;
export default UpdateUserProfile;

View File

@ -9,9 +9,7 @@ import type { I18n } from "../../i18n";
import type { Param0 } from "tsafe/Param0";
export type UserProfileFormFieldsProps = {
//kcContext: KcContextBase.RegisterUserProfile;
kcContext: Param0<typeof useFormValidationSlice>["kcContext"];
doInsertPasswordFields: boolean;
i18n: I18n;
} & KcProps &
Partial<Record<"BeforeField" | "AfterField", ReactComponent<{ attribute: Attribute }>>> & {
@ -19,7 +17,7 @@ export type UserProfileFormFieldsProps = {
};
export const UserProfileFormFields = memo(
({ kcContext, doInsertPasswordFields, onIsFormSubmittableValueChange, i18n, BeforeField, AfterField, ...props }: UserProfileFormFieldsProps) => {
({ kcContext, onIsFormSubmittableValueChange, i18n, BeforeField, AfterField, ...props }: UserProfileFormFieldsProps) => {
const { cx, css } = useCssAndCx();
const { advancedMsg } = i18n;
@ -64,7 +62,7 @@ export const UserProfileFormFields = memo(
return (
<>
{(doInsertPasswordFields ? attributesWithPassword : kcContext.profile.attributes).map((attribute, i) => {
{attributesWithPassword.map((attribute, i) => {
const { group = "", groupDisplayHeader = "", groupDisplayDescription = "" } = attribute;
const { value, displayableErrors } = fieldStateByAttributeName[attribute.name];

View File

@ -304,6 +304,10 @@ export function useGetErrors(params: {
return { getErrors };
}
/**
* NOTE: The attributesWithPassword returned is actually augmented with
* artificial password related attributes only if kcContext.passwordRequired === true
*/
export function useFormValidationSlice(params: {
kcContext: {
messagesPerField: Pick<KcContextBase.Common["messagesPerField"], "existsError" | "get">;