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")} headerNode={msg("registerTitle")}
formNode={ formNode={
<form id="kc-register-form" className={cx(props.kcFormClass)} action={url.registrationAction} method="post"> <form id="kc-register-form" className={cx(props.kcFormClass)} action={url.registrationAction} method="post">
<UserProfileFormFields <UserProfileFormFields kcContext={kcContext} onIsFormSubmittableValueChange={setIsFomSubmittable} i18n={i18n} {...props} />
kcContext={kcContext}
doInsertPasswordFields={true}
onIsFormSubmittableValueChange={setIsFomSubmittable}
i18n={i18n}
{...props}
/>
{recaptchaRequired && ( {recaptchaRequired && (
<div className="form-group"> <div className="form-group">
<div className={cx(props.kcInputWrapperClass)}> <div className={cx(props.kcInputWrapperClass)}>

View File

@ -6,7 +6,7 @@ import { useCssAndCx } from "../tools/useCssAndCx";
import type { I18n } from "../i18n"; import type { I18n } from "../i18n";
import { UserProfileFormFields } from "./shared/UserProfileCommons"; 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 { cx } = useCssAndCx();
const { msg, msgStr } = i18n; const { msg, msgStr } = i18n;
@ -22,13 +22,7 @@ const LoginUpdateProfile = memo(({ kcContext, i18n, ...props }: { kcContext: KcC
headerNode={msg("loginProfileTitle")} headerNode={msg("loginProfileTitle")}
formNode={ formNode={
<form id="kc-update-profile-form" className={cx(props.kcFormClass)} action={url.loginAction} method="post"> <form id="kc-update-profile-form" className={cx(props.kcFormClass)} action={url.loginAction} method="post">
<UserProfileFormFields <UserProfileFormFields kcContext={kcContext} onIsFormSubmittableValueChange={setIsFomSubmittable} i18n={i18n} {...props} />
kcContext={kcContext}
doInsertPasswordFields={true}
onIsFormSubmittableValueChange={setIsFomSubmittable}
i18n={i18n}
{...props}
/>
<div className={cx(props.kcFormGroupClass)}> <div className={cx(props.kcFormGroupClass)}>
<div id="kc-form-options" className={cx(props.kcFormOptionsClass)}> <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"; import type { Param0 } from "tsafe/Param0";
export type UserProfileFormFieldsProps = { export type UserProfileFormFieldsProps = {
//kcContext: KcContextBase.RegisterUserProfile;
kcContext: Param0<typeof useFormValidationSlice>["kcContext"]; kcContext: Param0<typeof useFormValidationSlice>["kcContext"];
doInsertPasswordFields: boolean;
i18n: I18n; i18n: I18n;
} & KcProps & } & KcProps &
Partial<Record<"BeforeField" | "AfterField", ReactComponent<{ attribute: Attribute }>>> & { Partial<Record<"BeforeField" | "AfterField", ReactComponent<{ attribute: Attribute }>>> & {
@ -19,7 +17,7 @@ export type UserProfileFormFieldsProps = {
}; };
export const UserProfileFormFields = memo( export const UserProfileFormFields = memo(
({ kcContext, doInsertPasswordFields, onIsFormSubmittableValueChange, i18n, BeforeField, AfterField, ...props }: UserProfileFormFieldsProps) => { ({ kcContext, onIsFormSubmittableValueChange, i18n, BeforeField, AfterField, ...props }: UserProfileFormFieldsProps) => {
const { cx, css } = useCssAndCx(); const { cx, css } = useCssAndCx();
const { advancedMsg } = i18n; const { advancedMsg } = i18n;
@ -64,7 +62,7 @@ export const UserProfileFormFields = memo(
return ( return (
<> <>
{(doInsertPasswordFields ? attributesWithPassword : kcContext.profile.attributes).map((attribute, i) => { {attributesWithPassword.map((attribute, i) => {
const { group = "", groupDisplayHeader = "", groupDisplayDescription = "" } = attribute; const { group = "", groupDisplayHeader = "", groupDisplayDescription = "" } = attribute;
const { value, displayableErrors } = fieldStateByAttributeName[attribute.name]; const { value, displayableErrors } = fieldStateByAttributeName[attribute.name];

View File

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