@@ -66,6 +66,7 @@ function LoginForm() {
6666 }
6767 ) ;
6868 const linkStraboBody = await linkStrabo . json ( ) ;
69+ console . log ( "Link Strabospot!" , linkStraboBody ) ;
6970 setLinkStraboResponse ( linkStraboBody ) ;
7071 }
7172 setLoggedIn ( true ) ;
@@ -84,6 +85,31 @@ function LoginForm() {
8485
8586 const className = classNames ( Classes . INPUT , "bp4-large" ) ;
8687
88+ useEffect ( ( ) => {
89+ const sendRockdJWTToStrabo = async ( ) => {
90+ if ( loggedIn && linkStraboResponse && jParam ) {
91+ try {
92+ const rockdJWTToStrabo = await fetch (
93+ "https://strabospot.org/db/macroJWT" ,
94+ {
95+ method : "POST" ,
96+ headers : {
97+ "Content-Type" : "application/json" ,
98+ Authorization : `Bearer ${ jParam } ` ,
99+ } ,
100+ body : JSON . stringify ( linkStraboResponse ) ,
101+ }
102+ ) ;
103+ const straboResponse = await rockdJWTToStrabo . json ( ) ;
104+ console . log ( "Strabo Response:" , straboResponse ) ;
105+ } catch ( err ) {
106+ console . error ( "Failed to send Rockd JWT to Strabo:" , err ) ;
107+ }
108+ }
109+ } ;
110+ sendRockdJWTToStrabo ( ) ;
111+ } , [ loggedIn , linkStraboResponse , jParam ] ) ;
112+
87113 if ( loggedIn ) {
88114 return h ( "div" , { className : "login-page" } , [
89115 h ( Callout , {
@@ -104,55 +130,55 @@ function LoginForm() {
104130 "Logout"
105131 ) ,
106132 ] ) ;
107- }
108-
109- return h ( "div" , { className : "login-page" } , [
110- h ( "h2" , "Login" ) ,
111- error &&
112- h ( Callout , {
113- className : "login-info" ,
114- title : "Login Error" ,
115- intent : Intent . DANGER ,
116- children : error ,
117- } ) ,
118- h (
119- "form.login-form" ,
120- {
121- onSubmit : ( e ) => {
122- e . preventDefault ( ) ; // Prevent form reload
123- submitForm ( ) ;
124- } ,
125- } ,
126- [
127- h ( "input" , {
128- type : "text" ,
129- name : "username" ,
130- value : state . username ,
131- onChange,
132- className,
133- placeholder : "Username" ,
134- } ) ,
135- h ( "input" , {
136- type : "password" ,
137- name : "password" ,
138- value : state . password ,
139- onChange,
140- className,
141- placeholder : "Password" ,
133+ } else {
134+ return h ( "div" , { className : "login-page" } , [
135+ h ( "h2" , "Login" ) ,
136+ error &&
137+ h ( Callout , {
138+ className : "login-info" ,
139+ title : "Login Error" ,
140+ intent : Intent . DANGER ,
141+ children : error ,
142142 } ) ,
143- h (
144- Button ,
145- {
146- intent : Intent . PRIMARY ,
147- large : true ,
148- type : "submit" , // Important: treat this as a submit button
149- disabled : ! isValid ( state ) ,
143+ h (
144+ "form.login-form" ,
145+ {
146+ onSubmit : ( e ) => {
147+ e . preventDefault ( ) ; // Prevent form reload
148+ submitForm ( ) ;
150149 } ,
151- "Login"
152- ) ,
153- ]
154- ) ,
155- ] ) ;
150+ } ,
151+ [
152+ h ( "input" , {
153+ type : "text" ,
154+ name : "username" ,
155+ value : state . username ,
156+ onChange,
157+ className,
158+ placeholder : "Username" ,
159+ } ) ,
160+ h ( "input" , {
161+ type : "password" ,
162+ name : "password" ,
163+ value : state . password ,
164+ onChange,
165+ className,
166+ placeholder : "Password" ,
167+ } ) ,
168+ h (
169+ Button ,
170+ {
171+ intent : Intent . PRIMARY ,
172+ large : true ,
173+ type : "submit" ,
174+ disabled : ! isValid ( state ) ,
175+ } ,
176+ "Login"
177+ ) ,
178+ ]
179+ ) ,
180+ ] ) ;
181+ }
156182}
157183function InnerPage ( ) {
158184 return h ( "div" , { className : "container" } , [
0 commit comments