@@ -43,7 +43,8 @@ const requestMiddleware: RequestMiddleware[] = [
4343
4444( async ( ) => {
4545 const journeyClient = await journey ( { config, requestMiddleware } ) ;
46- const formEl = document . getElementById ( 'form' ) as HTMLFormElement ;
46+ const errorEl = document . getElementById ( 'error' ) as HTMLDivElement ;
47+ const journeyEl = document . getElementById ( 'journey' ) as HTMLDivElement ;
4748
4849 let step = await journeyClient . start ( ) ;
4950
@@ -54,7 +55,7 @@ const requestMiddleware: RequestMiddleware[] = [
5455
5556 const session = step . getSessionToken ( ) ;
5657
57- formEl . innerHTML = `
58+ journeyEl . innerHTML = `
5859 <h2>Complete</h2>
5960 <span>Session:</span>
6061 <pre data-testid="sessionToken" id="sessionToken">${ session } </pre>
@@ -79,17 +80,16 @@ const requestMiddleware: RequestMiddleware[] = [
7980 }
8081
8182 const error = step . payload . message ;
82- const errorDiv = formEl . querySelector ( '#error-div' ) ;
83- if ( errorDiv ) {
84- errorDiv . innerHTML = `
83+ if ( errorEl ) {
84+ errorEl . innerHTML = `
8585 <pre>${ error } </pre>
8686 ` ;
8787 }
8888 }
8989
9090 // Represents the main render function for app
9191 async function renderForm ( ) {
92- formEl . innerHTML = '' ;
92+ journeyEl . innerHTML = '' ;
9393
9494 if ( step ?. type !== 'Step' ) {
9595 throw new Error ( 'Expected step to be defined and of type Step' ) ;
@@ -99,22 +99,22 @@ const requestMiddleware: RequestMiddleware[] = [
9999
100100 const header = document . createElement ( 'h2' ) ;
101101 header . innerText = formName || '' ;
102- formEl . appendChild ( header ) ;
102+ journeyEl . appendChild ( header ) ;
103103
104104 const callbacks = step . callbacks ;
105105
106106 callbacks . forEach ( ( callback , idx ) => {
107107 if ( callback . getType ( ) === 'NameCallback' ) {
108108 const cb = callback as NameCallback ;
109109 textComponent (
110- formEl , // You can ignore this; it's just for rendering
110+ journeyEl , // You can ignore this; it's just for rendering
111111 cb , // This callback class
112112 idx ,
113113 ) ;
114114 } else if ( callback . getType ( ) === 'PasswordCallback' ) {
115115 const cb = callback as PasswordCallback ;
116116 passwordComponent (
117- formEl , // You can ignore this; it's just for rendering
117+ journeyEl , // You can ignore this; it's just for rendering
118118 cb , // This callback class
119119 idx ,
120120 ) ;
@@ -125,10 +125,10 @@ const requestMiddleware: RequestMiddleware[] = [
125125 submitBtn . type = 'submit' ;
126126 submitBtn . id = 'submitButton' ;
127127 submitBtn . innerText = 'Submit' ;
128- formEl . appendChild ( submitBtn ) ;
128+ journeyEl . appendChild ( submitBtn ) ;
129129 }
130130
131- formEl . addEventListener ( 'submit' , async ( event ) => {
131+ journeyEl . addEventListener ( 'submit' , async ( event ) => {
132132 event . preventDefault ( ) ;
133133
134134 if ( step ?. type !== 'Step' ) {
0 commit comments