<commit_before>import React from 'react'
import { translate } from 'cozy-ui/react/I18n'
import styles from '../styles/konnectorInstall'

import AccountConnectionData from './AccountConnectionData'
import AccountLoginForm from './AccountLoginForm'
import DescriptionContent from './DescriptionContent'
import KonnectorSuccess from './KonnectorSuccess'

import { ACCOUNT_ERRORS } from '../lib/accounts'

export const KonnectorInstall = ({ t, account, connector, deleting, disableSuccessTimeout, driveUrl, error, fields, folderPath, isTimeout, isUnloading, oAuthTerminated, onAccountConfig, onCancel, onDelete, onSubmit, submitting, success }) => {
  const securityIcon = require('../assets/icons/color/icon-cloud-lock.svg')
  const { hasDescriptions } = connector

  return (
    <div className={styles['col-account-connection-content']}>
      <div className={styles['col-account-connection-form']}>

        { error && error.message !== ACCOUNT_ERRORS.LOGIN_FAILED && <DescriptionContent
          cssClassesObject={{'coz-error': true}}
          title={t('account.message.error.global.title')}
          messages={[t('account.message.error.global.description', {name: connector.name})]}
        /> }

        <DescriptionContent
          title={t('account.config.title', { name: connector.name })}
          messages={hasDescriptions && hasDescriptions.connector
            ? [t(`connector.${connector.slug}.description.connector`)]
            : []}
        >
          { !connector.oauth && <p className={styles['col-account-connection-security']}>
            <svg>
              <use xlinkHref={securityIcon} />
            </svg>
            {t('account.config.security')}
          </p> }
        </DescriptionContent>

        { !success && <AccountLoginForm
          connectorSlug={connector.slug}
          disableSuccessTimeout={disableSuccessTimeout}
          error={error && error.message === ACCOUNT_ERRORS.LOGIN_FAILED}
          fields={fields}
          forceEnabled={!!error}
          isOAuth={connector.oauth}
          isUnloading={isUnloading}
          oAuthTerminated={oAuthTerminated}
          onSubmit={onSubmit}
          submitting={submitting}
        /> }

        { success && <KonnectorSuccess
          connector={connector}
          driveUrl={driveUrl}
          folderId={account.folderId}
          folderPath={folderPath}
          isTimeout={isTimeout}
          isUnloading={isUnloading}
          onAccountConfig={onAccountConfig}
          onCancel={onCancel}
          success={success}
        /> }

      </div>

      <AccountConnectionData
        connector={connector}
      />

    </div>
  )
}

export default translate()(KonnectorInstall)<commit_msg>fix: avoid error when account is null :ambulance: Account should not be null, but it's a matter for later.<commit_after>import React from 'react'
import { translate } from 'cozy-ui/react/I18n'
import styles from '../styles/konnectorInstall'

import AccountConnectionData from './AccountConnectionData'
import AccountLoginForm from './AccountLoginForm'
import DescriptionContent from './DescriptionContent'
import KonnectorSuccess from './KonnectorSuccess'

import { ACCOUNT_ERRORS } from '../lib/accounts'

export const KonnectorInstall = ({ t, account, connector, deleting, disableSuccessTimeout, driveUrl, error, fields, folderPath, isTimeout, isUnloading, oAuthTerminated, onAccountConfig, onCancel, onDelete, onSubmit, submitting, success }) => {
  const securityIcon = require('../assets/icons/color/icon-cloud-lock.svg')
  const { hasDescriptions } = connector

  return (
    <div className={styles['col-account-connection-content']}>
      <div className={styles['col-account-connection-form']}>

        { error && error.message !== ACCOUNT_ERRORS.LOGIN_FAILED && <DescriptionContent
          cssClassesObject={{'coz-error': true}}
          title={t('account.message.error.global.title')}
          messages={[t('account.message.error.global.description', {name: connector.name})]}
        /> }

        <DescriptionContent
          title={t('account.config.title', { name: connector.name })}
          messages={hasDescriptions && hasDescriptions.connector
            ? [t(`connector.${connector.slug}.description.connector`)]
            : []}
        >
          { !connector.oauth && <p className={styles['col-account-connection-security']}>
            <svg>
              <use xlinkHref={securityIcon} />
            </svg>
            {t('account.config.security')}
          </p> }
        </DescriptionContent>

        { !success && <AccountLoginForm
          connectorSlug={connector.slug}
          disableSuccessTimeout={disableSuccessTimeout}
          error={error && error.message === ACCOUNT_ERRORS.LOGIN_FAILED}
          fields={fields}
          forceEnabled={!!error}
          isOAuth={connector.oauth}
          isUnloading={isUnloading}
          oAuthTerminated={oAuthTerminated}
          onSubmit={onSubmit}
          submitting={submitting}
        /> }

        { success && <KonnectorSuccess
          connector={connector}
          driveUrl={driveUrl}
          folderId={account && account.folderId}
          folderPath={folderPath}
          isTimeout={isTimeout}
          isUnloading={isUnloading}
          onAccountConfig={onAccountConfig}
          onCancel={onCancel}
          success={success}
        /> }

      </div>

      <AccountConnectionData
        connector={connector}
      />

    </div>
  )
}

export default translate()(KonnectorInstall)
{'fraction_non_alphanumeric': 0.12654097171863668, 'fraction_numerical': 0.0007251631617113851, 'mean_word_length': 2.8419220055710306, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7302361', 'n_tokens_mistral': 1479, 'n_tokens_neox': 1447, 'n_words': 264}