File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed
packages/console/src/pages/SignInExperience/PageContent/CollectUserProfile
ProfileFieldDetails/ProfileFieldDetailsForm Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import { collectUserProfilePathname } from '../../consts';
2424import { parseResponseToFormData , parseFormDataToRequestPayload } from '../../data-parser' ;
2525import { type ProfileFieldForm } from '../../types' ;
2626import useI18nFieldLabel from '../../use-i18n-field-label' ;
27- import { isBuiltInCustomProfileFieldKey } from '../../utils' ;
27+ import { getFieldTags , isBuiltInCustomProfileFieldKey } from '../../utils' ;
2828
2929import styles from './index.module.scss' ;
3030
@@ -120,11 +120,7 @@ function ProfileFieldDetailsForm({ data }: Props) {
120120 title = { watch ( 'label' ) || getI18nLabel ( data . name ) }
121121 identifier = { {
122122 name : t ( 'sign_in_exp.custom_profile_fields.details.key' ) ,
123- tags : compositionParts
124- ?. filter ( ( { enabled } ) => enabled )
125- . map ( ( { name } ) => ( data . name === 'address' ? `address.${ name } ` : name ) ) ?? [
126- isBuiltInFieldName ? data . name : `customData.${ data . name } ` ,
127- ] ,
123+ tags : getFieldTags ( data . name , compositionParts ) ,
128124 } }
129125 actionMenuItems = { [
130126 {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { trySubmitSafe } from '@/utils/form';
1313
1414import { collectUserProfilePathname } from '../consts' ;
1515import useI18nFieldLabel from '../use-i18n-field-label' ;
16+ import { getFieldTags } from '../utils' ;
1617
1718import styles from './index.module.scss' ;
1819
@@ -79,11 +80,7 @@ function ProfileFieldList({ data }: Props) {
7980 < div className = { styles . cell } > { t ( `sign_in_exp.custom_profile_fields.type.${ type } ` ) } </ div >
8081 < div className = { styles . cell } >
8182 < div className = { styles . tags } >
82- { (
83- config . parts
84- ?. filter ( ( { enabled } ) => Boolean ( enabled ) )
85- . map ( ( part ) => part . name ) ?? [ name ]
86- ) . map ( ( key ) => (
83+ { getFieldTags ( name , config . parts ) . map ( ( key ) => (
8784 < Tag key = { key } variant = "cell" >
8885 { key }
8986 </ Tag >
Original file line number Diff line number Diff line change 11import {
22 builtInCustomProfileFieldKeys ,
33 CustomProfileFieldType ,
4+ type FieldPart ,
45 userProfileAddressKeys ,
56} from '@logto/schemas' ;
67
@@ -48,3 +49,19 @@ export const getProfileFieldTypeByName = (name: string): CustomProfileFieldType
4849 }
4950 }
5051} ;
52+
53+ /**
54+ * Generates field tags based on the field name and its composition parts.
55+ * For address fields, it prefixes the field name with 'address.'.
56+ * For custom fields, it prefixes with 'customData.'.
57+ * Other built-in fields are used as-is.
58+ */
59+ export const getFieldTags = ( fieldName : string , compositionParts ?: FieldPart [ ] ) : string [ ] => {
60+ if ( compositionParts ) {
61+ return compositionParts
62+ . filter ( ( { enabled } ) => enabled )
63+ . map ( ( { name } ) => ( fieldName === 'address' ? `address.${ name } ` : name ) ) ;
64+ }
65+
66+ return isBuiltInCustomProfileFieldKey ( fieldName ) ? [ fieldName ] : [ `customData.${ fieldName } ` ] ;
67+ } ;
You can’t perform that action at this time.
0 commit comments