@@ -21,7 +21,7 @@ pub fn Footer() -> impl IntoView {
2121 </p>
2222 <NewsletterForm />
2323 </div>
24-
24+
2525 <div class="footer-bottom" >
2626 <div class="footer-links" >
2727 <a href="https://blockstream.com/terms/" class="footer-link" >
@@ -57,7 +57,7 @@ fn NewsletterForm() -> impl IntoView {
5757
5858 let handle_submit = move |ev : leptos:: ev:: SubmitEvent | {
5959 ev. prevent_default ( ) ;
60-
60+
6161 let email_value = email. get ( ) ;
6262 if email_value. is_empty ( ) || !email_value. contains ( '@' ) {
6363 set_status. set ( FormStatus :: Error ) ;
@@ -66,12 +66,13 @@ fn NewsletterForm() -> impl IntoView {
6666 }
6767
6868 set_status. set ( FormStatus :: Loading ) ;
69-
69+
7070 spawn_local ( async move {
7171 match subscribe_to_newsletter ( email_value) . await {
7272 Ok ( _) => {
7373 set_status. set ( FormStatus :: Success ) ;
74- set_message. set ( "Thank you for subscribing! We'll keep you updated." . to_string ( ) ) ;
74+ set_message
75+ . set ( "Thank you for subscribing! We'll keep you updated." . to_string ( ) ) ;
7576 set_email. set ( String :: new ( ) ) ;
7677 }
7778 Err ( err) => {
@@ -96,8 +97,8 @@ fn NewsletterForm() -> impl IntoView {
9697 required
9798 />
9899 </div>
99- <button
100- type ="submit"
100+ <button
101+ type ="submit"
101102 class="newsletter-button"
102103 disabled=move || matches!( status. get( ) , FormStatus :: Loading )
103104 >
@@ -131,16 +132,16 @@ enum FormStatus {
131132async fn subscribe_to_newsletter ( email : String ) -> Result < ( ) , String > {
132133 use gloo_net:: http:: Request ;
133134 use serde_json:: json;
134-
135+
135136 let api_url = "https://simplicity-lang.org/api/subscribe" ;
136-
137+
137138 let response = Request :: post ( api_url)
138139 . header ( "Content-Type" , "application/json" )
139140 . json ( & json ! ( { "email" : email } ) )
140- . map_err ( |e| format ! ( "Failed to create request: {}" , e ) ) ?
141+ . map_err ( |e| format ! ( "Failed to create request: {e}" ) ) ?
141142 . send ( )
142143 . await
143- . map_err ( |e| format ! ( "Network error: {}" , e ) ) ?;
144+ . map_err ( |e| format ! ( "Network error: {e}" ) ) ?;
144145
145146 if response. ok ( ) {
146147 Ok ( ( ) )
@@ -153,7 +154,7 @@ async fn subscribe_to_newsletter(email: String) -> Result<(), String> {
153154 . unwrap_or ( "Subscription failed" ) ;
154155 Err ( error_msg. to_string ( ) )
155156 }
156- Err ( _) => Err ( "Subscription failed. Please try again." . to_string ( ) )
157+ Err ( _) => Err ( "Subscription failed. Please try again." . to_string ( ) ) ,
157158 }
158159 }
159160}
@@ -166,8 +167,8 @@ fn event_target_value(ev: &leptos::ev::Event) -> String {
166167}
167168
168169#[ cfg( not( target_arch = "wasm32" ) ) ]
169- fn spawn_local < F > ( _future : F )
170+ fn spawn_local < F > ( _future : F )
170171where
171172 F : std:: future:: Future < Output = ( ) > + ' static ,
172173{
173- }
174+ }
0 commit comments