Skip to content
Snippets Groups Projects
Commit 2c738474 authored by Yoan VALLET's avatar Yoan VALLET
Browse files

WIP: add Success and error screen after job run

parent f97e06fa
No related branches found
No related tags found
3 merge requests!28Merge fix from dev,!27Dev,!25Features/us150 review of konnectors
import React, { useEffect } from 'react'
import React, { useEffect, useState } from 'react'
import { withClient, Client } from 'cozy-client'
import { translate } from 'cozy-ui/react/I18n'
......@@ -36,7 +36,13 @@ const KonnectorLaunch: React.FC<KonnectorLaunchProps> = ({
client,
t,
}: KonnectorLaunchProps) => {
const callbackResponse = () => {
const [state, setState] = useState<string | null>(null)
const callbackResponse = (_state: string) => {
setState(_state)
}
const handleClick = () => {
handleKonnectorLaunch()
}
......@@ -47,13 +53,13 @@ const KonnectorLaunch: React.FC<KonnectorLaunchProps> = ({
const konnectorJob = new KonnectorJob(client, trigger)
await konnectorJob.launch()
konnectorJob.jobWatcher.on(ERROR_EVENT, () => {
callbackResponse()
callbackResponse(ERROR_EVENT)
})
konnectorJob.jobWatcher.on(LOGIN_SUCCESS_EVENT, () => {
callbackResponse()
callbackResponse(LOGIN_SUCCESS_EVENT)
})
konnectorJob.jobWatcher.on(SUCCESS_EVENT, () => {
callbackResponse()
callbackResponse(SUCCESS_EVENT)
})
}
}
......@@ -63,16 +69,27 @@ const KonnectorLaunch: React.FC<KonnectorLaunchProps> = ({
}
}, [])
// TODO - SUCCESS SCREEN
// TODO - SUCCESS SCREEN + rename of class
return (
<div className="kload-content">
<Lottie options={loadingOptions} height={50} width={50} />
<div className="kload-content-text kload-content-text-center text-16-normal">
<div>{t('KONNECTORCONFIG.PLZ_WAIT')}</div>
</div>
<div className="kload-content-text text-16-normal">
<div>{t('KONNECTORCONFIG.LOADING_DATA')}</div>
</div>
{!state ? (
<>
<Lottie options={loadingOptions} height={50} width={50} />
<div className="kload-content-text kload-content-text-center text-16-normal">
<div>{t('KONNECTORCONFIG.PLZ_WAIT')}</div>
</div>
<div className="kload-content-text text-16-normal">
<div>{t('KONNECTORCONFIG.LOADING_DATA')}</div>
</div>
</>
) : (
<>
<div>
{/* // Add success when state <> ERROR_EVENT
// Add Error when state = ERROR_EVENT */}
</div>
</>
)}
</div>
)
}
......
......@@ -107,7 +107,6 @@ const KonnectorLoginForm: React.FC<KonnectorLoginFormProps> = ({
}
}, [])
// TODO - if received account from props = display error login failed
return (
<form
className="form"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment