From 8e7cadd8f0b5c7a82f82a675d314190fe2fa9005 Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Fri, 9 Apr 2021 11:11:43 +0200
Subject: [PATCH] remove news subscription when user exists

---
 src/app/form/form.component.html | 18 ++++++++++--------
 src/app/form/form.component.ts   |  3 ---
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html
index e060ad046..c32ffbbf9 100644
--- a/src/app/form/form.component.html
+++ b/src/app/form/form.component.html
@@ -1075,15 +1075,17 @@
         (checkEvent)="acceptDataBeSaved($event)"
       >
       </app-checkbox-form>
-      <div class="title">
-        <h3>Acceptez-vous de recevoir des mails d'informations de la part de Res'in ?</h3>
+      <div *ngIf="!profile">
+        <div class="title">
+          <h3>Acceptez-vous de recevoir des mails d'informations de la part de Res'in ?</h3>
+        </div>
+        <app-checkbox-form
+          [isChecked]="userAcceptNewsletter"
+          [text]="'J\'accepte'"
+          (checkEvent)="acceptReceiveNewsletter($event)"
+        >
+        </app-checkbox-form>
       </div>
-      <app-checkbox-form
-        [isChecked]="userAcceptNewsletter"
-        [text]="'J\'accepte'"
-        (checkEvent)="acceptReceiveNewsletter($event)"
-      >
-      </app-checkbox-form>
       <p class="informationEndForm">
         <span class="asterisk">*</span> Les informations recueillies sont enregistrées dans un fichier par la Métropole
         de Lyon en vue de l'animation du réseau des acteurs de la médiation numérique. Elles sont conservées pendant 24
diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts
index 7748c87b6..4e25894a4 100644
--- a/src/app/form/form.component.ts
+++ b/src/app/form/form.component.ts
@@ -848,9 +848,6 @@ export class FormComponent implements OnInit {
           user = this.profile;
           structure.accountVerified = true;
           this.createStructure(structure, user);
-          if (this.userAcceptNewsletter) {
-            this.newsletterService.newsletterSubscribe(user.email).subscribe(() => {});
-          }
         } else {
           if (this.accountForm.valid) {
             user = new User(this.accountForm.value);
-- 
GitLab