All files / app/src/entities/user/ui/profile-header-content profile-header-content.tsx

87.5% Statements 21/24
33.33% Branches 1/3
100% Functions 1/1
87.5% Lines 21/24

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 401x                       1x 2x 2x   2x 2x 2x 2x 2x 2x   2x 2x 2x         2x 2x 2x 2x 2x 2x 2x   2x  
import { FC } from 'react'
import { Button } from '@tmk/ui-kit'
import { useTranslate } from '@/shared/lib'
import {
  DRAFT_OPERATIONS_FILTERS_BY_STATUS,
  operationNameAtom,
  OPERATIONS_DRAFT_PRIMARY_KEY,
  useOperationJournal,
  getOperationDraftNameFilters,
} from '@/entities/accounting-object'
import { useAtomValue } from 'jotai'
 
export const ProfileHeaderContent: FC = () => {
  const { t } = useTranslate(['common'])
  const operationName = useAtomValue(operationNameAtom)
 
  const { data: draftOperations } = useOperationJournal(OPERATIONS_DRAFT_PRIMARY_KEY, {
    filters: {
      status: DRAFT_OPERATIONS_FILTERS_BY_STATUS,
      ...getOperationDraftNameFilters(operationName),
    },
  })
 
  return (
    <div className='flex items-center gap-x-2.5'>
      {!!draftOperations?.['hydra:totalItems'] && (
        <div className='px-2 py-1 bg-gray-tertiary rounded-base hover:cursor-pointer'>
          <h2 className='text-text-secondary'>{draftOperations['hydra:totalItems']}</h2>
        </div>
      )}
      <Button href='/profile/operations/draft' variant='outlined' color='secondary'>
        <h3>{t('Incomplete operations')}</h3>
      </Button>
      <Button href='/profile/operations'>
        <h3>{t('Operations changelog')}</h3>
      </Button>
    </div>
  )
}