Files
twenty/front/src/modules/ui/chip/components/EntityChip.tsx
Ayush Agrawal 77997674e5 Feat: Add "All assignees" in Task team member dropdown (#1763)
* implemented all select option FilterDropdownEntitySearchSelect and enabled it for tasks page filter

* created new filter operand IsNotNull for make a select all qraphql query, added internal state for tracking isAllEntitySelected

* used filterCurrentlyEdited to track if isAllEntitySelected is selected

* fixed filter button icon SelectAll Icon
2023-10-03 16:55:31 +02:00

77 lines
1.8 KiB
TypeScript

import * as React from 'react';
import { useNavigate } from 'react-router-dom';
import { useTheme } from '@emotion/react';
import { IconComponent } from '@/ui/icon/types/IconComponent';
import { Avatar, AvatarType } from '@/users/components/Avatar';
import { isNonEmptyString } from '~/utils/isNonEmptyString';
import { Chip, ChipVariant } from './Chip';
type OwnProps = {
linkToEntity?: string;
entityId: string;
name: string;
pictureUrl?: string;
avatarType?: AvatarType;
variant?: EntityChipVariant;
LeftIcon?: IconComponent;
};
export enum EntityChipVariant {
Regular = 'regular',
Transparent = 'transparent',
}
export const EntityChip = ({
linkToEntity,
entityId,
name,
pictureUrl,
avatarType = 'rounded',
variant = EntityChipVariant.Regular,
LeftIcon,
}: OwnProps) => {
const navigate = useNavigate();
const theme = useTheme();
const handleLinkClick = (event: React.MouseEvent<HTMLDivElement>) => {
if (linkToEntity) {
event.preventDefault();
event.stopPropagation();
navigate(linkToEntity);
}
};
return isNonEmptyString(name) ? (
<div onClick={handleLinkClick}>
<Chip
label={name}
variant={
linkToEntity
? variant === EntityChipVariant.Regular
? ChipVariant.Highlighted
: ChipVariant.Regular
: ChipVariant.Transparent
}
leftComponent={
LeftIcon ? (
<LeftIcon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
) : (
<Avatar
avatarUrl={pictureUrl}
colorId={entityId}
placeholder={name}
size="sm"
type={avatarType}
/>
)
}
/>
</div>
) : (
<></>
);
};