diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index f0222f40b5d25e6bd0432f368276112348d85116..61c2ac54c2e497349ad82c3e39a43eb948a199a9 100644 --- a/src/app/form/form.component.ts +++ b/src/app/form/form.component.ts @@ -517,6 +517,7 @@ export class FormComponent implements OnInit { let user: User; if (this.profile) { user = this.profile; + structure.accountVerified = true; this.createStructure(structure, user); } else { if (this.accountForm.valid) { diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index 88f461887fe295b4f78149236a978e6c5adf74bd..e9468d7c5cbe647f6c8e62ba2d4db22c8eadf465 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -51,6 +51,8 @@ export class Structure { public distance?: number; public coord?: number[] = []; + public accountVerified: boolean = false; + constructor(obj?: any) { Object.assign(this, obj, { hours: obj && obj.hours ? new Week(obj.hours) : new Week(), diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index 97caee520996d96e60eac4b9bc35d9eb2c3a9ac6..a51c7aa85442dcb4bcb9366e3b767058a52209dd 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -20,6 +20,12 @@ export class StructureService { private readonly baseUrl = 'api/structures'; constructor(private http: HttpClient) {} + public updateStructureAfterOwnerVerify(id: string, structure: Structure): Observable<Structure> { + delete structure._id; // id should not be provided for update + return this.http + .put(`${this.baseUrl}/updateAfterOwnerVerify/${id}`, structure) + .pipe(map((item: Structure) => new Structure(item))); + } public createStructure(structure: Structure, profile: User): Observable<Structure> { const idUser = profile.email; return this.http.post(`${this.baseUrl}`, { structure, idUser }).pipe(map((item: Structure) => new Structure(item))); diff --git a/src/app/user-verification/user-verification.component.html b/src/app/user-verification/user-verification.component.html index f1a4876a42e2ca08f1829114782bae9346dd2be0..1175295c10768842af062064721fc372f84abd57 100644 --- a/src/app/user-verification/user-verification.component.html +++ b/src/app/user-verification/user-verification.component.html @@ -1,13 +1,29 @@ <div fxLayout="column" class="content-container full-screen"> - <h1 style="display: none">Vérification du mail utilisateur</h1> - <div class="section-container" fxLayout="colum" fxLayoutAlign="center center"> - <p *ngIf="!verificationSuccess && !verificationIssue">Votre email est en cours de vérification ...</p> - <p *ngIf="verificationSuccess"> - Vous avez correctement validé l'email associé a votre compte. Vous pouvez dès maintenant vous connecter au site. - </p> - <p *ngIf="verificationIssue"> - Une erreur est survenue lors de la validation de votre email... Veuillez envoyer un mail au support. - </p> - <div></div> + <p *ngIf="!verificationSuccess && !verificationIssue">Votre email est en cours de vérification ...</p> + <div *ngIf="verificationSuccess"> + <div class="title"> + <h3> + Bravo !<br /> + Votre compte et votre structure ont bien été référencés. + </h3> + </div> + + <div class="structureInfoBlock" fxLayout="row" fxLayoutAlign=" center"> + <div class="structureInfoContent" fxLayout="column"> + {{ structure.structureName }} + <span>{{ structure.structureType }}</span> + </div> + <div class="validateSvg"> + <svg class="validate" aria-hidden="true"> + <use [attr.xlink:href]="'assets/form/sprite.svg#checkVector'"></use> + </svg> + </div> + </div> + <div class="btnSection"> + <button class="btn" routerLink="/home" [routerLinkActive]="'active'">Voir ma structure</button> + </div> </div> + <p *ngIf="verificationIssue"> + Une erreur est survenue lors de la validation de votre email... Veuillez envoyer un mail au support. + </p> </div> diff --git a/src/app/user-verification/user-verification.component.scss b/src/app/user-verification/user-verification.component.scss index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..668d3c80f585c4e74ae06b8f6a4e33843ee086d8 100644 --- a/src/app/user-verification/user-verification.component.scss +++ b/src/app/user-verification/user-verification.component.scss @@ -0,0 +1,53 @@ +@import '../../assets/scss/color'; +@import '../../assets/scss/typography'; +@import '../../assets/scss/breakpoint'; + +.content-container { + max-width: 960px; + padding: 18px; + margin: auto; +} +.structureInfoBlock { + background: $green-1; + color: $white; + padding: 16px; + border-radius: 6px; + @include cn-bold-18; + .structureInfoContent { + width: 100%; + } + span { + font-style: italic; + @include cn-regular-14; + } + .validateSvg { + stroke: $white; + text-align: right; + svg { + height: 14px; + width: 14px; + } + } +} +.btn { + background: $secondary-color; + border-radius: 4px; + outline: none; + cursor: pointer; + border: 0; + color: $white; + height: 40px; + width: 192px; + @include btn-bold; +} +.btnSection { + @media #{$large-phone} { + position: fixed; + border-top: 1px solid $grey-4; + } + bottom: 0; + left: 0; + width: 100%; + text-align: center; + padding: 17px 0px; +} diff --git a/src/app/user-verification/user-verification.component.ts b/src/app/user-verification/user-verification.component.ts index e5c0e4e7903c5777b94d1d6e536f8af442850414..baa2aced4148fe426f65b9c9ad5e873c067ece51 100644 --- a/src/app/user-verification/user-verification.component.ts +++ b/src/app/user-verification/user-verification.component.ts @@ -1,6 +1,9 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; +import { Structure } from '../models/structure.model'; +import { User } from '../models/user.model'; import { AuthService } from '../services/auth.service'; +import { StructureService } from '../services/structure.service'; @Component({ selector: 'app-user-verification', @@ -10,10 +13,15 @@ import { AuthService } from '../services/auth.service'; export class UserVerificationComponent implements OnInit { public userId: string; public token: string; + public structure: Structure; public verificationSuccess = false; public verificationIssue = false; - constructor(private activatedRoute: ActivatedRoute, private authService: AuthService) { + constructor( + private activatedRoute: ActivatedRoute, + private authService: AuthService, + private structureService: StructureService + ) { this.activatedRoute.queryParams.subscribe((params) => { this.token = params['token']; }); @@ -26,8 +34,24 @@ export class UserVerificationComponent implements OnInit { private sendVerification(): void { this.authService.verifyUser(this.userId, this.token).subscribe( - () => { - this.verificationSuccess = true; + (user: User) => { + this.structureService.getStructure(user.structuresLink[0]).subscribe( + (structure) => { + structure.accountVerified = true; + this.structure = structure; + this.structureService.updateStructureAfterOwnerVerify(structure._id, structure).subscribe( + () => { + this.verificationSuccess = true; + }, + () => { + this.verificationIssue = true; + } + ); + }, + () => { + this.verificationIssue = true; + } + ); }, () => { this.verificationIssue = true;