From 41cfbb801537b662fe08ed4133e803a15d914088 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Fri, 12 Feb 2021 16:10:41 +0100
Subject: [PATCH] fix: add claim structure message

---
 src/app/form/form.component.html              | 24 ++++++++++++++-----
 src/app/form/form.component.scss              |  8 +++++--
 src/app/form/form.component.ts                | 14 ++++++++---
 .../structure-details.component.ts            |  2 +-
 4 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html
index 1599d7889..f1b1929d9 100644
--- a/src/app/form/form.component.html
+++ b/src/app/form/form.component.html
@@ -35,12 +35,7 @@
         [value]="progressStatus"
       ></progress>
     </div>
-    <div
-      *ngIf="currentPage == pageTypeEnum.summary && !isEditMode"
-      class="home page"
-      fxLayout="column"
-      fxLayoutAlign="space-between"
-    >
+    <div *ngIf="displayAddStructure()" class="home page" fxLayout="column" fxLayoutAlign="space-between">
       <h2>Ajouter votre structure</h2>
       <img src="../../assets/form/schedule.svg" alt="logo schedule" />
       <div>
@@ -51,6 +46,23 @@
         <button class="btn-primary start" (click)="nextPage()">C'est Parti</button>
       </div>
     </div>
+    <div
+      *ngIf="displayClaimStructure()"
+      class="home page"
+      fxLayout="column"
+      fxLayoutAlign="space-between center"
+      fxLayoutAlign.lt-sm="center"
+    >
+      <h2>
+        Revendiquer la structure <span>{{ claimStructure.structureName }}</span>
+      </h2>
+      <div>
+        <p>Une fois réalisé cela vous permettra de devenir propriétaire de cette structure</p>
+      </div>
+      <div class="btnStart">
+        <button class="btn-primary start" (click)="nextPage()">C'est Parti</button>
+      </div>
+    </div>
     <div
       *ngIf="currentPage == pageTypeEnum.summary && isEditMode"
       class="editHome page"
diff --git a/src/app/form/form.component.scss b/src/app/form/form.component.scss
index 17ced3d6b..8ab5aa6f4 100644
--- a/src/app/form/form.component.scss
+++ b/src/app/form/form.component.scss
@@ -86,6 +86,7 @@ h3 {
     ) !important; // -1px because of header border
   }
   @media #{$tablet} {
+    height: 100%;
     &.editMode {
       .page {
         height: calc(
@@ -103,8 +104,11 @@ h3 {
   height: auto;
   h2 {
     @include cn-bold-28;
-    color: $secondary-color;
+    color: $black;
     margin-bottom: 0;
+    span {
+      color: $secondary-color;
+    }
   }
   h3 {
     @include cn-bold-22;
@@ -163,7 +167,7 @@ h3 {
       color: $grey-3;
 
       margin-top: 4px;
-      width: 256px;
+      width: 280px;
       &.invalid {
         color: $orange-warning;
       }
diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts
index 716865200..a09015170 100644
--- a/src/app/form/form.component.ts
+++ b/src/app/form/form.component.ts
@@ -41,7 +41,7 @@ export class FormComponent implements OnInit {
   public equipmentsAndServices: { module: Module; openned: boolean }[] = [];
   public trainingCategories: { category: Category; openned: boolean }[] = [];
   public pageTypeEnum = PageTypeEnum;
-  public claimStructureId = null;
+  public claimStructure: Structure = null;
 
   // Page and progress var
   public currentPage = 0;
@@ -93,7 +93,7 @@ export class FormComponent implements OnInit {
     } else if (history.state.newUser) {
       this.isClaimMode = true;
       this.createAccountForm();
-      this.claimStructureId = history.state.newUser;
+      this.claimStructure = history.state.newUser;
       this.setValidationsForm();
     } else {
       this.initForm(new Structure());
@@ -523,7 +523,7 @@ export class FormComponent implements OnInit {
       const user = new User(this.accountForm.value);
       // Create user and claim structure
       this.authService.register(user).subscribe(() => {
-        this.structureService.claimStructureWithAccount(this.claimStructureId, user).subscribe(() => {
+        this.structureService.claimStructureWithAccount(this.claimStructure._id, user).subscribe(() => {
           this.progressStatus = 100;
         });
       });
@@ -814,4 +814,12 @@ export class FormComponent implements OnInit {
       });
     }
   }
+
+  public displayAddStructure(): boolean {
+    return this.currentPage == this.pageTypeEnum.summary && !this.isEditMode && !this.isClaimMode;
+  }
+
+  public displayClaimStructure(): boolean {
+    return this.currentPage == this.pageTypeEnum.summary && !this.isEditMode && this.isClaimMode;
+  }
 }
diff --git a/src/app/structure-list/components/structure-details/structure-details.component.ts b/src/app/structure-list/components/structure-details/structure-details.component.ts
index a46e89ef8..a3c33e731 100644
--- a/src/app/structure-list/components/structure-details/structure-details.component.ts
+++ b/src/app/structure-list/components/structure-details/structure-details.component.ts
@@ -126,7 +126,7 @@ export class StructureDetailsComponent implements OnInit {
     if (this.userIsLoggedIn()) {
       this.toggleClaimModal();
     } else {
-      this.router.navigate(['create-structure'], { state: { newUser: this.structure._id } });
+      this.router.navigate(['create-structure'], { state: { newUser: this.structure } });
     }
   }
 
-- 
GitLab