From 5c293bbfac2f905e07c6f91bf97da60145b3a3a6 Mon Sep 17 00:00:00 2001
From: Bastien DUMONT <bdumont@grandlyon.com>
Date: Wed, 9 Oct 2024 13:59:40 +0200
Subject: [PATCH] change to lowercase

---
 .../Connection/SGEConnect/SgeConnectView.tsx  | 12 ++++-----
 .../SGEConnect/StepIdentityAndPdl.spec.tsx    |  4 +--
 .../SGEConnect/StepIdentityAndPdl.tsx         |  4 +--
 src/components/Connection/useForm.tsx         |  4 +--
 src/components/Hooks/useKonnectorAuth.tsx     |  4 +--
 .../ConnectionResult/ConnectionResult.tsx     | 27 ++-----------------
 src/models/sgeStore.model.ts                  |  4 +--
 tests/__mocks__/forms.mock.ts                 |  4 +--
 8 files changed, 20 insertions(+), 43 deletions(-)

diff --git a/src/components/Connection/SGEConnect/SgeConnectView.tsx b/src/components/Connection/SGEConnect/SgeConnectView.tsx
index e6290bd54..2b72a3a21 100644
--- a/src/components/Connection/SGEConnect/SgeConnectView.tsx
+++ b/src/components/Connection/SGEConnect/SgeConnectView.tsx
@@ -86,8 +86,8 @@ const SgeConnectView = () => {
     switch (currentStep) {
       case SgeStep.IdentityAndPDL:
         return (
-          sgeState.firstName !== '' &&
-          sgeState.lastName !== '' &&
+          sgeState.firstname !== '' &&
+          sgeState.lastname !== '' &&
           sgeState.pdl !== null &&
           sgeState.pdl.toString().length === 14
         )
@@ -107,8 +107,8 @@ const SgeConnectView = () => {
     sgeState.address,
     sgeState.city,
     sgeState.dataConsent,
-    sgeState.firstName,
-    sgeState.lastName,
+    sgeState.firstname,
+    sgeState.lastname,
     sgeState.pdl,
     sgeState.pdlConfirm,
     sgeState.zipCode,
@@ -122,8 +122,8 @@ const SgeConnectView = () => {
       client.save({
         ...formData,
         _type: FORM_DOCTYPE,
-        firstName: sgeState.firstName,
-        lastName: sgeState.lastName,
+        firstName: sgeState.firstname,
+        lastName: sgeState.lastname,
         pdl: sgeState.pdl,
         address: sgeState.address,
         city: sgeState.city,
diff --git a/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx b/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx
index db0bb7e1d..16aa31199 100644
--- a/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx
+++ b/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx
@@ -61,8 +61,8 @@ describe('StepIdentityAndPdl component', () => {
         sgeState={{
           ...mockSgeState,
           pdl: 11111111111111,
-          firstName: 'Zack',
-          lastName: 'Ichan',
+          firstname: 'Zack',
+          lastname: 'Ichan',
           zipCode: 69003,
         }}
         onChange={mockHandleChange}
diff --git a/src/components/Connection/SGEConnect/StepIdentityAndPdl.tsx b/src/components/Connection/SGEConnect/StepIdentityAndPdl.tsx
index e9ef1c8ec..936855740 100644
--- a/src/components/Connection/SGEConnect/StepIdentityAndPdl.tsx
+++ b/src/components/Connection/SGEConnect/StepIdentityAndPdl.tsx
@@ -31,7 +31,7 @@ const StepIdentityAndPdl = ({
         variant="outlined"
         type="text"
         id="firstName"
-        value={sgeState.firstName}
+        value={sgeState.firstname}
         onChange={e => onChange('firstName', e.target.value)}
         required
         autoComplete="given-name"
@@ -41,7 +41,7 @@ const StepIdentityAndPdl = ({
         variant="outlined"
         type="text"
         id="lastName"
-        value={sgeState.lastName}
+        value={sgeState.lastname}
         onChange={e => onChange('lastName', e.target.value)}
         required
         autoComplete="family-name"
diff --git a/src/components/Connection/useForm.tsx b/src/components/Connection/useForm.tsx
index 1bf3be720..4f01f587d 100644
--- a/src/components/Connection/useForm.tsx
+++ b/src/components/Connection/useForm.tsx
@@ -45,8 +45,8 @@ export const useFormData = () => {
 
 export const createInitialSgeState = (formData?: FormData): SgeStore => ({
   address: formData?.address ?? '',
-  lastName: formData?.lastName ?? '',
-  firstName: formData?.firstName ?? '',
+  lastname: formData?.lastName ?? '',
+  firstname: formData?.firstName ?? '',
   pdl: formData?.pdl ? parseInt(formData.pdl) : null,
   zipCode: formData?.zipCode ? parseInt(formData.zipCode) : null,
   city: formData?.city ?? '',
diff --git a/src/components/Hooks/useKonnectorAuth.tsx b/src/components/Hooks/useKonnectorAuth.tsx
index 6755f9ed4..85ef5133e 100644
--- a/src/components/Hooks/useKonnectorAuth.tsx
+++ b/src/components/Hooks/useKonnectorAuth.tsx
@@ -47,8 +47,8 @@ const formatAuthData = ({
   } else if (sgeAuthData) {
     const konnectorFields: AccountSgeData = {
       pointId: sgeAuthData?.pdl?.toString() ?? '',
-      firstname: sgeAuthData?.firstName ?? '',
-      lastname: sgeAuthData?.lastName ?? '',
+      firstname: sgeAuthData?.firstname ?? '',
+      lastname: sgeAuthData?.lastname ?? '',
       address: sgeAuthData?.address ?? '',
       postalCode: sgeAuthData?.zipCode?.toString() ?? '',
       city: sgeAuthData?.city ?? '',
diff --git a/src/components/Konnector/ConnectionResult/ConnectionResult.tsx b/src/components/Konnector/ConnectionResult/ConnectionResult.tsx
index d0e41143b..03db452ff 100644
--- a/src/components/Konnector/ConnectionResult/ConnectionResult.tsx
+++ b/src/components/Konnector/ConnectionResult/ConnectionResult.tsx
@@ -6,7 +6,7 @@ import { useClient } from 'cozy-client'
 import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
 import { FluidType, KonnectorUpdate } from 'enums'
 import { DateTime } from 'luxon'
-import { AccountSgeData, FluidConnection, FluidStatus } from 'models'
+import { FluidConnection, FluidStatus } from 'models'
 import React, { useCallback, useEffect, useState } from 'react'
 import AccountService from 'services/account.service'
 import DateChartService from 'services/dateChart.service'
@@ -14,7 +14,6 @@ import TriggerService from 'services/triggers.service'
 import {
   setShouldRefreshConsent,
   updateFluidConnection,
-  updateSgeStore,
 } from 'store/global/global.slice'
 import { useAppDispatch, useAppSelector } from 'store/hooks'
 import { getKonnectorUpdateError } from 'utils/utils'
@@ -108,33 +107,11 @@ const ConnectionResult = ({
 
   const handleRefreshConsent = useCallback(() => {
     if (fluidType == FluidType.ELECTRICITY) {
-      const accountData = currentFluidStatus.connection.account
-        ?.auth as AccountSgeData
-      // store the previous account data since the onDelete will remove account from DB
-      dispatch(
-        updateSgeStore({
-          currentStep: 0,
-          firstName: accountData.firstname,
-          lastName: accountData.lastname,
-          pdl: parseInt(accountData.pointId),
-          address: accountData.address,
-          zipCode: parseInt(accountData.postalCode),
-          city: accountData.city,
-          dataConsent: true,
-          pdlConfirm: true,
-          shouldLaunchAccount: true,
-        })
-      )
       dispatch(setShouldRefreshConsent(true))
     } else {
       deleteAccountsAndTriggers()
     }
-  }, [
-    fluidType,
-    currentFluidStatus.connection.account?.auth,
-    dispatch,
-    deleteAccountsAndTriggers,
-  ])
+  }, [fluidType, dispatch, deleteAccountsAndTriggers])
 
   useEffect(() => {
     if (currentFluidStatus.connection.triggerState?.last_success) {
diff --git a/src/models/sgeStore.model.ts b/src/models/sgeStore.model.ts
index 59b30d9f4..947ef39f9 100644
--- a/src/models/sgeStore.model.ts
+++ b/src/models/sgeStore.model.ts
@@ -1,7 +1,7 @@
 export interface SgeStore {
   currentStep: number
-  firstName: string
-  lastName: string
+  firstname: string
+  lastname: string
   pdl: number | null
   address: string
   zipCode: number | null
diff --git a/tests/__mocks__/forms.mock.ts b/tests/__mocks__/forms.mock.ts
index 9f3f43e67..481cfea04 100644
--- a/tests/__mocks__/forms.mock.ts
+++ b/tests/__mocks__/forms.mock.ts
@@ -2,8 +2,8 @@ import { SgeStore } from 'models'
 
 export const mockSgeState: SgeStore = {
   address: '',
-  lastName: '',
-  firstName: '',
+  lastname: '',
+  firstname: '',
   pdl: 0,
   zipCode: 0,
   city: '',
-- 
GitLab