Skip to content

Commit 2b12c9f

Browse files
hperlory-bot
authored andcommitted
fix: add card header detection for profile_first
GitOrigin-RevId: 5881c675187abe98591efdf252891c5a0d675ccd
1 parent 9b200ab commit 2b12c9f

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

packages/elements-react/src/theme/default/utils/__tests__/__snapshots__/constructCardHeader.spec.tsx.snap

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ exports[`flowType=login refresh=false combination=password constructCardHeaderTe
134134
}
135135
`;
136136

137+
exports[`flowType=login refresh=false combination=profile_first_registration constructCardHeaderText 1`] = `
138+
{
139+
"description": "Sign in with your Email",
140+
"title": "Sign in",
141+
}
142+
`;
143+
137144
exports[`flowType=login refresh=false combination=webauthn constructCardHeaderText 1`] = `
138145
{
139146
"description": "Sign in with a security key",
@@ -232,6 +239,13 @@ exports[`flowType=login refresh=true combination=password constructCardHeaderTex
232239
}
233240
`;
234241

242+
exports[`flowType=login refresh=true combination=profile_first_registration constructCardHeaderText 1`] = `
243+
{
244+
"description": "Confirm your identity with your Email",
245+
"title": "Reauthenticate",
246+
}
247+
`;
248+
235249
exports[`flowType=login refresh=true combination=webauthn constructCardHeaderText 1`] = `
236250
{
237251
"description": "Confirm your identity with a security key",
@@ -332,6 +346,13 @@ exports[`flowType=recovery refresh=false combination=password constructCardHeade
332346
}
333347
`;
334348

349+
exports[`flowType=recovery refresh=false combination=profile_first_registration constructCardHeaderText 1`] = `
350+
{
351+
"description": "Enter the email address associated with your account to receive a one-time access code",
352+
"title": "Recover your account",
353+
}
354+
`;
355+
335356
exports[`flowType=recovery refresh=false combination=webauthn constructCardHeaderText 1`] = `
336357
{
337358
"description": "Enter the email address associated with your account to receive a one-time access code",
@@ -432,6 +453,13 @@ exports[`flowType=recovery refresh=true combination=password constructCardHeader
432453
}
433454
`;
434455

456+
exports[`flowType=recovery refresh=true combination=profile_first_registration constructCardHeaderText 1`] = `
457+
{
458+
"description": "Enter the email address associated with your account to receive a one-time access code",
459+
"title": "Recover your account",
460+
}
461+
`;
462+
435463
exports[`flowType=recovery refresh=true combination=webauthn constructCardHeaderText 1`] = `
436464
{
437465
"description": "Enter the email address associated with your account to receive a one-time access code",
@@ -530,6 +558,13 @@ exports[`flowType=registration refresh=false combination=password constructCardH
530558
}
531559
`;
532560

561+
exports[`flowType=registration refresh=false combination=profile_first_registration constructCardHeaderText 1`] = `
562+
{
563+
"description": "Sign up with your Email",
564+
"title": "Register an account",
565+
}
566+
`;
567+
533568
exports[`flowType=registration refresh=false combination=webauthn constructCardHeaderText 1`] = `
534569
{
535570
"description": "Sign up with a security key",
@@ -628,6 +663,13 @@ exports[`flowType=registration refresh=true combination=password constructCardHe
628663
}
629664
`;
630665

666+
exports[`flowType=registration refresh=true combination=profile_first_registration constructCardHeaderText 1`] = `
667+
{
668+
"description": "Sign up with your Email",
669+
"title": "Register an account",
670+
}
671+
`;
672+
631673
exports[`flowType=registration refresh=true combination=webauthn constructCardHeaderText 1`] = `
632674
{
633675
"description": "Sign up with a security key",
@@ -726,6 +768,13 @@ exports[`flowType=settings refresh=false combination=password constructCardHeade
726768
}
727769
`;
728770

771+
exports[`flowType=settings refresh=false combination=profile_first_registration constructCardHeaderText 1`] = `
772+
{
773+
"description": "Update your account settings",
774+
"title": "Account Settings",
775+
}
776+
`;
777+
729778
exports[`flowType=settings refresh=false combination=webauthn constructCardHeaderText 1`] = `
730779
{
731780
"description": "Update your account settings",
@@ -824,6 +873,13 @@ exports[`flowType=settings refresh=true combination=password constructCardHeader
824873
}
825874
`;
826875

876+
exports[`flowType=settings refresh=true combination=profile_first_registration constructCardHeaderText 1`] = `
877+
{
878+
"description": "Update your account settings",
879+
"title": "Account Settings",
880+
}
881+
`;
882+
827883
exports[`flowType=settings refresh=true combination=webauthn constructCardHeaderText 1`] = `
828884
{
829885
"description": "Update your account settings",
@@ -924,6 +980,13 @@ exports[`flowType=verification refresh=false combination=password constructCardH
924980
}
925981
`;
926982

983+
exports[`flowType=verification refresh=false combination=profile_first_registration constructCardHeaderText 1`] = `
984+
{
985+
"description": "Enter the email address associated with your account to verify it",
986+
"title": "Verify your account",
987+
}
988+
`;
989+
927990
exports[`flowType=verification refresh=false combination=webauthn constructCardHeaderText 1`] = `
928991
{
929992
"description": "Enter the email address associated with your account to verify it",
@@ -1024,6 +1087,13 @@ exports[`flowType=verification refresh=true combination=password constructCardHe
10241087
}
10251088
`;
10261089

1090+
exports[`flowType=verification refresh=true combination=profile_first_registration constructCardHeaderText 1`] = `
1091+
{
1092+
"description": "Enter the email address associated with your account to verify it",
1093+
"title": "Verify your account",
1094+
}
1095+
`;
1096+
10271097
exports[`flowType=verification refresh=true combination=webauthn constructCardHeaderText 1`] = `
10281098
{
10291099
"description": "Enter the email address associated with your account to verify it",

packages/elements-react/src/theme/default/utils/__tests__/constructCardHeader.spec.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,26 @@ const identifierFirstPhone: UiNode = {
178178
},
179179
}
180180

181+
const profileSubmit: UiNode = {
182+
type: "input",
183+
group: "profile",
184+
attributes: {
185+
name: "method",
186+
type: "submit",
187+
value: "profile",
188+
disabled: false,
189+
node_type: "input",
190+
},
191+
messages: [],
192+
meta: {
193+
label: {
194+
id: 1040001,
195+
text: "Sign up",
196+
type: "info",
197+
},
198+
},
199+
}
200+
181201
const combinations = {
182202
oidc,
183203
code,
@@ -193,6 +213,7 @@ const combinations = {
193213
default_and_passkeys: [defaultGroup, passkey],
194214
default_and_webauthn: [defaultGroup, aal2Nodes.webauthn],
195215
idenfier_first_and_oidc: [identifierFirst, oidc],
216+
profile_first_registration: [defaultGroup, profileSubmit],
196217
}
197218

198219
const wrapper = ({ children }: PropsWithChildren) => (

packages/elements-react/src/theme/default/utils/constructCardHeader.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,28 @@ export function useCardHeaderText(
226226
}
227227
}
228228

229+
if (nodes.some((node) => node.group === "profile")) {
230+
const identifier = nodes.find(
231+
(node) =>
232+
isUiNodeInputAttributes(node.attributes) &&
233+
node.attributes.name.startsWith("traits.") &&
234+
node.attributes.type !== "hidden",
235+
)
236+
237+
if (identifier) {
238+
parts.push(
239+
intl.formatMessage(
240+
{
241+
id: "card.header.parts.identifier-first",
242+
},
243+
{
244+
identifierLabel: identifier.meta.label?.text,
245+
},
246+
),
247+
)
248+
}
249+
}
250+
229251
switch (opts.flowType) {
230252
case FlowType.Login:
231253
if (opts.flow.refresh) {

0 commit comments

Comments
 (0)