diff --git a/src/app/components/contact-form/contact-form.html b/src/app/components/contact-form/contact-form.html index a199972..a8e31bd 100644 --- a/src/app/components/contact-form/contact-form.html +++ b/src/app/components/contact-form/contact-form.html @@ -1,5 +1,6 @@ -
- {{strings.addContact|upperfirst}}.{{strings.allFieldRequired|upperfirst}} + + +
(); + form = input(new FormGroupContact()); protected strings = inject(STRINGS_INJECTOR); protected companyAndNameErrorsDictionary = new NameAndCompanyFieldsErrorsDictionary().getDictionary(); protected phoneErrorsDictionary = new PhoneFieldErroresDictionary().getDictionary(); + handleSubmit(contactForm: ContactFormValue) { + if(contactForm.company === null || contactForm.name === null || contactForm.phone === null) return; + const contact = new ContactDTO(undefined, contactForm.name, contactForm.company, contactForm.phone); + this.contact.emit(contact); + this.form().reset(); + } } diff --git a/src/app/types/ContactFormValue.type.ts b/src/app/types/ContactFormValue.type.ts new file mode 100644 index 0000000..ec466db --- /dev/null +++ b/src/app/types/ContactFormValue.type.ts @@ -0,0 +1 @@ +export type ContactFormValue = Partial<{name: string|null, company: string|null, phone: string|null}>; \ No newline at end of file