-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.ts
More file actions
41 lines (37 loc) · 1.17 KB
/
send.ts
File metadata and controls
41 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
@Component({
templateUrl: './send.html',
})
export class SendDocumentUsingTemplateComponent implements OnInit {
userForm!: FormGroup;
isDocumentSend!: boolean;
showLoading!: boolean;
documentId!: string;
constructor(private formBuilder: FormBuilder, private http: HttpClient) {}
onSubmit(): void {
this.isDocumentSend = false;
if (this.userForm.invalid) {
console.warn('Fill required fields');
} else {
this.showLoading = true;
this.http
.post('http://localhost:8080/api/template/send', this.userForm.value)
.subscribe((data) => {
this.showLoading = false;
this.isDocumentSend = true;
this.documentId = (data as any).documentId;
});
}
}
ngOnInit() {
this.isDocumentSend = false;
this.showLoading = false;
this.userForm = this.formBuilder.group({
templateId: ['', Validators.required],
name: ['', Validators.required],
email: ['', [Validators.required, Validators.email]],
});
}
}