2323 let demoEmail = $state (' ' );
2424 let heroSubmitted = $state (false );
2525 let demoSubmitted = $state (false );
26+ let heroError = $state (' ' );
27+ let demoError = $state (' ' );
28+ let heroLoading = $state (false );
29+ let demoLoading = $state (false );
30+
31+ const BETA_SIGNUP_URL = ' https://dev.context-engine.ai/auth/beta-signup' ;
2632
2733 // Features data
2834 const features = [
170176
171177 async function handleHeroSubmit(e : SubmitEvent ) {
172178 e .preventDefault ();
179+ heroError = ' ' ;
180+ heroLoading = true ;
173181 try {
174- const response = await fetch (' https://formspree.io/f/xojjvnkd ' , {
182+ const response = await fetch (BETA_SIGNUP_URL , {
175183 method: ' POST' ,
176184 headers: { ' Content-Type' : ' application/json' },
177- body: JSON .stringify ({ email: heroEmail , subject: ' Early Access Request ' })
185+ body: JSON .stringify ({ email: heroEmail })
178186 });
187+ const data = await response .json ();
179188 if (response .ok ) {
180189 heroSubmitted = true ;
190+ } else {
191+ heroError = data .detail || ' Something went wrong. Please try again.' ;
181192 }
182193 } catch (error ) {
183- console .error (' Form submission error:' , error );
194+ heroError = ' Network error. Please try again.' ;
195+ } finally {
196+ heroLoading = false ;
184197 }
185198 }
186199
187200 async function handleDemoSubmit(e : SubmitEvent ) {
188201 e .preventDefault ();
202+ demoError = ' ' ;
203+ demoLoading = true ;
189204 try {
190- const response = await fetch (' https://formspree.io/f/xojjvnkd ' , {
205+ const response = await fetch (BETA_SIGNUP_URL , {
191206 method: ' POST' ,
192207 headers: { ' Content-Type' : ' application/json' },
193- body: JSON .stringify ({ email: demoEmail , subject: ' Request Invite ' })
208+ body: JSON .stringify ({ email: demoEmail })
194209 });
210+ const data = await response .json ();
195211 if (response .ok ) {
196212 demoSubmitted = true ;
213+ } else {
214+ demoError = data .detail || ' Something went wrong. Please try again.' ;
197215 }
198216 } catch (error ) {
199- console .error (' Form submission error:' , error );
217+ demoError = ' Network error. Please try again.' ;
218+ } finally {
219+ demoLoading = false ;
200220 }
201221 }
202222 </script >
221241 codebase to AI. Start coding.
222242 </p >
223243
224- {#if heroSubmitted }
244+ {#if heroSubmitted }
225245 <div class =" hero-form" style =" color: var(--accent); font-size: 16px;" >
226- Thanks! We'll be in touch at {heroEmail }
246+ Beta key sent! Check your email at {heroEmail }
227247 </div >
228248 {:else }
229249 <form class ="hero-form" onsubmit ={handleHeroSubmit }>
233253 placeholder =" you@company.com"
234254 required
235255 bind:value ={heroEmail }
256+ disabled ={heroLoading }
236257 />
237- <button type =" submit" class =" btn btn-primary btn-lg" >Request Early Access</button >
258+ <button type ="submit" class ="btn btn-primary btn-lg" disabled ={heroLoading }>
259+ {heroLoading ? ' Sending…' : ' Request Early Access' }
260+ </button >
238261 </form >
262+ {#if heroError }
263+ <div style ="color: #ef4444; font-size: 14px; margin-top: 8px;" >{heroError }</div >
264+ {/if }
239265 {/if }
240266
241267 <div class =" hero-actions" >
@@ -408,7 +434,7 @@ result = <span class="c-fn">repo_search</span>(
408434
409435 {#if demoSubmitted }
410436 <div class =" demo-form" style =" color: var(--accent); font-size: 16px; justify-content: center;" >
411- Thanks! We'll be in touch at {demoEmail }
437+ Beta key sent! Check your email at {demoEmail }
412438 </div >
413439 {:else }
414440 <form class ="demo-form" onsubmit ={handleDemoSubmit }>
@@ -418,9 +444,15 @@ result = <span class="c-fn">repo_search</span>(
418444 placeholder =" you@company.com"
419445 required
420446 bind:value ={demoEmail }
447+ disabled ={demoLoading }
421448 />
422- <button type =" submit" class =" btn btn-primary btn-lg" >Request Invite</button >
449+ <button type ="submit" class ="btn btn-primary btn-lg" disabled ={demoLoading }>
450+ {demoLoading ? ' Sending…' : ' Request Invite' }
451+ </button >
423452 </form >
453+ {#if demoError }
454+ <div style ="color: #ef4444; font-size: 14px; margin-top: 8px; text-align: center;" >{demoError }</div >
455+ {/if }
424456 {/if }
425457</section >
426458
0 commit comments