1
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
2
|
import {FormGroup} from '@angular/forms';
|
3
|
import {EnvProperties} from "../utils/properties/env-properties";
|
4
|
import {Observable} from "rxjs";
|
5
|
import {map, startWith} from "rxjs/operators";
|
6
|
|
7
|
@Component({
|
8
|
selector: 'contact-us',
|
9
|
templateUrl: './contact-us.component.html',
|
10
|
})
|
11
|
|
12
|
export class ContactUsComponent implements OnInit {
|
13
|
@Input()
|
14
|
public contactForm: FormGroup;
|
15
|
@Input() formTitle: string;
|
16
|
@Input() properties: EnvProperties;
|
17
|
@Output() sendEmitter: EventEmitter<any> = new EventEmitter<any>();
|
18
|
@Input() errorMessage;
|
19
|
@Input()
|
20
|
public organizationTypes: string[];
|
21
|
public autoCompleteTypes: Observable<string[]>;
|
22
|
|
23
|
constructor() {
|
24
|
}
|
25
|
|
26
|
ngOnInit() {
|
27
|
this.autoCompleteTypes = this.contactForm.get('organizationType').valueChanges
|
28
|
.pipe(
|
29
|
startWith(''),
|
30
|
map(value => this._filter(value))
|
31
|
);
|
32
|
}
|
33
|
|
34
|
private _filter(value: string): string[] {
|
35
|
const filterValue = value.toLowerCase();
|
36
|
return this.organizationTypes.filter(option => option.toLowerCase().includes(filterValue));
|
37
|
}
|
38
|
|
39
|
public send() {
|
40
|
this.sendEmitter.emit({
|
41
|
valid: this.contactForm.valid
|
42
|
});
|
43
|
}
|
44
|
|
45
|
public handleRecaptcha(captchaResponse: string) {
|
46
|
this.contactForm.get('recaptcha').setValue(captchaResponse);
|
47
|
}
|
48
|
}
|