@@ -31,16 +31,6 @@ const generateId = (prefix: string): string => {
3131 * Convert simple input type to component variant
3232 */
3333const getInputVariant = ( type : string , name : string ) : 'TEXT' | 'EMAIL' | 'PASSWORD' => {
34- // Check name first (e.g., "password" field name)
35- const lowerName = name . toLowerCase ( ) ;
36- if ( lowerName . includes ( 'password' ) ) {
37- return 'PASSWORD' ;
38- }
39- if ( lowerName . includes ( 'email' ) ) {
40- return 'EMAIL' ;
41- }
42-
43- // Then check type
4434 switch ( type . toLowerCase ( ) ) {
4535 case 'email' :
4636 return 'EMAIL' ;
@@ -91,16 +81,25 @@ const convertSimpleInputToComponent = (
9181 } ,
9282 t : UseTranslation [ 't' ] ,
9383) : EmbeddedFlowComponent => {
94- const variant = getInputVariant ( input . type , input . name ) ;
95- const label = getInputLabel ( input . name , input . type , t ) ;
96- const placeholder = getInputPlaceholder ( input . name , input . type , t ) ;
84+ let fieldType : string = input . type ;
85+
86+ // If the field name contains 'password' but type is 'string', change it to 'password'
87+ // TODO: Need to remove this one the following improvement is done.
88+ // Tracker: https://github.com/asgardeo/thunder/issues/725
89+ if ( input . name . toLowerCase ( ) . includes ( 'password' ) && input . type . toLowerCase ( ) === 'string' ) {
90+ fieldType = 'password' ;
91+ }
92+
93+ const variant : 'TEXT' | 'EMAIL' | 'PASSWORD' = getInputVariant ( fieldType , input . name ) ;
94+ const label : string = getInputLabel ( input . name , fieldType , t ) ;
95+ const placeholder : string = getInputPlaceholder ( input . name , fieldType , t ) ;
9796
9897 return {
9998 id : generateId ( 'input' ) ,
10099 type : EmbeddedFlowComponentType . Input ,
101100 variant,
102101 config : {
103- type : input . type ,
102+ type : fieldType ,
104103 label,
105104 placeholder,
106105 required : input . required as boolean ,
@@ -118,13 +117,19 @@ const convertActionToComponent = (
118117 action : { type : string ; id : string } ,
119118 t : UseTranslation [ 't' ] ,
120119) : EmbeddedFlowComponent => {
120+ // Normalize action ID for translation lookup (e.g., "google_auth" -> "google")
121+ const normalizedId : string = action . id . replace ( / _ a u t h $ / , '' ) ;
122+
121123 // Use i18n key for button text, fallback to capitalized id
122- const i18nKey = `elements.buttons.${ action . id } ` ;
123- let text = t ( i18nKey ) ;
124+ const i18nKey : string = `elements.buttons.${ normalizedId } ` ;
125+ let text : string = t ( i18nKey ) ;
126+
124127 if ( ! text || text === i18nKey ) {
128+ // Fallback: format the original action ID
125129 text = action . id . replace ( / _ / g, ' ' ) ;
126130 text = text . charAt ( 0 ) . toUpperCase ( ) + text . slice ( 1 ) ;
127131 }
132+
128133 return {
129134 id : generateId ( 'action' ) ,
130135 type : EmbeddedFlowComponentType . Button ,
0 commit comments