From f79b47f3ac148437ad2a822ed38b3d1caba3856f Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Fri, 25 Feb 2022 17:19:03 +0100 Subject: [PATCH 1/2] encore erreur --- src/app/app.module.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index dec0f01..5850a5c 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -43,7 +43,6 @@ import localeFr from '@angular/common/locales/fr'; import { CardAvatarComponent } from './components/card-avatar/card-avatar.component'; import { HumeurComponent } from './components/humeur/humeur.component'; import { DeconnexionComponent } from './components/deconnexion/deconnexion.component'; -import { HumeurComponent } from './components/humeur/humeur.component'; registerLocaleData(localeFr) @NgModule({ From 21e076b1eee758b2987a7ce97a669eee7da6b081 Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Fri, 25 Feb 2022 18:52:30 +0100 Subject: [PATCH 2/2] addMember envoi de mail ok --- src/app/models/mail.ts | 5 ++++ .../page-add-member.component.ts | 15 ++++++++++ src/app/services/mail.service.spec.ts | 16 ++++++++++ src/app/services/mail.service.ts | 29 +++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 src/app/models/mail.ts create mode 100644 src/app/services/mail.service.spec.ts create mode 100644 src/app/services/mail.service.ts diff --git a/src/app/models/mail.ts b/src/app/models/mail.ts new file mode 100644 index 0000000..d4d7afe --- /dev/null +++ b/src/app/models/mail.ts @@ -0,0 +1,5 @@ +export interface Mail { + recipient: string; + subject: string; + message: string; +} diff --git a/src/app/pages/page-add-member/page-add-member.component.ts b/src/app/pages/page-add-member/page-add-member.component.ts index e6f9cb4..d685097 100644 --- a/src/app/pages/page-add-member/page-add-member.component.ts +++ b/src/app/pages/page-add-member/page-add-member.component.ts @@ -1,8 +1,10 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; +import { Mail } from 'src/app/models/mail'; import { Membre } from 'src/app/models/membre'; import { AuthService } from 'src/app/services/auth.service'; +import { MailService } from 'src/app/services/mail.service'; import { MembreService } from 'src/app/services/membre.service'; @Component({ @@ -15,6 +17,7 @@ export class PageAddMemberComponent implements OnInit { public addMemberForm: FormGroup; constructor( private membreService: MembreService, + private mailService: MailService, private authService: AuthService, private router: Router, private fb: FormBuilder @@ -75,9 +78,21 @@ export class PageAddMemberComponent implements OnInit { roleList: [roleValue] }; + const mail: Mail = { + recipient: emailValue, + subject: "Votre mot de passe Organizee", + //message: 'Votre mot de passe' + message: `Bonjour ${firstNameValue}!\n Voici vos identifiants de connexion : \n + Identifiant : ${emailValue} + Mot de passe : ${passwordValue}` + }; + if (membre.email !== '' && membre.password !== '') { this.membreService.addMembre(membre)?.subscribe((resp) => { + this.mailService.envoiMailText(mail)?.subscribe((respMail) =>{ + console.log("Mail envoyé"); + }) this.router.navigate(['compte']); }); } else { diff --git a/src/app/services/mail.service.spec.ts b/src/app/services/mail.service.spec.ts new file mode 100644 index 0000000..1ab6588 --- /dev/null +++ b/src/app/services/mail.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { MailService } from './mail.service'; + +describe('MailService', () => { + let service: MailService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(MailService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/mail.service.ts b/src/app/services/mail.service.ts new file mode 100644 index 0000000..3e25373 --- /dev/null +++ b/src/app/services/mail.service.ts @@ -0,0 +1,29 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; +import { Observable } from 'rxjs'; +import { environment } from 'src/environments/environment'; +import { Mail } from '../models/mail'; +import { TokenService } from './token.service'; + +@Injectable({ + providedIn: 'root' +}) +export class MailService { + apiUrl: string; + tokenKey: string; + + constructor(private http: HttpClient, private tokenService: TokenService, private router: Router) { + this.apiUrl = environment.apiUrl; + this.tokenKey = environment.tokenKey; + } + + envoiMailText(mail: Mail): Observable | void{ + return this.http.post(`${this.apiUrl}/sendmail/text`, mail, { + responseType: "text" + }); + } + + + +}