File tree Expand file tree Collapse file tree 3 files changed +14
-17
lines changed
packages/console/src/pages/SignInExperience/PageContent Expand file tree Collapse file tree 3 files changed +14
-17
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ export const getInitialRequestPayloadByFieldName = (name: string) => {
100100 required : true ,
101101 config : {
102102 format : cond ( type === CustomProfileFieldType . Date && SupportedDateFormat . US ) ,
103+ placeholder : cond ( type === CustomProfileFieldType . Date && SupportedDateFormat . US ) ,
103104 parts : getDefaultParts ( type ) ,
104105 options : getDefaultOptions ( name ) ,
105106 ...cond ( type === CustomProfileFieldType . Text && { minLength : 1 , maxLength : 100 } ) ,
Original file line number Diff line number Diff line change 11import { SupportedDateFormat } from '@logto/schemas' ;
2- import { useEffect } from 'react' ;
32import { Controller , useFormContext } from 'react-hook-form' ;
43import { Trans , useTranslation } from 'react-i18next' ;
54
@@ -32,16 +31,6 @@ function DateFormatSelector({ index }: Props) {
3231 const formatValue = watch ( `${ fieldPrefix } format` ) ;
3332 const formErrors = index === undefined ? errors : errors . parts ?. [ index ] ;
3433
35- useEffect ( ( ) => {
36- if ( ! formatValue ) {
37- setValue ( `${ fieldPrefix } format` , SupportedDateFormat . US ) ;
38- return ;
39- }
40- if ( formatValue !== SupportedDateFormat . Custom ) {
41- setValue ( `${ fieldPrefix } customFormat` , '' ) ;
42- }
43- } , [ fieldPrefix , formatValue , setValue ] ) ;
44-
4534 return (
4635 < div className = { styles . dateFormatSelector } >
4736 < Controller
@@ -56,7 +45,14 @@ function DateFormatSelector({ index }: Props) {
5645 { value : SupportedDateFormat . Custom , title : t ( 'custom_date_format' ) } ,
5746 ] }
5847 value = { value }
59- onChange = { onChange }
48+ onChange = { ( value ) => {
49+ onChange ( value ) ;
50+ setValue (
51+ `${ fieldPrefix } placeholder` ,
52+ value === SupportedDateFormat . Custom ? '' : value ,
53+ { shouldDirty : true }
54+ ) ;
55+ } }
6056 />
6157 ) }
6258 />
Original file line number Diff line number Diff line change @@ -101,6 +101,11 @@ function ProfileFieldPartSubForm({ index }: Props) {
101101 } }
102102 />
103103 </ FormField >
104+ { type === CustomProfileFieldType . Date && (
105+ < FormField title = "sign_in_exp.custom_profile_fields.details.date_format" >
106+ < DateFormatSelector />
107+ </ FormField >
108+ ) }
104109 < FormField
105110 isRequired = { ! isBuiltInFieldName }
106111 title = "sign_in_exp.custom_profile_fields.details.label"
@@ -184,11 +189,6 @@ function ProfileFieldPartSubForm({ index }: Props) {
184189 />
185190 </ FormField >
186191 ) }
187- { type === CustomProfileFieldType . Date && (
188- < FormField title = "sign_in_exp.custom_profile_fields.details.date_format" >
189- < DateFormatSelector />
190- </ FormField >
191- ) }
192192 { type === CustomProfileFieldType . Checkbox && (
193193 < FormField title = "sign_in_exp.custom_profile_fields.details.default_value" >
194194 < Controller
You can’t perform that action at this time.
0 commit comments