Skip to content

The open alternative to Salesforce, designed for AI.

1.6 KB
Raw Blame
import { styled } from '@linaria/react';
import { type ReactNode } from 'react';

import { SettingsItemTypeTag } from '@/settings/components/SettingsItemTypeTag';
import { TableCell } from '@/ui/layout/table/components/TableCell';
import { TableRow } from '@/ui/layout/table/components/TableRow';
import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
import { useIcons } from 'twenty-ui/icon/provider';
import { useTheme, themeCssVariables } from 'twenty-ui/theme';

import { type Skill } from '~/generated-metadata/graphql';

export type SettingsSkillTableRowProps = {
  skill: Omit<Skill, 'isCustom'>;
  action?: ReactNode;
  link?: string;
};

const StyledIconContainer = styled.div`
  align-items: center;
  display: flex;
  flex-shrink: 0;
`;

export const SettingsSkillTableRow = ({
  skill,
  action,
  link,
}: SettingsSkillTableRowProps) => {
  const theme = useTheme();
  const { getIcon } = useIcons();
  const Icon = getIcon(skill.icon ?? 'IconBook');

  return (
    <TableRow
      key={skill.id}
      to={link}
      gridTemplateColumns="1fr 120px 36px"
      style={{ opacity: skill.isActive ? 1 : 0.5 }}
    >
      <TableCell
        color={themeCssVariables.font.color.primary}
        gap={themeCssVariables.spacing[2]}
        minWidth="0"
        overflow="hidden"
      >
        <StyledIconContainer>
          <Icon size={theme.icon.size.md} color={theme.color.blue9} />
        </StyledIconContainer>
        <OverflowingTextWithTooltip text={skill.label} />
      </TableCell>
      <TableCell>
        <SettingsItemTypeTag item={skill} />
      </TableCell>
      <TableCell align="right">{action}</TableCell>
    </TableRow>
  );
};