Files
twenty_crm/front/src/modules/companies/components/CompanyEditableNameCell.tsx
Lucas Bordeau 5e2673a2a4 Lucas/t 366 on comment drawer when i have comments on the selected (#201)
* Fixed right drawer width and shared in theme

* Added date packages and tooltip

* Added date utils and tests

* Added comment thread components

* Fixed comment chip

* Fix from rebase

* Fix from rebase

* Fix margin right

* Fixed CSS and graphql
2023-06-07 10:48:44 +00:00

58 lines
1.5 KiB
TypeScript

import { CellCommentChip } from '@/comments/components/comments/CellCommentChip';
import { useOpenCommentRightDrawer } from '@/comments/hooks/useOpenCommentRightDrawer';
import { useCompanyCommentsCountQuery } from '@/comments/services';
import EditableChip from '@/ui/components/editable-cell/types/EditableChip';
import { getLogoUrlFromDomainName } from '@/utils/utils';
import { Company } from '../interfaces/company.interface';
import { updateCompany } from '../services';
import CompanyChip from './CompanyChip';
type OwnProps = {
company: Company;
};
export function CompanyEditableNameChipCell({ company }: OwnProps) {
const openCommentRightDrawer = useOpenCommentRightDrawer();
function handleCommentClick(event: React.MouseEvent<HTMLDivElement>) {
event.preventDefault();
event.stopPropagation();
openCommentRightDrawer([
{
type: 'Company',
id: company.id,
},
]);
}
const commentCount = useCompanyCommentsCountQuery(company.id);
const displayCommentCount = !commentCount.loading;
return (
<EditableChip
value={company.name || ''}
placeholder="Name"
picture={getLogoUrlFromDomainName(company.domainName)}
changeHandler={(value: string) => {
updateCompany({
...company,
name: value,
});
}}
ChipComponent={CompanyChip}
rightEndContents={[
displayCommentCount && (
<CellCommentChip
count={commentCount.data ?? 0}
onClick={handleCommentClick}
/>
),
]}
/>
);
}