146146      </ div > 
147147    </ nav > 
148148
149-     < h1  id ="user " style ="text-align: center "> < b > Coding Hut</ b > </ h1 > 
150-     < h2  style ="text-align: center "> Welcome to your dashboard</ h2 > 
151-     < p  id ="data " style ="text-align: center "> COMING SOON</ p > 
152- 
153-     < div  class ="settings-form "> 
154-       < h3 > Update Your Settings</ h3 > 
155-       < form  id ="settings-form "> 
156-         < input  type ="email " id ="email " placeholder ="Update your email " /> 
157-         < input  type ="number " id ="points " placeholder ="Update your points " /> 
158-         < button  type ="submit "> Save Settings</ button > 
159-       </ form > 
160-     </ div > 
149+     < h1  id ="user " style ="text-align: center "> < b > Login to see your dashboard!</ b > </ h1 > 
150+     < h2  style ="text-align: center "> Welcome to your dashboard!</ h2 > 
151+     < p  id ="data " style ="text-align: center "> Loading...</ p > 
152+ 
153+ 
161154
162155    < script > 
163156      async  function  loadUserData ( )  { 
@@ -179,48 +172,6 @@ <h3>Update Your Settings</h3>
179172          } 
180173        } 
181174      } 
182- 
183-       async  function  updateUserSettings ( event )  { 
184-         event . preventDefault ( ) ; 
185- 
186-         const  username  =  localStorage . getItem ( "username" ) ; 
187-         const  email  =  document . getElementById ( "email" ) . value ; 
188-         const  points  =  document . getElementById ( "points" ) . value ; 
189- 
190-         if  ( ! email  &&  ! points )  { 
191-           alert ( "Please enter at least one value to update." ) ; 
192-           return ; 
193-         } 
194- 
195-         const  updatedData  =  { } ; 
196-         if  ( email )  updatedData . email  =  email ; 
197-         if  ( points )  updatedData . points  =  parseInt ( points ) ; 
198- 
199-         try  { 
200-           const  res  =  await  fetch ( `https://scratch-coding-hut-data.onrender.com/${ username }  ,  { 
201-             method : "PUT" , 
202-             headers : { 
203-               "Content-Type" : "application/json" , 
204-             } , 
205-             body : JSON . stringify ( updatedData ) , 
206-           } ) ; 
207- 
208-           const  data  =  await  res . json ( ) ; 
209- 
210-           if  ( data )  { 
211-             document . getElementById ( "data" ) . textContent  =  JSON . stringify ( data ) ; 
212-             alert ( "Settings updated successfully!" ) ; 
213-           }  else  { 
214-             alert ( "Error updating settings." ) ; 
215-           } 
216-         }  catch  ( error )  { 
217-           console . error ( "Error updating data:" ,  error ) ; 
218-           alert ( "Failed to update settings." ) ; 
219-         } 
220-       } 
221- 
222-       document . getElementById ( "settings-form" ) . addEventListener ( "submit" ,  updateUserSettings ) ; 
223- 
224175      function  toggleMenu ( )  { 
225176        var  menu  =  document . querySelector ( ".menu" ) ; 
226177        menu . style . display  =  menu . style . display  ===  "flex"  ? "none"  : "flex" ; 
0 commit comments