From b4c24528a3dffd8e81da378b4784111c7575f941 Mon Sep 17 00:00:00 2001
From: Bastien Dumont <bdumont@grandlyon.com>
Date: Mon, 6 May 2024 10:08:33 +0200
Subject: [PATCH] chore(gas): remove account on error

---
 .vscode/settings.json                             |  2 ++
 src/components/Konnector/KonnectorModalFooter.tsx | 10 ----------
 src/components/Konnector/KonnectorViewerCard.tsx  |  6 ++++--
 src/enums/konnectorStatus.enum.ts                 |  1 +
 src/locales/fr.json                               |  1 -
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/.vscode/settings.json b/.vscode/settings.json
index 2da2aa9b3..05e6af925 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -85,6 +85,7 @@
     "Enedis",
     "ENEDIS",
     "enedissgegrandlyon",
+    "energical",
     "Epgl",
     "esnext",
     "firstname",
@@ -141,6 +142,7 @@
     "sendmail",
     "SHARAPOWATT",
     "shortcodes",
+    "Smartmeter",
     "splashscreen",
     "swipeable",
     "Swipeable",
diff --git a/src/components/Konnector/KonnectorModalFooter.tsx b/src/components/Konnector/KonnectorModalFooter.tsx
index 2023ed972..69faad6e0 100644
--- a/src/components/Konnector/KonnectorModalFooter.tsx
+++ b/src/components/Konnector/KonnectorModalFooter.tsx
@@ -68,16 +68,6 @@ const KonnectorModalFooter = ({
         <div>{t('konnector_modal.button_try_again')}</div>
       </Button>
     )
-  } else if (error === KonnectorError.CHALLENGE_ASKED) {
-    return (
-      <Button
-        aria-label={t('konnector_modal.accessibility.button_close')}
-        onClick={() => handleCloseClick(state === SUCCESS_EVENT)}
-        className="btnPrimary"
-      >
-        <div>{t('konnector_modal.button_come_back_later')}</div>
-      </Button>
-    )
   } else if (error === KonnectorError.TERMS_VERSION_MISMATCH) {
     return (
       <div className="buttons">
diff --git a/src/components/Konnector/KonnectorViewerCard.tsx b/src/components/Konnector/KonnectorViewerCard.tsx
index 91096b619..d288af83b 100644
--- a/src/components/Konnector/KonnectorViewerCard.tsx
+++ b/src/components/Konnector/KonnectorViewerCard.tsx
@@ -183,11 +183,13 @@ const KonnectorViewerCard = ({
       const isEnedisCodeInseeError =
         !isUpdating && fluidType === FluidType.ELECTRICITY
 
+      const isGRDFError =
+        konnectorErrorDescription === KonnectorError.USER_ACTION_NEEDED_CGU_FORM
+
       const shouldDeleteAccount =
         account &&
         !isSuccess &&
-        account &&
-        (isGlobalLoginFailed || isEnedisCodeInseeError)
+        (isGlobalLoginFailed || isEnedisCodeInseeError || isGRDFError)
 
       if (shouldDeleteAccount) {
         logApp('info', `shouldDeleteAccount`)
diff --git a/src/enums/konnectorStatus.enum.ts b/src/enums/konnectorStatus.enum.ts
index ca1975dae..b74b68006 100644
--- a/src/enums/konnectorStatus.enum.ts
+++ b/src/enums/konnectorStatus.enum.ts
@@ -7,6 +7,7 @@ export enum KonnectorError {
   CRITICAL = 'exit status 1',
   MISSING_SECRET = "Cannot read property 'secret' of null",
   USER_ACTION_NEEDED_ACCOUNT_REMOVED = 'USER_ACTION_NEEDED.ACCOUNT_REMOVED',
+  USER_ACTION_NEEDED_CGU_FORM = 'USER_ACTION_NEEDED.CGU_FORM',
 }
 
 export enum KonnectorUpdate {
diff --git a/src/locales/fr.json b/src/locales/fr.json
index 81db76e0d..e81e81f36 100644
--- a/src/locales/fr.json
+++ b/src/locales/fr.json
@@ -856,7 +856,6 @@
     "button_check_info": "Vérifier les infos",
     "button_go": "J'y vais",
     "button_later": "Plus tard",
-    "button_come_back_later": "Revenir plus tard",
     "show_common_error": "Voir les erreurs récurrentes",
     "show_common_error_list": "<span>Le problème peut provenir des cas suivants :</span><ul><li>Vous avez un co-titulaire sur votre contrat. Veillez à bien entrer le nom du <span class=\"gold\">titulaire du contrat</span> et non le co-titulaire.</li><li>  Votre nom comporte un tiret\u00a0? Tentez sans le tiret.</li><li>Entrez bien le nom de votre commune de résidence en entier (tirets et accents inclus)</li><li>Avez-vous bien entré le <span class=\"gold\">numéro de votre compteur</span> (PDL)\u00a0? Tout autre numéro (de contrat, de client) ne fonctionne pas.</li></ul><p>Si vous rencontrez toujours des difficultés, contactez notre service d'aide </p><div class=\"center\">Avez-vous pensez à vérifier ces informations\u00a0?</div>",
     "accessibility": {
-- 
GitLab