Files
twenty/front/src/modules/people/constants/peopleAvailableColumnDefinitions.tsx
bosiraphael b9f23d9be6 Refactor RelationFieldDisplay to eliminate dependency on non-ui components (#1949)
* job done

* removed example type

* removed unused temporary type
2023-10-09 22:38:47 +02:00

165 lines
4.6 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ColumnDefinition } from '@/ui/data-table/types/ColumnDefinition';
import {
FieldDateMetadata,
FieldDoubleTextChipMetadata,
FieldEmailMetadata,
FieldMetadata,
FieldPhoneMetadata,
FieldRelationMetadata,
FieldTextMetadata,
FieldURLMetadata,
} from '@/ui/field/types/FieldMetadata';
import {
IconArrowUpRight,
IconBrandLinkedin,
IconBrandX,
IconBriefcase,
IconBuildingSkyscraper,
IconCalendarEvent,
IconMail,
IconMap,
IconPencil,
IconPhone,
IconUser,
} from '@/ui/icon/index';
import { Entity } from '@/ui/input/relation-picker/types/EntityTypeForSelect';
import { Company } from '~/generated/graphql';
import { getLogoUrlFromDomainName } from '~/utils';
export const peopleAvailableColumnDefinitions: ColumnDefinition<FieldMetadata>[] =
[
{
key: 'displayName',
name: 'People',
Icon: IconUser,
size: 210,
index: 0,
type: 'double-text-chip',
metadata: {
firstValueFieldName: 'firstName',
secondValueFieldName: 'lastName',
firstValuePlaceholder: 'First name', // Hack: Fake character to prevent password-manager from filling the field
secondValuePlaceholder: 'Last name', // Hack: Fake character to prevent password-manager from filling the field
avatarUrlFieldName: 'avatarUrl',
entityType: Entity.Person,
},
buttonIcon: IconArrowUpRight,
infoTooltipContent: 'Contacts first and last name.',
basePathToShowPage: '/person/',
} satisfies ColumnDefinition<FieldDoubleTextChipMetadata>,
{
key: 'email',
name: 'Email',
Icon: IconMail,
size: 150,
type: 'email',
index: 1,
metadata: {
fieldName: 'email',
placeHolder: 'Email', // Hack: Fake character to prevent password-manager from filling the field
},
buttonIcon: IconPencil,
infoTooltipContent: 'Contacts Email.',
} satisfies ColumnDefinition<FieldEmailMetadata>,
{
key: 'company',
name: 'Company',
Icon: IconBuildingSkyscraper,
size: 150,
index: 2,
type: 'relation',
metadata: {
fieldName: 'company',
relationType: Entity.Company,
},
infoTooltipContent: 'Contacts company.',
entityChipDisplayMapper: (dataObject: Company) => {
return {
name: dataObject?.name,
pictureUrl: getLogoUrlFromDomainName(dataObject?.domainName),
avatarType: 'squared',
};
},
} satisfies ColumnDefinition<FieldRelationMetadata>,
{
key: 'phone',
name: 'Phone',
Icon: IconPhone,
size: 150,
index: 3,
type: 'phone',
metadata: {
fieldName: 'phone',
placeHolder: 'Phone', // Hack: Fake character to prevent password-manager from filling the field
},
buttonIcon: IconPencil,
infoTooltipContent: 'Contacts phone number.',
} satisfies ColumnDefinition<FieldPhoneMetadata>,
{
key: 'createdAt',
name: 'Creation',
Icon: IconCalendarEvent,
size: 150,
index: 4,
type: 'date',
metadata: {
fieldName: 'createdAt',
},
infoTooltipContent: 'Date when the contact was added.',
} satisfies ColumnDefinition<FieldDateMetadata>,
{
key: 'city',
name: 'City',
Icon: IconMap,
size: 150,
index: 5,
type: 'text',
metadata: {
fieldName: 'city',
placeHolder: 'City', // Hack: Fake character to prevent password-manager from filling the field
},
infoTooltipContent: 'Contacts city.',
} satisfies ColumnDefinition<FieldTextMetadata>,
{
key: 'jobTitle',
name: 'Job title',
Icon: IconBriefcase,
size: 150,
index: 6,
type: 'text',
metadata: {
fieldName: 'jobTitle',
placeHolder: 'Job title',
},
infoTooltipContent: 'Contacts job title.',
} satisfies ColumnDefinition<FieldTextMetadata>,
{
key: 'linkedin',
name: 'LinkedIn',
Icon: IconBrandLinkedin,
size: 150,
index: 7,
type: 'url',
metadata: {
fieldName: 'linkedinUrl',
placeHolder: 'LinkedIn',
},
buttonIcon: IconPencil,
infoTooltipContent: 'Contacts Linkedin account.',
} satisfies ColumnDefinition<FieldURLMetadata>,
{
key: 'x',
name: 'Twitter',
Icon: IconBrandX,
size: 150,
index: 8,
type: 'url',
metadata: {
fieldName: 'xUrl',
placeHolder: 'X',
},
buttonIcon: IconPencil,
infoTooltipContent: 'Contacts Twitter account.',
} satisfies ColumnDefinition<FieldURLMetadata>,
];