11<template >
2+ <div id =" captcha-modal-container" ></div >
23 <div class =" feedback-form-holder" >
34 <div class =" feedback-form" :class =" { 'gradient-border': !isMobile, 'hidden': !isFormDisplayed }" >
45 <div class =" form-header" >
4546 </div >
4647 </form >
4748 </div >
48- <div class =" ready-alert" :class =" { 'hidden': !isRequestSent }" >Thank you!
49- Our technical support will get in touch with you soon!</div >
49+ <div class =" ready-alert" :class =" { 'hidden': !isRequestSent }" >
50+ Thank you!
51+ Our technical support will get in touch with you soon!
52+ </div >
53+ <div class =" error-alert" :class =" { 'hidden': !isRequestErrored }" >
54+ Something went wrong! Please, try again later
55+ </div >
5056 <div class =" feedback-form-launcher" :class =" { 'hidden': isFormDisplayed }" >
5157 <button @click =" toggleFormVisibility" >
5258 <img src =" /assets/images/common/feedback.webp" alt =" feedback" />
@@ -75,8 +81,10 @@ const EMAIL_VALIDATION_REGEX: RegExp = new RegExp(
7581export default {
7682 data() {
7783 return {
84+ isCaptchaReady: false ,
7885 isRequestHandling: false as boolean ,
7986 isRequestSent: false as boolean ,
87+ isRequestErrored: false as boolean ,
8088 isFormDisplayed: false as boolean ,
8189 name: ' ' as string ,
8290 email: ' ' as string ,
@@ -125,9 +133,14 @@ export default {
125133 },
126134 async showAlert(): Promise <void > {
127135 this .isRequestSent = true ;
128- await new Promise (r => setTimeout (r , 2000 ));
136+ await new Promise (r => setTimeout (r , 5000 ));
129137 this .isRequestSent = false ;
130138 },
139+ async showError(): Promise <void > {
140+ this .isRequestErrored = true ;
141+ await new Promise (r => setTimeout (r , 5000 ));
142+ this .isRequestErrored = false ;
143+ },
131144 async sendFeedback(): Promise <void > {
132145 try {
133146 const options: RequestInit = {
@@ -149,15 +162,16 @@ export default {
149162 attachment_details: {},
150163 })
151164 };
152- if (! this .isRequestHandling ) {
165+ if (! this .isRequestHandling && this . $captcha . isReady ) {
153166 this .isRequestHandling = true ;
154- await fetch (endpoints .FEEDBACK , options );
167+ await this . $captcha ?. fetch ?. (endpoints .FEEDBACK , options );
155168 }
156169 this .isFormDisplayed = false ;
157170 await this .showAlert ();
158171 } catch (error ) {
159172 this .isFormDisplayed = false ;
160173 console .log (" error on feedback request: " , error );
174+ this .showError ();
161175 } finally {
162176 this .resetForm ();
163177 this .isRequestHandling = false ;
@@ -202,6 +216,7 @@ export default {
202216 background : var (--feedback-form-background );
203217}
204218
219+ .error-alert.hidden ,
205220.ready-alert.hidden ,
206221.feedback-form.hidden ,
207222.feedback-form-launcher.hidden {
@@ -335,16 +350,26 @@ form {
335350 transform : scale (1.1 );
336351}
337352
353+ .error-alert ,
338354.ready-alert {
339355 width : 200px ;
340356 position : absolute ;
341357 right : 100px ;
342358 bottom : 30px ;
343359 padding : 10px ;
344360 border-radius : 8px ;
361+ backdrop-filter : blur (5px );
362+ transition : var (--feedback-form-transition ) all ;
363+ }
364+
365+ .error-alert {
366+ color : var (--vp-c-caution-3 );
367+ background-color : var (--vp-c-danger-soft );
368+ }
369+
370+ .ready-alert {
345371 color : var (--vp-c-green-1 );
346372 background-color : var (--vp-c-green-soft );
347- transition : var (--feedback-form-transition ) all ;
348373}
349374
350375@media (max-width : 450px ) {
0 commit comments