diff --git a/src/app/components/humeur/humeur.component.ts b/src/app/components/humeur/humeur.component.ts index 3dbabaa..64cc0a6 100644 --- a/src/app/components/humeur/humeur.component.ts +++ b/src/app/components/humeur/humeur.component.ts @@ -27,8 +27,7 @@ alert: any; this.alert=""; } -// récupère le getCurrentMembreId (stocké dans token.service), -// qui est l'identifiant du membre et qui stocké dans le token +// récupère l'id du membre connecté (stocké dans token.service), ngOnInit(): void { const userId = this.tokenService.getCurrentMembreId(); this.membreService.getMembreId(userId).subscribe({ diff --git a/src/app/pages/page-signup/page-signup.component.html b/src/app/pages/page-signup/page-signup.component.html index 7d2a6ca..bb9ebef 100644 --- a/src/app/pages/page-signup/page-signup.component.html +++ b/src/app/pages/page-signup/page-signup.component.html @@ -83,7 +83,7 @@ !signupForm.controls['dateNaissanceFc'].valid }" /> - +
-
+ +

Nous contacter

-
+ +
- +
-
- +
- - +
- +
- +
diff --git a/src/app/pages/page-support/page-support.component.ts b/src/app/pages/page-support/page-support.component.ts index ff60707..929fabe 100644 --- a/src/app/pages/page-support/page-support.component.ts +++ b/src/app/pages/page-support/page-support.component.ts @@ -1,40 +1,83 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { TokenService } from 'src/app/services/token.service'; -import { Membre } from 'src/app/models/membre'; -import { ActivatedRoute, Router } from '@angular/router'; -import { FormBuilder, FormGroup } from '@angular/forms'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { MembreService } from 'src/app/services/membre.service'; -import { HttpClient } from '@angular/common/http'; -import { FormsModule } from '@angular/forms'; +import { TokenService } from 'src/app/services/token.service'; +import { MailService } from 'src/app/services/mail.service'; +import { Component, OnInit } from '@angular/core'; +import { Mail } from 'src/app/models/mail'; - -//DRIVEN FORM @Component({ selector: 'app-page-support', templateUrl: './page-support.component.html', styleUrls: ['./page-support.component.scss'] }) export class PageSupportComponent implements OnInit { - -memberName: any; + public contactForm: FormGroup; + memberName: any; + alert: any; + isShow: boolean; +expName: any; +expMail: any; -constructor(private membreService: MembreService, - private http: HttpClient, - private router: Router, - private tokenService: TokenService) { + constructor(private membreService: MembreService, + private tokenService: TokenService, + private fb: FormBuilder, + private mailService: MailService, + ) { + this.contactForm = new FormGroup({}); + this.alert = ""; + this.isShow = false; + } -} + ngOnInit(): void { + this.contactForm = this.fb.group( + { + lastNameFc: new FormControl('', [Validators.required]), + emailFc: new FormControl('', [Validators.required]), + messageFc: new FormControl('', [Validators.required]), + } + ); + this.membreService.getMembreId(this.tokenService.getCurrentMembreId()).subscribe((result) => { + this.memberName = result; + this.expName = this.memberName.nom; + this.expMail = this.memberName.email; + }) + } -ngOnInit(): void { - this.membreService.getMembreId(this.tokenService.getCurrentMembreId()).subscribe((result) => { - this.memberName = result ; }) } + public onSubmit(): void { + const nomValue = this.contactForm.value['lastNameFc']; + const emailValue = this.contactForm.value['emailFc']; + const messageValue = this.contactForm.value['messageFc']; + console.log(this.contactForm); + const mail: Mail = { + recipient: "organizee.contact@gmail.com", + subject: "Demande de support", + message: ` + Bonjour!\n + Nouveau message d'un utilisateur du site\n + Nom : ${nomValue} \n + Email : ${emailValue} \n + Message : ${messageValue} \n ` + }; + this.mailService.envoiMailText(mail)?.subscribe((respMail) => { + console.log("Mail envoyé"); + this.alert = { "type": "success", "content": "Votre message a été envoyé" }; + this.isShow = true; + }) + } + onDeleteMail() { + console.log("Formulaire effacé"); + location.reload(); + this.alert = { "type": "danger", "content": "Réinitialisation en cours" }; + this.isShow = true; + } - onSendMail(){ } + onClickCloseAlert() { + this.isShow = !this.isShow; + } - onDeleteMail(){ } } \ No newline at end of file