All files / app/src/features/import/ui/import-errors-count-block import-errors-count-block.tsx

100% Statements 37/37
100% Branches 4/4
100% Functions 1/1
100% Lines 37/37

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 531x                   1x 4x 4x 4x 4x 4x 4x   4x 4x 4x 4x 4x 4x 4x   4x 4x 4x 4x 4x 4x 4x   4x 4x 4x 2x 2x 2x 2x 2x 2x 2x   2x 2x 2x   4x   4x  
import { FCWithClassName } from '@tmk/ui-kit'
import cn from 'classnames'
import { TFunction } from 'next-i18next'
import { getDeclination } from '../../lib/get-declination'
 
export interface ImportErrorsCountBlockProps {
  objectsCount: number
  errorsCount?: number
  t: TFunction
}
export const ImportErrorsCountBlock: FCWithClassName<ImportErrorsCountBlockProps> = ({
  objectsCount,
  errorsCount,
  className,
  t,
}) => {
  const errorMessage = errorsCount && getDeclination('mistake', 'errors', 'errors', errorsCount, t)
 
  const objectCountSuccessMessage = getDeclination(
    'object_processed_successfully',
    'objects_processed_successfully_per_five',
    'objects_processed_successfully',
    objectsCount,
    t
  )
 
  const objectCountMessage = getDeclination(
    'object_loaded_from',
    'object_loaded_per_five_from',
    'objects_loaded_from',
    objectsCount,
    t
  )
 
  return (
    <div className={cn('flex justify-center items-center', className)} data-testid='import-errors-count-block'>
      {errorsCount ? (
        <span className='text-main-regular text-text-secondary'>
          <span className='text-main-semibold'>{objectsCount}</span> {objectCountMessage}{' '}
          <span className='text-main-semibold text-red'>
            {errorsCount} {errorMessage}
          </span>
          , <>{t('please_correct_them_and_upload_the_file_again')}</>
        </span>
      ) : (
        <span className='text-main-regular text-text-secondary'>
          <span className='text-main-semibold text-green-unit'>{objectsCount}</span> {objectCountSuccessMessage}
        </span>
      )}
    </div>
  )
}