Skip to content

Commit c67119e

Browse files
committed
Add optional reference identifier to EmbeddedFlowComponent and update related components to use it
1 parent f7710bf commit c67119e

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

packages/javascript/src/models/v2/embedded-flow-v2.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ export interface EmbeddedFlowComponent {
133133
* Unique identifier for the component
134134
*/
135135
id: string;
136+
137+
/**
138+
* Reference identifier for the component (e.g., field name, action ref)
139+
*/
140+
ref?: string;
136141

137142
/**
138143
* Component type that determines rendering behavior

packages/react/src/components/factories/FieldFactory.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export interface FieldConfig {
3737
/**
3838
* The field type.
3939
*/
40-
type: FieldType;
40+
type: FieldType
41+
;
4142
/**
4243
* Display name for the field.
4344
*/

packages/react/src/components/presentation/SignIn/v2/BaseSignIn.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ const BaseSignInContent: FC<BaseSignInProps> = ({
316316
const processComponents = (comps: EmbeddedFlowComponent[]) => {
317317
comps.forEach(component => {
318318
if (component.type === 'TEXT_INPUT' || component.type === 'PASSWORD_INPUT') {
319-
const identifier: string = component.id;
319+
const identifier: string = component.ref;
320320
fields.push({
321321
name: identifier,
322322
required: component.required || false,
@@ -390,6 +390,7 @@ const BaseSignInContent: FC<BaseSignInProps> = ({
390390

391391
setIsSubmitting(true);
392392
clearMessages();
393+
console.log('Submitting component:', component, 'with data:', data);
393394

394395
try {
395396
// Filter out empty or undefined input values
@@ -404,9 +405,10 @@ const BaseSignInContent: FC<BaseSignInProps> = ({
404405

405406
let payload: EmbeddedSignInFlowRequest = {};
406407

407-
// For V2, we always send inputs, not actionId
408+
// For V2, we always send inputs and action
408409
payload = {
409410
...payload,
411+
...(component.id && {action: component.id}),
410412
inputs: filteredInputs,
411413
};
412414

packages/react/src/components/presentation/SignIn/v2/SignInOptionFactory.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ const createSignInComponentFromFlow = (
9595
): ReactElement | null => {
9696
const key: string | number = options.key || component.id;
9797

98+
console.log('Creating sign-in component for:', component);
9899
switch (component.type) {
99100
case EmbeddedFlowComponentType.TextInput: {
100-
const identifier: string = component.id;
101+
const identifier: string = component.ref;
101102
const value: string = formValues[identifier] || '';
102103
const isTouched: boolean = touchedFields[identifier] || false;
103104
const error: string = isTouched ? formErrors[identifier] : undefined;
@@ -120,7 +121,7 @@ const createSignInComponentFromFlow = (
120121
}
121122

122123
case EmbeddedFlowComponentType.PasswordInput: {
123-
const identifier: string = component.id;
124+
const identifier: string = component.ref;
124125
const value: string = formValues[identifier] || '';
125126
const isTouched: boolean = touchedFields[identifier] || false;
126127
const error: string = isTouched ? formErrors[identifier] : undefined;

packages/react/src/components/presentation/SignUp/v2/BaseSignUp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ const BaseSignUpContent: FC<BaseSignUpProps> = ({
442442
const payload: EmbeddedFlowExecuteRequestPayload = {
443443
...(currentFlow.flowId && {flowId: currentFlow.flowId}),
444444
flowType: (currentFlow as any).flowType || 'REGISTRATION',
445+
...(component.id && {action: component.id}),
445446
inputs: filteredInputs,
446447
} as any;
447448

packages/react/src/components/presentation/SignUp/v2/SignUpOptionFactory.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const createSignUpComponentFromFlow = (
9292

9393
switch (component.type) {
9494
case EmbeddedFlowComponentType.TextInput: {
95-
const identifier: string = component.id;
95+
const identifier: string = component.ref;
9696
const value: string = formValues[identifier] || '';
9797
const isTouched: boolean = touchedFields[identifier] || false;
9898
const error: string = isTouched ? formErrors[identifier] : undefined;
@@ -115,7 +115,7 @@ const createSignUpComponentFromFlow = (
115115
}
116116

117117
case EmbeddedFlowComponentType.PasswordInput: {
118-
const identifier: string = component.id;
118+
const identifier: string = component.ref;
119119
const value: string = formValues[identifier] || '';
120120
const isTouched: boolean = touchedFields[identifier] || false;
121121
const error: string = isTouched ? formErrors[identifier] : undefined;

0 commit comments

Comments
 (0)