1010 < link rel ="shortcut icon " href ="Favicon.png " type ="image/x-icon " />
1111 < link rel ="stylesheet " href ="dark_mode.css " />
1212 < link rel ="stylesheet " href ="navstyle.css " />
13+ < script type ="text/javascript "
14+ src ="https://cdn.jsdelivr.net/npm/@emailjs/browser@4/dist/email.min.js ">
15+ </ script >
1316</ head >
1417< body >
1518 < header class ="header ">
@@ -77,19 +80,19 @@ <h1>HelpOps-Hub</h1>
7780 </ div >
7881 < div id ="feedback-section ">
7982 < h2 > Feedback</ h2 >
80- < form class ="feedback-form " id ="feedback-form ">
83+ < form class ="feedback-form " id ="feedback-form ">
8184 < label for ="name "> Name</ label >
8285 < input type ="text " id ="name " name ="name " required />
8386
8487 < label for ="email "> Email</ label >
85- < input type ="email " id ="email " name ="email " required />
88+ < input type ="email " id ="email " name ="user_email " required />
8689
8790 < label for ="comments "> Comments</ label >
88- < textarea id ="comments " name ="comments " required > </ textarea >
91+ < textarea id ="comments " name ="message " required > </ textarea >
8992
9093 < label for ="rating "> Rating</ label >
9194 < div class ="rating ">
92- < input type ="radio " id ="star1 " name ="rating " value ="1 " /> < label for =" star1 " title =" 1 star " > ★ </ label >
95+ < label for =" star1 " title =" 1 star " > ★ </ label > < input type ="radio " id ="star1 " name ="rating " value ="1 " />
9396 < input type ="radio " id ="star2 " name ="rating " value ="2 " /> < label for ="star2 " title ="2 stars "> ★</ label >
9497 < input type ="radio " id ="star3 " name ="rating " value ="3 " /> < label for ="star3 " title ="3 stars "> ★</ label >
9598 < input type ="radio " id ="star4 " name ="rating " value ="4 " /> < label for ="star4 " title ="4 stars "> ★</ label >
@@ -110,11 +113,46 @@ <h2>Feedback</h2>
110113
111114 < script src ="app.js "> </ script >
112115 < script src ="darkmode.js "> </ script >
116+ < script type ="text/javascript ">
117+ ( function ( ) {
118+ emailjs . init ( {
119+ publicKey : "rId2aw03Pj2ZNq2U5" ,
120+ } ) ;
121+ } ) ( ) ;
122+ </ script >
123+ < script >
124+ document . getElementById ( "feedback-form" ) . reset ( ) ;
125+
126+ </ script >
113127 < script >
114128 // Feedback JS
115129 document . getElementById ( "feedback-form" ) . addEventListener ( "submit" , function ( event ) {
116130 event . preventDefault ( ) ;
117-
131+ var rating = document . querySelector ( 'input[name="rating"]:checked' ) . value
132+ if ( ! rating ) {
133+ var errorMessage = document . getElementById ( "error-message" ) ;
134+ errorMessage . innerText = "Please select a Rating!" ;
135+ errorMessage . style . display = "block" ;
136+ setTimeout ( function ( ) {
137+ errorMessage . style . display = "none" ;
138+ } , 3000 ) ;
139+ return ;
140+ }
141+ let temp = document . getElementById ( 'comments' ) . value
142+ document . getElementById ( 'comments' ) . value = `Comments : ${ document . getElementById ( "comments" ) . value } Rating : ${ document . querySelector ( 'input[name="rating"]:checked' ) . value } ` ;
143+
144+ emailjs . sendForm ( 'service_hrz8hfg' , 'template_na7xjc4' , "#feedback-form" ) . then (
145+ ( response ) => {
146+ console . log ( 'SUCCESS!' , response . status , response . text ) ;
147+ } ,
148+ ( error ) => {
149+ console . log ( 'FAILED...' , error ) ;
150+ } ,
151+ ) ;
152+ document . getElementById ( 'comments' ) . value = temp
153+
154+
155+
118156 if ( ! document . querySelector ( 'input[name="rating"]:checked' ) ) {
119157 var errorMessage = document . getElementById ( "error-message" ) ;
120158 errorMessage . innerText = "Please select a rating!" ;
@@ -130,7 +168,6 @@ <h2>Feedback</h2>
130168 comments : document . getElementById ( "comments" ) . value ,
131169 rating : document . querySelector ( 'input[name="rating"]:checked' ) . value
132170 } ;
133- console . log ( formData ) ;
134171 fetch ( 'https://helpops-hub.vercel.app/feedback' , {
135172 method : 'POST' ,
136173 headers : {
@@ -157,7 +194,13 @@ <h2>Feedback</h2>
157194 errorMessage . style . display = "none" ;
158195 } , 3000 ) ;
159196 } ) ;
160- } ) ;
197+
198+
199+
200+
201+
202+
203+ } ) ;
161204 </ script >
162205</ body >
163206</ html >
0 commit comments