diff --git a/src/components/Connection/SGEConnect/SgeConnectView.tsx b/src/components/Connection/SGEConnect/SgeConnectView.tsx index e6290bd5472d2f9427a8064270d6d896510eb102..2b72a3a21b0f0f46ad3043fa260ca02216e2f9be 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 db0bb7e1d6909e0773a57d14d1a092b7840fb256..16aa31199eac4c94d4cb409fbfb0886e4a80d2ee 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 e9ef1c8ecaa6d880c75d9018b22d292e9c8ce4a6..936855740e81d48d2d28bd92e81ab34dc536bcf9 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 1bf3be72089103ee22d8a0d8ac7efc1e38370a88..4f01f587d45fff4b463c5418e9f90f760bd66a56 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 6755f9ed4dcffe90ac611bfbe61df92ba11bbe7c..85ef5133e41b3f88933e4f83b2934e59ca4fda5b 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 d0e41143ba1b7f1640def054212e3426b726b157..03db452ffbe8995d3f6954df16efebd6e72468e9 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 59b30d9f42f3b5e912b4ad5b43838ce240e8f84e..947ef39f992520ccdefd027d2a5e1eb97cfe300d 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 9f3f43e67924305e8024b8d7505bb8b084e8b833..481cfea041f986b80565ff2b78eb6f275a85b308 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: '',