diff --git a/src/app/contact/contact.component.html b/src/app/contact/contact.component.html index 1dc13668eb3f379fca17e95165724b246bf39fc4..d54ac4bfbf1ce8569e4d99e073dff96b24ebf1e3 100644 --- a/src/app/contact/contact.component.html +++ b/src/app/contact/contact.component.html @@ -1,123 +1,59 @@ -<div class="section-container"> - <form [formGroup]="contactForm" (ngSubmit)="onSubmit()"> - <div class="formFields"> - <h2>Nous contacter</h2> - <div class="form-group"> - <label for="name">Prénom et Nom</label> - <div fxLayout="row" fxLayoutGap="15px"> - <input type="text" autocomplete="on" formControlName="name" class="form-input" /> - <app-svg-icon - *ngIf="contactForm.get('name').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'validate'" - /> - <app-svg-icon - *ngIf="contactForm.get('name').value && !contactForm.get('name').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'notValidate'" - /> - </div> - </div> +<form class="contactForm" [formGroup]="contactForm" (ngSubmit)="onSubmit()"> + <h2>Nous contacter</h2> - <div class="form-group"> - <label for="email">Adresse mail</label> - <div fxLayout="row" fxLayoutGap="15px"> - <input type="text" autocomplete="on" formControlName="email" class="form-input" /> - <app-svg-icon - *ngIf="contactForm.get('email').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'validate'" - /> - <app-svg-icon - *ngIf="contactForm.get('email').value && !contactForm.get('email').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'notValidate'" - /> - </div> - </div> + <app-input + id="name" + label="Nom" + size="large" + [status]="contactForm.get('name').invalid ? null : 'success'" + [value]="contactForm.get('name').value" + (valueChange)="contactForm.get('name').setValue($event)" + /> - <div class="form-group"> - <label for="phone">N° de téléphone</label> - <p class="notRequired">facultatif</p> - <div fxLayout="row" fxLayoutGap="15px"> - <input - type="text" - autocomplete="on" - formControlName="phone" - class="form-input phone" - (input)="utils.modifyPhoneInput(contactForm, 'phone', $event.target)" - /> - <app-svg-icon - *ngIf="contactForm.get('phone').value && contactForm.get('phone').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'validate'" - /> - <app-svg-icon - *ngIf="contactForm.get('phone').value && !contactForm.get('phone').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'notValidate'" - /> - </div> - </div> + <app-input + id="email" + label="Adresse mail" + autocomplete="on" + size="large" + [status]="contactForm.get('email').value ? (contactForm.get('email').invalid ? 'error' : 'success') : null" + [statusText]="contactForm.get('email').hasError('alreadyExist') ? 'Cet email est déjà utilisé' : null" + [value]="contactForm.get('email').value" + (valueChange)="contactForm.get('email').setValue($event)" + /> - <div class="form-group"> - <label for="subject">Objet du message</label> - <div fxLayout="row" fxLayoutGap="15px"> - <input type="text" maxlength="100" formControlName="subject" class="form-input subject" /> - <app-svg-icon - *ngIf="contactForm.get('subject').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'validate'" - /> - <app-svg-icon - *ngIf="contactForm.get('subject').value && !contactForm.get('subject').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'notValidate'" - /> - </div> - </div> + <app-input + id="phone" + label="Téléphone" + size="large" + [status]="contactForm.get('phone').value ? (contactForm.get('phone').invalid ? 'error' : 'success') : null" + [value]="contactForm.get('phone').value" + (valueChange)="contactForm.get('phone').setValue($event); utils.modifyPhoneInput(contactForm, 'phone', $event)" + /> - <div class="form-group"> - <label for="message">Message</label> - <div class="textareaBlock" fxLayout="row" fxLayoutGap="15px"> - <textarea - rows="8" - placeholder="Exemple : J'aimerais avoir de l'aide sur Rés'in." - maxlength="500" - formControlName="message" - ></textarea> - <app-svg-icon - *ngIf="contactForm.get('message').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'validate'" - /> - <app-svg-icon - *ngIf="contactForm.get('message').value && !contactForm.get('message').valid" - [iconClass]="'validation'" - [folder]="'form'" - [icon]="'notValidate'" - /> - </div> - <p>{{ contactForm.get('message').value ? contactForm.get('message').value.length : 0 }}/500</p> - </div> - </div> - <div class="buttons"> - <app-button [variant]="'secondary'" [label]="'Annuler'" [routerLink]="'/home'" /> - <app-button - [type]="'submit'" - [variant]="'primary'" - [label]="'Envoyer'" - [disabled]="!contactForm.valid || loading" - /> - </div> - </form> -</div> + <app-input + id="subject" + label="Objet du message" + size="large" + [status]="contactForm.get('subject').invalid ? null : 'success'" + [value]="contactForm.get('subject').value" + (valueChange)="contactForm.get('subject').setValue($event)" + /> + + <app-textarea + id="message" + label="Message" + placeholder="Exemple : J'aimerais avoir de l'aide sur Rés'in." + [value]="contactForm.get('message').value || ''" + (valueChange)="contactForm.get('message').setValue($event)" + /> + + <div class="buttons"> + <app-button [variant]="'secondary'" [label]="'Annuler'" [routerLink]="'/home'" /> + <app-button + [type]="'submit'" + [variant]="'primary'" + [label]="'Envoyer'" + [disabled]="!contactForm.valid || loading" + /> + </div> +</form> diff --git a/src/app/contact/contact.component.scss b/src/app/contact/contact.component.scss index ad393715e8fb4363c6281d43983f44fe188d32c5..7799d1448a375fd46233e60027b293e4e46d9533 100644 --- a/src/app/contact/contact.component.scss +++ b/src/app/contact/contact.component.scss @@ -5,44 +5,19 @@ @import 'shapes'; @import 'z-index'; -.formFields { - max-width: 960px; - padding: 40px; - background: $white; - border-radius: 8px; - border: 1px solid $grey-6; -} -.phone { - width: 200px; -} -.subject { - width: 600px; -} -.textareaBlock { - flex-direction: column; - box-sizing: border-box; - display: flex; - textarea { - width: 94%; - margin-top: 4px; - &:focus { - border: 1px solid $blue; - outline: none !important; - } - } -} -.buttons { +.contactForm { + max-width: 600px; + padding: 1rem 0; + margin: auto; + display: flex; - justify-content: center; - max-width: 960px; - padding-top: 1rem; + flex-direction: column; gap: 1rem; -} -p { - text-align: right; - width: 96%; - &.notRequired { - text-align: left; - margin: 0; + + .buttons { + display: flex; + justify-content: center; + max-width: 600px; + gap: 1rem; } } diff --git a/src/app/contact/contact.component.ts b/src/app/contact/contact.component.ts index c631d5c9693bdb3e21434fa9404f7eb0d4136e1d..1e1231ad352dd4c841d7d160ed808c170660ed3d 100644 --- a/src/app/contact/contact.component.ts +++ b/src/app/contact/contact.component.ts @@ -58,9 +58,6 @@ export class ContactComponent implements OnInit { } public onSubmit(): void { - if (!this.contactForm.valid) { - return; - } this.loading = true; const contactMessage: ContactMessage = this.contactForm.value; diff --git a/src/app/form/orientation-form-view/global-components/structure-orientator/structure-orientator.component.ts b/src/app/form/orientation-form-view/global-components/structure-orientator/structure-orientator.component.ts index 56bc78f49134666bc5bc544df7d3bc0770307672..78ea1b2c9973d8c2936034af333f20f0eec9200c 100644 --- a/src/app/form/orientation-form-view/global-components/structure-orientator/structure-orientator.component.ts +++ b/src/app/form/orientation-form-view/global-components/structure-orientator/structure-orientator.component.ts @@ -52,7 +52,7 @@ export class StructureOrientatorComponent implements OnInit { public updatedForm(field: string, target: EventTarget): void { const value = (target as HTMLInputElement).value; if (field === 'phone') { - this.utils.modifyPhoneInput(this.form, 'phone', target); + this.utils.modifyPhoneInput(this.form, 'phone', value); } else this.form.get(field).patchValue(value); this.validatePage.emit(this.form.valid); diff --git a/src/app/utils/utils.ts b/src/app/utils/utils.ts index 1ee5d70610b5946eb33317be2b60801721dd6635..5f7aabf8c0893607ec3d8ec398eb9a49cf32d74a 100644 --- a/src/app/utils/utils.ts +++ b/src/app/utils/utils.ts @@ -16,12 +16,8 @@ import { PersonalOffer } from './../models/personalOffer.model'; providedIn: 'root', }) export class Utils { - // V3REMOVE : supprimer le cas EventTarget - public modifyPhoneInput(form: UntypedFormGroup, controlName: string, target: EventTarget | string): void { - if (target['value']) target = (target as HTMLInputElement).value; - const phoneNumber = target as string; + public modifyPhoneInput(form: UntypedFormGroup, controlName: string, phoneNumber: string): void { form.get(controlName).setValue(phoneNumber); - // Take length of phone number without spaces. const phoneNoSpace = phoneNumber.replace(/\s/g, ''); // Check to refresh every 2 number.