From 2ef36f46abec6010b4c1e8ec6fea8fe0c166d0e8 Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Thu, 29 Apr 2021 17:14:25 +0200
Subject: [PATCH] WIP: login on structure form

---
 src/app/form/form.component.html | 12 ++++++++++++
 src/app/form/form.component.ts   | 24 ++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html
index 279e2672a..a96763da0 100644
--- a/src/app/form/form.component.html
+++ b/src/app/form/form.component.html
@@ -121,6 +121,13 @@
           <h3>Qui êtes-vous ?</h3>
           <p>Ces informations ne seront pas visibles sur la plateforme</p>
         </div>
+        <div class="title">
+          <h4>Vous possédez déja un compte ? Connectez-vous:</h4>
+          <button class="btn-primary small next" *ngIf="!isLoggedIn" (click)="isPopUpOpen = !isPopUpOpen">
+            Se connecter
+          </button>
+          <h4>Sinon, inscrivez-vous en suivant le formulaire ci-dessous:</h4>
+        </div>
         <div class="form-group" fxLayout="column">
           <label for="surname">Nom</label>
           <div fxLayout="row" fxLayoutGap="13px">
@@ -1213,4 +1220,9 @@
       Voir ma structure
     </button>
   </div>
+  <app-signup-modal
+    *ngIf="displaySignUp"
+    [openned]="isPopUpOpen"
+    (closed)="closeSignUpModal($event)"
+  ></app-signup-modal>
 </div>
diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts
index 9d4d64af4..6051a2538 100644
--- a/src/app/form/form.component.ts
+++ b/src/app/form/form.component.ts
@@ -77,6 +77,9 @@ export class FormComponent implements OnInit {
   public isWifiChoosen = null;
   public structureWithOwners: StructureWithOwners;
 
+  public isPopUpOpen = false;
+  public displaySignUp = true;
+
   constructor(
     private structureService: StructureService,
     private searchService: SearchService,
@@ -138,6 +141,27 @@ export class FormComponent implements OnInit {
     }
   }
 
+  public closeSignUpModal(value: boolean): void {
+    if (!value) {
+      this.displaySignUp = false;
+    } else {
+      this.isPopUpOpen = false;
+    }
+    if (this.isLoggedIn) {
+      this.updateFormOnLogin();
+    }
+  }
+
+  public updateFormOnLogin() {
+    //TODO -> switch to signed mode, update user data, validate/delete previous field, skip 2 pages
+    this.isAccountMode = true;
+    this.currentPage = PageTypeEnum.structureNameAndAddress;
+  }
+
+  public get isLoggedIn(): boolean {
+    return this.authService.isLoggedIn();
+  }
+
   async setCategories(): Promise<void> {
     this.searchService.getCategoriesAccompaniment().subscribe((categories: Category[]) => {
       this.proceduresAccompaniment = categories[0];
-- 
GitLab