Skip to content

Commit 9e75b29

Browse files
ktx-krupaMonil-KTX
andauthored
Feat/integration of news letter and feedback menu (#194)
* Add feedback widget and modal for user feedback submission - Introduced a feedback button in the footer that opens a modal for users to submit feedback. - Created a feedback modal with tabs for different feedback types (Issue, Idea, Other). - Implemented JavaScript functionality to handle modal opening, closing, and form submission. - Added SVG icon for the feedback button. - Styled the feedback modal and button using Tailwind CSS classes. - Included error handling for feedback submission failures. - Ensured responsive design for the feedback modal across different screen sizes. * feat: implement newsletter subscription with reCAPTCHA validation * feat: add segment related code for the send data to swisspipe * fix: update placeholder for other * fix: update capcha related code --------- Co-authored-by: ktx-monil <[email protected]>
1 parent e8eeb1d commit 9e75b29

File tree

1 file changed

+57
-35
lines changed

1 file changed

+57
-35
lines changed

overrides/partials/footer.html

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
</form>
165165
<div
166166
id="newsletter-toast"
167-
class="tw-fixed tw-bottom-5 tw-right-2 tw-transform tw-bg-[#7782FF] tw-text-white tw-p-6 tw-rounded-lg tw-shadow-lg tw-z-50 tw-hidden tw-transition-opacity tw-duration-300"
167+
class="tw-fixed tw-bottom-5 tw-right-2 tw-transform tw-bg-[#7782FF] tw-text-white tw-p-6 tw-rounded-lg tw-shadow-lg tw-z-50 tw-hidden tw-transition-opacity tw-duration-300 tw-text-base"
168168
></div>
169169
</div>
170170

@@ -284,11 +284,11 @@
284284
) {
285285
recaptchaToken = token;
286286

287-
// Hide loader, show success state briefly
288-
const loader = document.getElementById("newsletter-captcha-loader");
289-
if (loader) {
290-
loader.style.display = "flex";
291-
}
287+
// // Hide loader immediately on success
288+
// const loader = document.getElementById("newsletter-captcha-loader");
289+
// if (loader) {
290+
// loader.style.display = "none";
291+
// }
292292

293293
// Auto-submit after reCAPTCHA completion (like Vue component)
294294
setTimeout(async () => {
@@ -307,8 +307,8 @@
307307
);
308308
if (!recaptchaContainer) return;
309309

310-
// If widget already exists, don't create another one
311-
if (recaptchaWidgetId !== null) return;
310+
// Clear any existing widget content first
311+
recaptchaContainer.innerHTML = "";
312312

313313
try {
314314
recaptchaWidgetId = window.grecaptcha.render(recaptchaContainer, {
@@ -317,7 +317,10 @@
317317
"expired-callback": window.onRecaptchaExpired,
318318
theme: "dark",
319319
});
320-
} catch (error) {}
320+
} catch (error) {
321+
// If render fails, reset the widget ID
322+
recaptchaWidgetId = null;
323+
}
321324
}
322325

323326
// Submit form function (like Vue component)
@@ -334,18 +337,25 @@
334337
container.classList.add("tw-flex");
335338
}
336339

337-
// Hide loader when showing reCAPTCHA
340+
// Ensure loader is hidden when showing reCAPTCHA
338341
if (loader) {
339342
loader.style.display = "none";
340343
}
341344

342-
// Wait for DOM update, then render reCAPTCHA
345+
// Always try to initialize reCAPTCHA, even if widget exists
343346
setTimeout(() => {
344-
if (
345-
recaptchaDiv &&
346-
window.grecaptcha &&
347-
recaptchaWidgetId === null
348-
) {
347+
if (recaptchaDiv && window.grecaptcha) {
348+
// Destroy existing widget if it exists
349+
if (recaptchaWidgetId !== null) {
350+
try {
351+
window.grecaptcha.reset(recaptchaWidgetId);
352+
} catch (error) {
353+
// If reset fails, clear the container
354+
recaptchaDiv.innerHTML = "";
355+
}
356+
recaptchaWidgetId = null;
357+
}
358+
// Always create a new widget
349359
initializeRecaptcha();
350360
}
351361
}, 100);
@@ -370,6 +380,12 @@
370380
return;
371381
}
372382

383+
// Hide loader during processing
384+
const loader = document.getElementById("newsletter-captcha-loader");
385+
if (loader) {
386+
loader.style.display = "none";
387+
}
388+
373389
try {
374390
isSubmitting = true;
375391

@@ -420,16 +436,19 @@
420436
if (window.grecaptcha && recaptchaWidgetId !== null) {
421437
try {
422438
window.grecaptcha.reset(recaptchaWidgetId);
423-
// Clear the container completely
424-
const recaptchaDiv = document.getElementById(
425-
"newsletter-recaptcha"
426-
);
427-
if (recaptchaDiv) {
428-
recaptchaDiv.innerHTML = "";
429-
}
430-
recaptchaWidgetId = null;
431-
} catch (error) {}
439+
} catch (error) {
440+
// Silent error handling
441+
}
442+
}
443+
444+
// Clear the container and reset widget ID
445+
const recaptchaDiv = document.getElementById(
446+
"newsletter-recaptcha"
447+
);
448+
if (recaptchaDiv) {
449+
recaptchaDiv.innerHTML = "";
432450
}
451+
recaptchaWidgetId = null;
433452
recaptchaToken = "";
434453

435454
// Analytics tracking
@@ -472,16 +491,19 @@
472491
if (window.grecaptcha && recaptchaWidgetId !== null) {
473492
try {
474493
window.grecaptcha.reset(recaptchaWidgetId);
475-
// Clear the container completely
476-
const recaptchaDiv = document.getElementById(
477-
"newsletter-recaptcha"
478-
);
479-
if (recaptchaDiv) {
480-
recaptchaDiv.innerHTML = "";
481-
}
482-
recaptchaWidgetId = null;
483-
} catch (error) {}
494+
} catch (error) {
495+
// Silent error handling
496+
}
497+
}
498+
499+
// Clear the container and reset widget ID
500+
const recaptchaDiv = document.getElementById(
501+
"newsletter-recaptcha"
502+
);
503+
if (recaptchaDiv) {
504+
recaptchaDiv.innerHTML = "";
484505
}
506+
recaptchaWidgetId = null;
485507
recaptchaToken = "";
486508

487509
// GTM error tracking
@@ -817,7 +839,7 @@
817839
id="feedback-tab-other"
818840
role="tab"
819841
aria-selected="false"
820-
data-type="Other"
842+
data-type="Feedback"
821843
class="feedback-tab tw-flex tw-items-center tw-gap-2 tw-py-1.5 tw-rounded-md tw-text-xs tw-font-medium tw-transition-all tw-flex-1 tw-justify-center tw-cursor-pointer tw-border tw-border-gray-400 tw-text-gray-600 hover:tw-text-gray-900 hover:tw-bg-gray-100 hover:tw-border-gray-200"
822844
style="border: 1px solid gray !important"
823845
>

0 commit comments

Comments
 (0)