All files / src/components/StyledTypography StyledTypography.tsx

81.81% Statements 9/11
100% Branches 7/7
100% Functions 2/2
81.81% Lines 9/11

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 436x 6x       9x 4x   5x 5x                   11x 9x 9x                                          
import React from 'react';
import { Typography, useI18nContext } from '@procore/core-react';
import { PCNResult } from '../../models/PCNSearchResponse';
 
export function getFontColor(result: PCNResult, currentBusinessId: string) {
  if (result.id === currentBusinessId) {
    return '#9F3C0D';
  }
  if (result.vendor_id) {
    return '#1D5CC9';
  }
  return 'none';
}
 
export interface StyledTypographyProps {
  result: PCNResult;
  businessId: string;
}
 
export function StyledTypography(props: StyledTypographyProps) {
  const i18n = useI18nContext();
  return (
    <Typography
      style={{
        position: 'absolute',
        top: -22,
        fontSize: 12,
        fontWeight: 600,
        letterSpacing: 0.25,
        color: getFontColor(props.result, props.businessId),
      }}
    >
      {props.result.id === props.businessId &&
        i18n.t('views.generic.directory.add_company_package.your_company')}
      {props.result.id !== props.businessId &&
        props.result.vendor_id &&
        i18n.t(
          'views.generic.directory.add_company_package.in_your_company_directory'
        )}
    </Typography>
  );
}