Skip to content
Snippets Groups Projects
Commit 78d0f745 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Revert "chore: remove unused error from custom hook"

This reverts commit f87dbc11.
parent 4fbc1a62
No related branches found
No related tags found
2 merge requests!1154feat: GRDF consent email,!1137feat(grdf)!: update error messages
...@@ -29,7 +29,7 @@ const EpglForm = ({ hasCreatedAccount }: { hasCreatedAccount: boolean }) => { ...@@ -29,7 +29,7 @@ const EpglForm = ({ hasCreatedAccount }: { hasCreatedAccount: boolean }) => {
const [loading, setLoading] = useState<boolean>(false) const [loading, setLoading] = useState<boolean>(false)
const [showPassword, setShowPassword] = useState(false) const [showPassword, setShowPassword] = useState(false)
const [connect, update] = useKonnectorAuth(FluidType.WATER, { const [connect, update, connectError] = useKonnectorAuth(FluidType.WATER, {
eglAuthData: { login, password }, eglAuthData: { login, password },
}) })
...@@ -67,6 +67,10 @@ const EpglForm = ({ hasCreatedAccount }: { hasCreatedAccount: boolean }) => { ...@@ -67,6 +67,10 @@ const EpglForm = ({ hasCreatedAccount }: { hasCreatedAccount: boolean }) => {
} }
} }
useEffect(() => {
if (connectError) setError(connectError)
}, [connectError])
useEffect(() => { useEffect(() => {
if (account?.auth) { if (account?.auth) {
const auth = account.auth const auth = account.auth
......
import * as Sentry from '@sentry/react' import * as Sentry from '@sentry/react'
import { useClient } from 'cozy-client' import { useClient } from 'cozy-client'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import { FluidType } from 'enums' import { FluidType } from 'enums'
import { import {
AccountEGLData, AccountEGLData,
...@@ -8,6 +9,7 @@ import { ...@@ -8,6 +9,7 @@ import {
FluidConnection, FluidConnection,
SgeStore, SgeStore,
} from 'models' } from 'models'
import { useState } from 'react'
import AccountService from 'services/account.service' import AccountService from 'services/account.service'
import ConnectionService from 'services/connection.service' import ConnectionService from 'services/connection.service'
import { updateFluidConnection } from 'store/global/global.slice' import { updateFluidConnection } from 'store/global/global.slice'
...@@ -64,12 +66,14 @@ const useKonnectorAuth = ( ...@@ -64,12 +66,14 @@ const useKonnectorAuth = (
sgeAuthData?: SgeStore sgeAuthData?: SgeStore
grdfAuthData?: AccountGRDFData grdfAuthData?: AccountGRDFData
} }
): [() => Promise<null | undefined>, () => Promise<void>] => { ): [() => Promise<null | undefined>, () => Promise<void>, string] => {
const client = useClient() const client = useClient()
const { t } = useI18n()
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const { fluidStatus } = useAppSelector(state => state.ecolyo.global) const { fluidStatus } = useAppSelector(state => state.ecolyo.global)
const currentFluidStatus = fluidStatus[fluidType] const currentFluidStatus = fluidStatus[fluidType]
const konnectorSlug = currentFluidStatus.connection.konnectorConfig.slug const konnectorSlug = currentFluidStatus.connection.konnectorConfig.slug
const [connectError, setConnectError] = useState<string>('')
const connect = async () => { const connect = async () => {
try { try {
...@@ -88,6 +92,7 @@ const useKonnectorAuth = ( ...@@ -88,6 +92,7 @@ const useKonnectorAuth = (
) )
if (!trigger || !account) { if (!trigger || !account) {
setConnectError(t('konnector_form.error_account_creation'))
return null return null
} }
const updatedConnection: FluidConnection = { const updatedConnection: FluidConnection = {
...@@ -142,7 +147,7 @@ const useKonnectorAuth = ( ...@@ -142,7 +147,7 @@ const useKonnectorAuth = (
Sentry.captureException(error) Sentry.captureException(error)
} }
} }
return [connect, update] return [connect, update, connectError]
} }
export default useKonnectorAuth export default useKonnectorAuth
...@@ -760,6 +760,7 @@ ...@@ -760,6 +760,7 @@
"login_failed": "Un problème a lieu lors de la récupération de vos données. Merci de supprimer votre connecteur et vous reconnecter.", "login_failed": "Un problème a lieu lors de la récupération de vos données. Merci de supprimer votre connecteur et vous reconnecter.",
"not_installed": "Le connecteur n'est pas installé. Veuillez l'installer en cliquant sur le bouton ci-dessous.", "not_installed": "Le connecteur n'est pas installé. Veuillez l'installer en cliquant sur le bouton ci-dessous.",
"button_install": "Installer", "button_install": "Installer",
"error_account_creation": "Une erreur est survenue, veuillez essayer de nouveau.",
"error_no_login_password": "Identifiant et mot de passe requis", "error_no_login_password": "Identifiant et mot de passe requis",
"error_login_failed": "Identifiants invalides", "error_login_failed": "Identifiants invalides",
"error_update": "Un problème est survenu lors du rapatriement de vos données.", "error_update": "Un problème est survenu lors du rapatriement de vos données.",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment