From c14f62849fc00d401c7c420e2a1ec1f7b8f53f34 Mon Sep 17 00:00:00 2001 From: Marek Lesko Date: Fri, 7 Nov 2025 17:08:09 +0000 Subject: [PATCH] feat: integrate Toastr for user feedback in contact form submission #15 --- .../app/pages/front-pages/contact/contact.component.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Web/src/app/pages/front-pages/contact/contact.component.ts b/Web/src/app/pages/front-pages/contact/contact.component.ts index de0adae..bc70382 100755 --- a/Web/src/app/pages/front-pages/contact/contact.component.ts +++ b/Web/src/app/pages/front-pages/contact/contact.component.ts @@ -4,6 +4,7 @@ import { MaterialModule } from '../../../material.module'; import { FooterComponent } from '../footer/footer.component'; import { FormsModule } from '@angular/forms'; import { HttpClient } from '@angular/common/http'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-contact', @@ -24,7 +25,7 @@ export class ContactComponent implements AfterViewInit { @ViewChild('recaptcha', { static: false }) recaptchaElem!: ElementRef; widgetId: number | null = null; - constructor(private http: HttpClient) { } + constructor(private http: HttpClient, private toastr: ToastrService) { } ngAfterViewInit(): void { const win: any = window as any; @@ -58,7 +59,7 @@ export class ContactComponent implements AfterViewInit { if (!token) { // optionally show UI feedback to complete captcha - alert('Prosím, potvrďte reCAPTCHA.'); + this.toastr.warning('Prosím, potvrďte reCAPTCHA.', 'Upozornenie'); return; } @@ -75,7 +76,7 @@ export class ContactComponent implements AfterViewInit { // POST to your backend endpoint which must verify the token with Google this.http.post('/api/webmessages', payload).subscribe({ next: () => { - alert('Správa odoslaná'); + this.toastr.success('Správa odoslaná', 'Úspech'); // reset widget if (grecaptchaAny && grecaptchaAny.reset) { if (this.widgetId !== null) grecaptchaAny.reset(this.widgetId); @@ -84,7 +85,7 @@ export class ContactComponent implements AfterViewInit { }, error: (err) => { console.error(err); - alert('Chyba pri odosielaní — skúste znova.'); + this.toastr.error('Chyba pri odosielaní — skúste znova.', 'Chyba'); } }); }