Skip to content

Commit 48fed38

Browse files
committed
ADDS thank you message to contact us form
1 parent 677b7bc commit 48fed38

2 files changed

Lines changed: 69 additions & 14 deletions

File tree

src/app/pages/contact-us/contact-us-form.component.html

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,45 @@ <h2 class="text-left text-2xl mb-2 font-bold dark:text-white">Please fill in thi
2121
<div>
2222
<label for="email" class="font-bold text-lg dark:text-white">Email</label>
2323
<input formControlName="email" type="text" id="email"
24-
[ngClass]="(contactForm.get('email')?.invalid == true && contactForm.value.email!='') || (contactForm.get('email')?.touched && contactForm.value.email=='') ? 'border-red-600' : 'border-gray-300 dark:border-secondary-200'"
24+
[ngClass]="contactForm.get('email')?.touched && contactForm.get('email')?.invalid
25+
? 'border-red-600'
26+
: 'border-gray-300 dark:border-secondary-200'"
2527
class="mb-2 bg-gray-50 dark:bg-secondary-300 border dark:text-white text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" />
2628
@if(contactForm.get('email')?.invalid && contactForm.get('email')?.errors?.['maxlength']){
2729
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">Email is too long. Must be less than 320 characters.</span></p>
2830
}
2931
@if(contactForm.get('email')?.invalid && contactForm.get('email')?.errors?.['pattern']){
3032
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">Email must follow the following format: example&#64;example.example</span></p>
3133
}
32-
@if(contactForm.get('email')?.invalid && contactForm.get('email')?.errors?.['required'] && (contactForm.get('email')?.touched && contactForm.value.email=='')){
34+
@if(contactForm.get('email')?.touched && contactForm.get('email')?.hasError('required')){
3335
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is mandatory.</span></p>
3436
}
3537
</div>
3638
<div>
3739
<label for="name" class="font-bold text-lg dark:text-white">First name</label>
3840
<input formControlName="name" type="text" id="name"
39-
[ngClass]="(contactForm.get('name')?.invalid == true && contactForm.value.name!='') || (contactForm.get('name')?.touched && contactForm.value.name=='') ? 'border-red-600' : 'border-gray-300 dark:border-secondary-200'"
41+
[ngClass]="contactForm.get('name')?.touched && contactForm.get('name')?.invalid
42+
? 'border-red-600'
43+
: 'border-gray-300 dark:border-secondary-200'"
4044
class="mb-2 bg-gray-50 dark:bg-secondary-300 border dark:text-white text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" />
4145
@if(contactForm.get('name')?.invalid && contactForm.get('name')?.errors?.['maxlength']){
4246
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is too long. Must be less than 100 characters.</span></p>
4347
}
44-
@if(contactForm.get('name')?.invalid && contactForm.get('name')?.errors?.['required'] && (contactForm.get('name')?.touched && contactForm.value.name=='')){
48+
@if(contactForm.get('name')?.touched && contactForm.get('name')?.hasError('required')){
4549
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is mandatory.</span></p>
4650
}
4751
</div>
4852
<div>
4953
<label for="lastname" class="font-bold text-lg dark:text-white">Last name</label>
5054
<input formControlName="lastname" type="text" id="lastname"
51-
[ngClass]="(contactForm.get('lastname')?.invalid == true && contactForm.value.lastname!='') || (contactForm.get('lastname')?.touched && contactForm.value.lastname=='') ? 'border-red-600' : 'border-gray-300 dark:border-secondary-200'"
55+
[ngClass]="contactForm.get('lastname')?.touched && contactForm.get('lastname')?.invalid
56+
? 'border-red-600'
57+
: 'border-gray-300 dark:border-secondary-200'"
5258
class="mb-2 bg-gray-50 dark:bg-secondary-300 border dark:text-white text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" />
5359
@if(contactForm.get('lastname')?.invalid && contactForm.get('lastname')?.errors?.['maxlength']){
5460
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is too long. Must be less than 100 characters.</span></p>
5561
}
56-
@if(contactForm.get('lastname')?.invalid && contactForm.get('lastname')?.errors?.['required'] && (contactForm.get('lastname')?.touched && contactForm.value.lastname=='')){
62+
@if(contactForm.get('lastname')?.touched && contactForm.get('lastname')?.hasError('required')){
5763
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is mandatory.</span></p>
5864
}
5965
</div>
@@ -62,34 +68,40 @@ <h2 class="text-left text-2xl mb-2 font-bold dark:text-white">Please fill in thi
6268
<div>
6369
<label for="organization" class="font-bold text-lg dark:text-white">Organization</label>
6470
<input formControlName="organization" type="text" id="organization"
65-
[ngClass]="(contactForm.get('organization')?.invalid == true && contactForm.value.organization!='') || (contactForm.get('organization')?.touched && contactForm.value.organization=='') ? 'border-red-600' : 'border-gray-300 dark:border-secondary-200'"
71+
[ngClass]="contactForm.get('organization')?.touched && contactForm.get('organization')?.invalid
72+
? 'border-red-600'
73+
: 'border-gray-300 dark:border-secondary-200'"
6674
class="mb-2 bg-gray-50 dark:bg-secondary-300 border dark:text-white text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" />
6775
@if(contactForm.get('organization')?.invalid && contactForm.get('organization')?.errors?.['maxlength']){
6876
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is too long. Must be less than 100 characters.</span></p>
6977
}
70-
@if(contactForm.get('organization')?.invalid && contactForm.get('organization')?.errors?.['required'] && (contactForm.get('organization')?.touched && contactForm.value.organization=='')){
78+
@if(contactForm.get('organization')?.touched && contactForm.get('organization')?.hasError('required')){
7179
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is mandatory.</span></p>
7280
}
7381
</div>
7482
<div>
7583
<label for="role" class="font-bold text-lg dark:text-white">Role in organization</label>
7684
<input formControlName="role" type="text" id="role"
77-
[ngClass]="(contactForm.get('role')?.invalid == true && contactForm.value.role!='') || (contactForm.get('role')?.touched && contactForm.value.role=='') ? 'border-red-600' : 'border-gray-300 dark:border-secondary-200'"
85+
[ngClass]="contactForm.get('role')?.touched && contactForm.get('role')?.invalid
86+
? 'border-red-600'
87+
: 'border-gray-300 dark:border-secondary-200'"
7888
class="mb-2 bg-gray-50 dark:bg-secondary-300 border dark:text-white text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" />
7989
@if(contactForm.get('role')?.invalid && contactForm.get('role')?.errors?.['maxlength']){
8090
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is too long. Must be less than 100 characters.</span></p>
8191
}
82-
@if(contactForm.get('role')?.invalid && contactForm.get('role')?.errors?.['required'] && (contactForm.get('role')?.touched && contactForm.value.role=='')){
92+
@if(contactForm.get('role')?.touched && contactForm.get('role')?.hasError('required')){
8393
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is mandatory.</span></p>
8494
}
8595
</div>
8696
</div>
8797
<div>
8898
<label for="organization" class="font-bold text-lg dark:text-white">Message</label>
8999
<textarea id="editor" formControlName="message" rows="8"
90-
[ngClass]="(contactForm.get('message')?.invalid == true && contactForm.value.message!='') || (contactForm.get('message')?.touched && contactForm.value.message=='') ? 'border-red-600' : 'border-gray-300 dark:border-secondary-200'"
100+
[ngClass]="contactForm.get('message')?.touched && contactForm.get('message')?.invalid
101+
? 'border-red-600'
102+
: 'border-gray-300 dark:border-secondary-200'"
91103
class="block w-full min-h-fit rounded-lg px-2 text-sm text-gray-800 dark:text-gray-200 border bg-white dark:bg-secondary-300" placeholder="Add product description..." ></textarea>
92-
@if(contactForm.get('message')?.invalid && contactForm.get('message')?.errors?.['required'] && (contactForm.get('message')?.touched && contactForm.value.message=='')){
104+
@if(contactForm.get('message')?.touched && contactForm.get('message')?.hasError('required')){
93105
<p class="text-sm text-red-600 dark:text-red-500"><span class="font-medium">This field is mandatory.</span></p>
94106
}
95107
</div>
@@ -113,5 +125,28 @@ <h2 class="text-left text-2xl mb-2 font-bold dark:text-white">Please fill in thi
113125
</button>
114126

115127
</form>
128+
</div>
129+
@if(showThanksMessage){
130+
<div class="fixed inset-0 flex items-center justify-center z-40">
131+
<div id="details-modal" tabindex="-1" aria-hidden="true" class="flex justify-center overflow-x-hidden justify-center items-center w-1/2 md:inset-0 h-full max-h-full rounded-lg $event.stopPropagation();">
132+
<div class="relative w-full max-w-7xl max-h-full rounded-t-lg" (click)="$event.stopPropagation();">
133+
<!-- Modal content -->
134+
<div class="relative sm:m-8 bg-white rounded-lg shadow dark:border-gray-600 dark:bg-secondary-100 bg-cover bg-right-bottom rounded-lg overflow-y-auto max-h-[calc(100vh-10rem)]">
135+
<button type="button" (click)="hide();$event.stopPropagation();" class="absolute top-4 right-4 z-50 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-hide="details-modal">
136+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
137+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
138+
</svg>
139+
<span class="sr-only">{{ 'CARD._close' | translate }}</span>
140+
</button>
141+
142+
<div class="w-full mb-4 rounded-t-lg p-8">
143+
144+
<fa-icon [icon]="faHandsHoldingHeart" class="text-5xl text-primary-50 align-middle mr-2"></fa-icon>
145+
<h5 class="md:text-3xl lg:text-4xl mt-2 font-semibold tracking-tight text-secondary-100 dark:text-white text-wrap break-all">Thank you for contacting DOME Marketplace.</h5>
116146

117-
</div>
147+
</div>
148+
</div>
149+
</div>
150+
</div>
151+
</div>
152+
}

src/app/pages/contact-us/contact-us-form.component.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component, HostListener, OnInit, ChangeDetectorRef} from '@angular/core';
2-
import { FormGroup, FormControl, Validators } from '@angular/forms';
2+
import { FormGroup, FormControl, Validators, FormArray } from '@angular/forms';
3+
import {faHandsHoldingHeart} from "@fortawesome/pro-solid-svg-icons";
34

45
@Component({
56
selector: 'app-contact-us-form',
@@ -17,8 +18,11 @@ export class ContactUsFormComponent implements OnInit {
1718
message: new FormControl('', [Validators.required]),
1819
});
1920

21+
protected readonly faHandsHoldingHeart = faHandsHoldingHeart;
22+
2023
dataControllerDome:any='https://dome-project.eu/about/#partners';
2124
DPA:any='https://dome-marketplace-sbx.org/assets/documents/privacy.pdf';
25+
showThanksMessage:boolean=false;
2226

2327
ngOnInit() {
2428
}
@@ -33,8 +37,24 @@ export class ContactUsFormComponent implements OnInit {
3337

3438
const mailtoLink = `mailto:info@dome-marketplace.eu?body=${message}`;
3539

40+
this.showThanksMessage=true;
3641
// Open the mailto link
3742
window.location.href = mailtoLink;
43+
this.resetContactForm();
3844
}
3945

46+
hide(){
47+
this.showThanksMessage=false;
48+
}
49+
resetContactForm(): void {
50+
this.contactForm.reset();
51+
52+
Object.values(this.contactForm.controls).forEach(control => {
53+
control.setErrors(null); // clear errors
54+
control.markAsPristine();
55+
control.markAsUntouched();
56+
control.updateValueAndValidity({ onlySelf: true, emitEvent: false });
57+
});
58+
}
59+
4060
}

0 commit comments

Comments
 (0)