All files / app/src/features/passport/ui/variable-characteristics-passport variable-characteristics-passport.tsx

100% Statements 68/68
21.42% Branches 3/14
100% Functions 1/1
100% Lines 68/68

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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 851x                           1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 1x 1x 1x   1x  
import { FC } from 'react'
import { useTranslate } from '@/shared/lib'
import { getAgeFromDate } from '@/shared/helpers'
import { BaseInfoPassport } from '@/features/passport'
import cn from 'classnames'
import { Pipe } from '@/entities/pipe'
import { AccountingType } from '@/entities/accounting-object'
import dayjs from 'dayjs'
import { DEFAULT_DATE_FORMAT } from '@/shared/config'
 
export interface VariableCharacteristicsPassportProps {
  pipe?: Pipe
}
 
export const VariableCharacteristicsPassport: FC<VariableCharacteristicsPassportProps> = ({ pipe }) => {
  const { t } = useTranslate(['accounting-object', 'common'])
  const info = [
    {
      title: t('Object_type'),
      value: pipe?.accountingObject?.type && t(`${pipe?.accountingObject?.type}`),
      isTruncated: true,
    },
 
    {
      title: t('Age'),
      value: getAgeFromDate(pipe?.manufactureDate as string, t),
    },
 
    {
      title: t('affiliation'),
      value: t(`affiliation_${pipe?.affiliation}`),
    },
    {
      title: t('number'),
      value: pipe?.package?.number,
      isHide: pipe?.accountingObject?.type === AccountingType.SINGLE,
    },
    {
      title: t('warehouse'),
      value: pipe?.accountingObject?.warehouseContract?.warehouse?.name,
    },
    {
      title: t('rack'),
      value: pipe?.accountingObject?.row?.rack?.name,
    },
    {
      title: t('row'),
      value: pipe?.accountingObject?.row?.orderNumber,
    },
    {
      title: t('preservationLubricant'),
      value: pipe?.preservationLubricant?.name,
      isLarge: true,
    },
    {
      title: t('preservationLubricantDate'),
      value: dayjs(pipe?.preservationLubricantDate).format(DEFAULT_DATE_FORMAT),
      isLarge: true,
    },
  ]
  return (
    <div className='flex flex-col bg-white p-5 gap-y-2.5 w-full'>
      <h2 className='text-black'>{t('Variable Characteristics')}</h2>
      <div className='bg-gray-tertiary rounded-base p-4 grid grid-cols-4 h-full gap-2.5'>
        {info.map((item, index) => (
          <BaseInfoPassport
            title={item.title}
            value={item.value}
            className={cn({
              'col-span-2': index === 0 || item.isLarge,
              'col-span-1': index !== 0,
            })}
            key={index + item.title}
            isHide={item.isHide}
            isTruncated={item.isTruncated}
            childrenClassName={cn({
              '!line-clamp-none !truncate !block': item?.isTruncated,
            })}
          />
        ))}
      </div>
    </div>
  )
}