Skip to content

Commit 65cdc32

Browse files
authored
Merge pull request #245 from brionmario/fix-asgardeo-v2-signup
fix: fix password field type in `SignUp` in `AsgardeoV2` AKA Thunder ⚡
2 parents ef65364 + d2ac85b commit 65cdc32

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

.changeset/ninety-words-grow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@asgardeo/react': patch
3+
---
4+
5+
Fix password field type

packages/react/src/components/presentation/SignUp/transformer.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ const getInputLabel = (name: string, type: string, t: UseTranslation['t']): stri
5656
const label: string = t(i18nKey);
5757

5858
if (label === i18nKey || !label) {
59-
return name.charAt(0).toUpperCase() + name.slice(1);
59+
// Convert camelCase to sentence case (e.g., "firstName" -> "First name")
60+
// TODO: Need to remove this one the following improvement is done.
61+
// Tracker: https://github.com/asgardeo/thunder/issues/725
62+
return name
63+
.replace(/([A-Z])/g, ' $1')
64+
.replace(/^./, str => str.toUpperCase())
65+
.trim();
6066
}
6167

6268
return label;
@@ -102,9 +108,9 @@ const convertSimpleInputToComponent = (
102108
fieldType = 'password';
103109
}
104110

105-
const variant: 'TEXT' | 'EMAIL' | 'PASSWORD' = getInputVariant(input.type, input.name);
106-
const label: string = getInputLabel(input.name, input.type, t);
107-
const placeholder: string = getInputPlaceholder(input.name, input.type, t);
111+
const variant: 'TEXT' | 'EMAIL' | 'PASSWORD' = getInputVariant(fieldType, input.name);
112+
const label: string = getInputLabel(input.name, fieldType, t);
113+
const placeholder: string = getInputPlaceholder(input.name, fieldType, t);
108114

109115
return {
110116
id: generateId('input'),

0 commit comments

Comments
 (0)