All files / libs/assignments/quotas/components/src/lib/quota-table/cell QuotaTableNameCell.tsx

100% Statements 2/2
75% Branches 3/4
100% Functions 1/1
100% Lines 2/2

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                            54x     20x                                                                                            
import { css } from '@emotion/react';
import { memo } from 'react';
import { FormattedMessage } from 'react-intl';
import { generatePath } from 'react-router-dom';
 
import { FormFieldLabel, Group, Table, TextOverflow } from '@allshares/studio-design-system';
import { DesignerTokenIcon } from '@amalia/amalia-lang/tokens/components';
import { TokenType, type Quota } from '@amalia/amalia-lang/tokens/types';
import { routes } from '@amalia/core/routes';
 
export type QuotaTableNameCellProps = {
  readonly quota: Quota;
};
 
export const QuotaTableNameCell = memo(function QuotaTableNameCell({
  quota: { id, format, isQuotaRequired, name },
}: QuotaTableNameCellProps) {
  return (
    <Table.Cell.Main
      link={
        <Table.Cell.Main.Link to={generatePath(routes.QUOTAS_VALUE, { variableId: id })}>
          <FormattedMessage defaultMessage="View quota assignments" />
        </Table.Cell.Main.Link>
      }
    >
      <Group
        align="center"
        gap={8}
      >
        <DesignerTokenIcon
          height={14}
          tokenFormat={format}
          tokenType={TokenType.QUOTA}
          width={14}
          css={css`
            box-sizing: content-box;
          `}
        />
 
        <FormFieldLabel
          required={isQuotaRequired ?? false}
          size="medium"
          css={css`
            min-width: 0;
 
            label {
              min-width: 0;
              overflow: hidden;
              text-overflow: ellipsis;
            }
          `}
          tooltip={
            isQuotaRequired ? (
              <FormattedMessage defaultMessage="Required for statement calculation.{br}Empty values will result in a calculation error for the corresponding statement period." />
            ) : null
          }
        >
          <TextOverflow>{name}</TextOverflow>
        </FormFieldLabel>
      </Group>
    </Table.Cell.Main>
  );
});