Chore: New standard fields on Companies (#1276)

* New standard fields on Companies

Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

* New standard fields on Companies

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Add requested changes

Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Make some fields hidden by default

Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Add minor refactors

Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

---------

Co-authored-by: Thiago Nascimbeni <tnascimbeni@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
This commit is contained in:
gitstart-twenty
2023-08-24 15:36:12 +00:00
committed by GitHub
parent 615018654a
commit baf92d6d65
21 changed files with 420 additions and 9 deletions

View File

@ -620,15 +620,18 @@ export type Company = {
accountOwnerId?: Maybe<Scalars['String']>;
activities: Array<Activity>;
address: Scalars['String'];
annualRecurringRevenue?: Maybe<Scalars['Int']>;
comments: Array<Comment>;
createdAt: Scalars['DateTime'];
domainName: Scalars['String'];
employees?: Maybe<Scalars['Int']>;
id: Scalars['ID'];
idealCustomerProfile: Scalars['Boolean'];
linkedinUrl?: Maybe<Scalars['String']>;
name: Scalars['String'];
people?: Maybe<Array<Person>>;
updatedAt: Scalars['DateTime'];
xUrl?: Maybe<Scalars['String']>;
};
export type CompanyCreateInput = {
@ -637,26 +640,32 @@ export type CompanyCreateInput = {
PipelineProgress?: InputMaybe<PipelineProgressCreateNestedManyWithoutCompanyInput>;
accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>;
address: Scalars['String'];
annualRecurringRevenue?: InputMaybe<Scalars['Int']>;
createdAt?: InputMaybe<Scalars['DateTime']>;
domainName: Scalars['String'];
employees?: InputMaybe<Scalars['Int']>;
id?: InputMaybe<Scalars['String']>;
idealCustomerProfile?: InputMaybe<Scalars['Boolean']>;
linkedinUrl?: InputMaybe<Scalars['String']>;
name: Scalars['String'];
people?: InputMaybe<PersonCreateNestedManyWithoutCompanyInput>;
updatedAt?: InputMaybe<Scalars['DateTime']>;
xUrl?: InputMaybe<Scalars['String']>;
};
export type CompanyCreateManyInput = {
accountOwnerId?: InputMaybe<Scalars['String']>;
address: Scalars['String'];
annualRecurringRevenue?: InputMaybe<Scalars['Int']>;
createdAt?: InputMaybe<Scalars['DateTime']>;
domainName: Scalars['String'];
employees?: InputMaybe<Scalars['Int']>;
id?: InputMaybe<Scalars['String']>;
idealCustomerProfile?: InputMaybe<Scalars['Boolean']>;
linkedinUrl?: InputMaybe<Scalars['String']>;
name: Scalars['String'];
updatedAt?: InputMaybe<Scalars['DateTime']>;
xUrl?: InputMaybe<Scalars['String']>;
};
export type CompanyCreateNestedOneWithoutActivityTargetInput = {
@ -688,14 +697,17 @@ export type CompanyOrderByWithRelationInput = {
accountOwner?: InputMaybe<UserOrderByWithRelationInput>;
accountOwnerId?: InputMaybe<SortOrder>;
address?: InputMaybe<SortOrder>;
annualRecurringRevenue?: InputMaybe<SortOrder>;
createdAt?: InputMaybe<SortOrder>;
domainName?: InputMaybe<SortOrder>;
employees?: InputMaybe<SortOrder>;
id?: InputMaybe<SortOrder>;
idealCustomerProfile?: InputMaybe<SortOrder>;
linkedinUrl?: InputMaybe<SortOrder>;
name?: InputMaybe<SortOrder>;
people?: InputMaybe<PersonOrderByRelationAggregateInput>;
updatedAt?: InputMaybe<SortOrder>;
xUrl?: InputMaybe<SortOrder>;
};
export type CompanyRelationFilter = {
@ -706,15 +718,18 @@ export type CompanyRelationFilter = {
export enum CompanyScalarFieldEnum {
AccountOwnerId = 'accountOwnerId',
Address = 'address',
AnnualRecurringRevenue = 'annualRecurringRevenue',
CreatedAt = 'createdAt',
DeletedAt = 'deletedAt',
DomainName = 'domainName',
Employees = 'employees',
Id = 'id',
IdealCustomerProfile = 'idealCustomerProfile',
LinkedinUrl = 'linkedinUrl',
Name = 'name',
UpdatedAt = 'updatedAt',
WorkspaceId = 'workspaceId'
WorkspaceId = 'workspaceId',
XUrl = 'xUrl'
}
export type CompanyUpdateInput = {
@ -723,14 +738,17 @@ export type CompanyUpdateInput = {
PipelineProgress?: InputMaybe<PipelineProgressUpdateManyWithoutCompanyNestedInput>;
accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>;
address?: InputMaybe<Scalars['String']>;
annualRecurringRevenue?: InputMaybe<Scalars['Int']>;
createdAt?: InputMaybe<Scalars['DateTime']>;
domainName?: InputMaybe<Scalars['String']>;
employees?: InputMaybe<Scalars['Int']>;
id?: InputMaybe<Scalars['String']>;
idealCustomerProfile?: InputMaybe<Scalars['Boolean']>;
linkedinUrl?: InputMaybe<Scalars['String']>;
name?: InputMaybe<Scalars['String']>;
people?: InputMaybe<PersonUpdateManyWithoutCompanyNestedInput>;
updatedAt?: InputMaybe<Scalars['DateTime']>;
xUrl?: InputMaybe<Scalars['String']>;
};
export type CompanyUpdateManyWithoutAccountOwnerNestedInput = {
@ -765,14 +783,17 @@ export type CompanyWhereInput = {
accountOwner?: InputMaybe<UserRelationFilter>;
accountOwnerId?: InputMaybe<StringNullableFilter>;
address?: InputMaybe<StringFilter>;
annualRecurringRevenue?: InputMaybe<IntNullableFilter>;
createdAt?: InputMaybe<DateTimeFilter>;
domainName?: InputMaybe<StringFilter>;
employees?: InputMaybe<IntNullableFilter>;
id?: InputMaybe<StringFilter>;
idealCustomerProfile?: InputMaybe<BoolFilter>;
linkedinUrl?: InputMaybe<StringNullableFilter>;
name?: InputMaybe<StringFilter>;
people?: InputMaybe<PersonListRelationFilter>;
updatedAt?: InputMaybe<DateTimeFilter>;
xUrl?: InputMaybe<StringNullableFilter>;
};
export type CompanyWhereUniqueInput = {
@ -3047,7 +3068,7 @@ export type GetClientConfigQueryVariables = Exact<{ [key: string]: never; }>;
export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, debugMode: boolean, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean }, telemetry: { __typename?: 'Telemetry', enabled: boolean, anonymizationEnabled: boolean }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null } } };
export type CompanyFieldsFragmentFragment = { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, linkedinUrl?: string | null, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null };
export type CompanyFieldsFragmentFragment = { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, linkedinUrl?: string | null, xUrl?: string | null, annualRecurringRevenue?: number | null, idealCustomerProfile: boolean, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null };
export type DeleteManyCompaniesMutationVariables = Exact<{
ids?: InputMaybe<Array<Scalars['String']> | Scalars['String']>;
@ -3068,7 +3089,7 @@ export type InsertOneCompanyMutationVariables = Exact<{
}>;
export type InsertOneCompanyMutation = { __typename?: 'Mutation', createOneCompany: { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, linkedinUrl?: string | null, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null } };
export type InsertOneCompanyMutation = { __typename?: 'Mutation', createOneCompany: { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, linkedinUrl?: string | null, xUrl?: string | null, annualRecurringRevenue?: number | null, idealCustomerProfile: boolean, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null } };
export type UpdateOneCompanyMutationVariables = Exact<{
where: CompanyWhereUniqueInput;
@ -3076,7 +3097,7 @@ export type UpdateOneCompanyMutationVariables = Exact<{
}>;
export type UpdateOneCompanyMutation = { __typename?: 'Mutation', updateOneCompany?: { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, linkedinUrl?: string | null, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null } | null };
export type UpdateOneCompanyMutation = { __typename?: 'Mutation', updateOneCompany?: { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, linkedinUrl?: string | null, xUrl?: string | null, annualRecurringRevenue?: number | null, idealCustomerProfile: boolean, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null } | null };
export type GetCompaniesQueryVariables = Exact<{
orderBy?: InputMaybe<Array<CompanyOrderByWithRelationInput> | CompanyOrderByWithRelationInput>;
@ -3084,14 +3105,14 @@ export type GetCompaniesQueryVariables = Exact<{
}>;
export type GetCompaniesQuery = { __typename?: 'Query', companies: Array<{ __typename?: 'Company', id: string, domainName: string, name: string, createdAt: string, address: string, linkedinUrl?: string | null, employees?: number | null, _activityCount: number, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } | null }> };
export type GetCompaniesQuery = { __typename?: 'Query', companies: Array<{ __typename?: 'Company', id: string, domainName: string, name: string, createdAt: string, address: string, linkedinUrl?: string | null, xUrl?: string | null, annualRecurringRevenue?: number | null, idealCustomerProfile: boolean, employees?: number | null, _activityCount: number, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } | null }> };
export type GetCompanyQueryVariables = Exact<{
where: CompanyWhereUniqueInput;
}>;
export type GetCompanyQuery = { __typename?: 'Query', findUniqueCompany: { __typename?: 'Company', id: string, domainName: string, name: string, createdAt: string, address: string, linkedinUrl?: string | null, employees?: number | null, _activityCount: number, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null, Favorite?: Array<{ __typename?: 'Favorite', id: string, person?: { __typename?: 'Person', id: string } | null, company?: { __typename?: 'Company', id: string } | null }> | null } };
export type GetCompanyQuery = { __typename?: 'Query', findUniqueCompany: { __typename?: 'Company', id: string, domainName: string, name: string, createdAt: string, address: string, linkedinUrl?: string | null, xUrl?: string | null, annualRecurringRevenue?: number | null, idealCustomerProfile: boolean, employees?: number | null, _activityCount: number, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null, Favorite?: Array<{ __typename?: 'Favorite', id: string, person?: { __typename?: 'Person', id: string } | null, company?: { __typename?: 'Company', id: string } | null }> | null } };
export type DeleteFavoriteMutationVariables = Exact<{
where: FavoriteWhereInput;
@ -3302,7 +3323,7 @@ export type SearchCompanyQueryVariables = Exact<{
}>;
export type SearchCompanyQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, linkedinUrl?: string | null, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null }> };
export type SearchCompanyQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, linkedinUrl?: string | null, xUrl?: string | null, annualRecurringRevenue?: number | null, idealCustomerProfile: boolean, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null }> };
export type SearchPeopleQueryVariables = Exact<{
where?: InputMaybe<PersonWhereInput>;
@ -3628,6 +3649,9 @@ export const CompanyFieldsFragmentFragmentDoc = gql`
domainName
employees
linkedinUrl
xUrl
annualRecurringRevenue
idealCustomerProfile
id
name
}
@ -4514,6 +4538,9 @@ export const GetCompaniesDocument = gql`
createdAt
address
linkedinUrl
xUrl
annualRecurringRevenue
idealCustomerProfile
employees
_activityCount
accountOwner {
@ -4565,6 +4592,9 @@ export const GetCompanyDocument = gql`
createdAt
address
linkedinUrl
xUrl
annualRecurringRevenue
idealCustomerProfile
employees
_activityCount
accountOwner {

View File

@ -1,8 +1,10 @@
import {
ViewFieldBooleanMetadata,
ViewFieldChipMetadata,
ViewFieldDateMetadata,
ViewFieldDefinition,
ViewFieldMetadata,
ViewFieldMoneyMetadata,
ViewFieldNumberMetadata,
ViewFieldRelationMetadata,
ViewFieldTextMetadata,
@ -10,10 +12,13 @@ import {
} from '@/ui/editable-field/types/ViewField';
import {
IconBrandLinkedin,
IconBrandX,
IconBuildingSkyscraper,
IconCalendarEvent,
IconLink,
IconMap,
IconMoneybag,
IconTarget,
IconUserCircle,
IconUsers,
} from '@/ui/icon/index';
@ -111,4 +116,40 @@ export const companyViewFields: ViewFieldDefinition<ViewFieldMetadata>[] = [
},
isVisible: true,
} satisfies ViewFieldDefinition<ViewFieldTextMetadata>,
{
id: 'idealCustomerProfile',
columnLabel: 'ICP',
columnIcon: <IconTarget />,
columnSize: 150,
columnOrder: 8,
metadata: {
type: 'boolean',
fieldName: 'idealCustomerProfile',
},
isVisible: false,
} satisfies ViewFieldDefinition<ViewFieldBooleanMetadata>,
{
id: 'annualRecurringRevenue',
columnLabel: 'ARR',
columnIcon: <IconMoneybag />,
columnSize: 150,
columnOrder: 8,
metadata: {
type: 'moneyAmount',
fieldName: 'annualRecurringRevenue',
},
} satisfies ViewFieldDefinition<ViewFieldMoneyMetadata>,
{
id: 'xUrl',
columnLabel: 'Twitter',
columnIcon: <IconBrandX />,
columnSize: 150,
columnOrder: 8,
metadata: {
type: 'url',
fieldName: 'xUrl',
placeHolder: 'X',
},
isVisible: false,
} satisfies ViewFieldDefinition<ViewFieldURLMetadata>,
];

View File

@ -13,6 +13,9 @@ export const COMPANY_FIELDS_FRAGMENT = gql`
domainName
employees
linkedinUrl
xUrl
annualRecurringRevenue
idealCustomerProfile
id
name
}

View File

@ -12,6 +12,9 @@ export const GET_COMPANIES = gql`
createdAt
address
linkedinUrl
xUrl
annualRecurringRevenue
idealCustomerProfile
employees
_activityCount
accountOwner {

View File

@ -9,6 +9,9 @@ export const GET_COMPANY = gql`
createdAt
address
linkedinUrl
xUrl
annualRecurringRevenue
idealCustomerProfile
employees
_activityCount
accountOwner {

View File

@ -10,6 +10,9 @@ type MockedCompany = Pick<
| 'address'
| 'employees'
| 'linkedinUrl'
| 'xUrl'
| 'annualRecurringRevenue'
| 'idealCustomerProfile'
| '_activityCount'
> & {
accountOwner: Pick<
@ -30,6 +33,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
domainName: 'airbnb.com',
name: 'Airbnb',
linkedinUrl: 'https://www.linkedin.com/company/airbnb/',
xUrl: 'https://twitter.com/airbnb',
annualRecurringRevenue: 500000,
idealCustomerProfile: true,
createdAt: '2023-04-26T10:08:54.724515+00:00',
address: 'San Francisco, CA',
employees: 5000,
@ -50,6 +56,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
domainName: 'qonto.com',
name: 'Qonto',
linkedinUrl: 'https://www.linkedin.com/company/qonto/',
xUrl: 'https://twitter.com/qonto',
annualRecurringRevenue: 500000,
idealCustomerProfile: false,
createdAt: '2023-04-26T10:12:42.33625+00:00',
address: 'Paris, France',
employees: 800,
@ -62,6 +71,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
domainName: 'stripe.com',
name: 'Stripe',
linkedinUrl: 'https://www.linkedin.com/company/stripe/',
xUrl: 'https://twitter.com/stripe',
annualRecurringRevenue: 5000000,
idealCustomerProfile: false,
createdAt: '2023-04-26T10:10:32.530184+00:00',
address: 'San Francisco, CA',
employees: 8000,
@ -73,6 +85,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
id: 'b1cfd51b-a831-455f-ba07-4e30671e1dc3',
domainName: 'figma.com',
linkedinUrl: 'https://www.linkedin.com/company/figma/',
xUrl: 'https://twitter.com/figma',
annualRecurringRevenue: 50000,
idealCustomerProfile: true,
name: 'Figma',
createdAt: '2023-03-21T06:30:25.39474+00:00',
address: 'San Francisco, CA',
@ -85,6 +100,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
id: '5c21e19e-e049-4393-8c09-3e3f8fb09ecb',
domainName: 'notion.com',
linkedinUrl: 'https://www.linkedin.com/company/notion/',
xUrl: 'https://twitter.com/notion',
annualRecurringRevenue: 500000,
idealCustomerProfile: false,
name: 'Notion',
createdAt: '2023-04-26T10:13:29.712485+00:00',
address: 'San Francisco, CA',

View File

@ -9,10 +9,12 @@ export type FieldType =
| 'double-text-chip'
| 'double-text'
| 'number'
| 'boolean'
| 'date'
| 'phone'
| 'url'
| 'probability';
| 'probability'
| 'moneyAmount';
export type FieldTextMetadata = {
placeHolder: string;

View File

@ -11,7 +11,9 @@ export type ViewFieldType =
| 'date'
| 'phone'
| 'url'
| 'probability';
| 'probability'
| 'boolean'
| 'moneyAmount';
export type ViewFieldTextMetadata = {
type: 'text';
@ -42,6 +44,16 @@ export type ViewFieldNumberMetadata = {
isPositive?: boolean;
};
export type ViewFieldMoneyMetadata = {
type: 'moneyAmount';
fieldName: string;
};
export type ViewFieldBooleanMetadata = {
type: 'boolean';
fieldName: string;
};
export type ViewFieldRelationMetadata = {
type: 'relation';
relationType: Entity;
@ -89,8 +101,10 @@ export type ViewFieldMetadata = { type: ViewFieldType } & (
| ViewFieldPhoneMetadata
| ViewFieldURLMetadata
| ViewFieldNumberMetadata
| ViewFieldBooleanMetadata
| ViewFieldDateMetadata
| ViewFieldProbabilityMetadata
| ViewFieldMoneyMetadata
);
export type ViewFieldDefinition<T extends ViewFieldMetadata | unknown> = {
@ -109,6 +123,8 @@ export type ViewFieldTextValue = string;
export type ViewFieldChipValue = string;
export type ViewFieldDateValue = string;
export type ViewFieldPhoneValue = string;
export type ViewFieldBooleanValue = boolean;
export type ViewFieldMoneyValue = number;
export type ViewFieldURLValue = string;
export type ViewFieldNumberValue = number | null;
export type ViewFieldProbabilityValue = number;

View File

@ -0,0 +1,11 @@
import {
ViewFieldBooleanMetadata,
ViewFieldDefinition,
ViewFieldMetadata,
} from '../ViewField';
export function isViewFieldBoolean(
field: ViewFieldDefinition<ViewFieldMetadata>,
): field is ViewFieldDefinition<ViewFieldBooleanMetadata> {
return field.metadata.type === 'boolean';
}

View File

@ -0,0 +1,7 @@
import { ViewFieldBooleanValue } from '../ViewField';
export function isViewFieldBooleanValue(
fieldValue: unknown,
): fieldValue is ViewFieldBooleanValue {
return typeof fieldValue === 'boolean';
}

View File

@ -0,0 +1,11 @@
import {
ViewFieldDefinition,
ViewFieldMetadata,
ViewFieldMoneyMetadata,
} from '../ViewField';
export function isViewFieldMoney(
field: ViewFieldDefinition<ViewFieldMetadata>,
): field is ViewFieldDefinition<ViewFieldMoneyMetadata> {
return field.metadata.type === 'moneyAmount';
}

View File

@ -0,0 +1,7 @@
import { ViewFieldMoneyValue } from '../ViewField';
export function isViewFieldMoneyValue(
fieldValue: unknown,
): fieldValue is ViewFieldMoneyValue {
return typeof fieldValue === 'number';
}

View File

@ -45,6 +45,7 @@ export {
IconMail,
IconMap,
IconMinus,
IconMoneybag,
IconNotes,
IconPencil,
IconPhone,
@ -53,6 +54,7 @@ export {
IconSearch,
IconSettings,
IconTag,
IconTarget,
IconTargetArrow,
IconTimelineEvent,
IconTrash,

View File

@ -1,6 +1,8 @@
import { isViewFieldBoolean } from '@/ui/editable-field/types/guards/isViewFieldBoolean';
import { isViewFieldDate } from '@/ui/editable-field/types/guards/isViewFieldDate';
import { isViewFieldDoubleText } from '@/ui/editable-field/types/guards/isViewFieldDoubleText';
import { isViewFieldDoubleTextChip } from '@/ui/editable-field/types/guards/isViewFieldDoubleTextChip';
import { isViewFieldMoney } from '@/ui/editable-field/types/guards/isViewFieldMoney';
import { isViewFieldNumber } from '@/ui/editable-field/types/guards/isViewFieldNumber';
import { isViewFieldPhone } from '@/ui/editable-field/types/guards/isViewFieldPhone';
import { isViewFieldRelation } from '@/ui/editable-field/types/guards/isViewFieldRelation';
@ -12,10 +14,12 @@ import {
} from '@/ui/editable-field/types/ViewField';
import { isViewFieldChip } from '../../../editable-field/types/guards/isViewFieldChip';
import { GenericEditableBooleanCell } from '../type/components/GenericEditableBooleanCell';
import { GenericEditableChipCell } from '../type/components/GenericEditableChipCell';
import { GenericEditableDateCell } from '../type/components/GenericEditableDateCell';
import { GenericEditableDoubleTextCell } from '../type/components/GenericEditableDoubleTextCell';
import { GenericEditableDoubleTextChipCell } from '../type/components/GenericEditableDoubleTextChipCell';
import { GenericEditableMoneyCell } from '../type/components/GenericEditableMoneyCell';
import { GenericEditableNumberCell } from '../type/components/GenericEditableNumberCell';
import { GenericEditablePhoneCell } from '../type/components/GenericEditablePhoneCell';
import { GenericEditableRelationCell } from '../type/components/GenericEditableRelationCell';
@ -43,8 +47,12 @@ export function GenericEditableCell({ viewField: fieldDefinition }: OwnProps) {
return <GenericEditableDateCell viewField={fieldDefinition} />;
} else if (isViewFieldNumber(fieldDefinition)) {
return <GenericEditableNumberCell viewField={fieldDefinition} />;
} else if (isViewFieldBoolean(fieldDefinition)) {
return <GenericEditableBooleanCell viewField={fieldDefinition} />;
} else if (isViewFieldChip(fieldDefinition)) {
return <GenericEditableChipCell viewField={fieldDefinition} />;
} else if (isViewFieldMoney(fieldDefinition)) {
return <GenericEditableMoneyCell viewField={fieldDefinition} />;
} else {
console.warn(
`Unknown field metadata type: ${fieldDefinition.metadata.type} in GenericEditableCell`,

View File

@ -0,0 +1,77 @@
import styled from '@emotion/styled';
import { IconCheck, IconX } from '@tabler/icons-react';
import { useRecoilState } from 'recoil';
import {
ViewFieldBooleanMetadata,
ViewFieldDefinition,
} from '@/ui/editable-field/types/ViewField';
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
import { useUpdateEntityField } from '@/ui/table/hooks/useUpdateEntityField';
import { tableEntityFieldFamilySelector } from '@/ui/table/states/selectors/tableEntityFieldFamilySelector';
import { EditableCellDisplayContainer } from '../../components/EditableCellContainer';
type OwnProps = {
viewField: ViewFieldDefinition<ViewFieldBooleanMetadata>;
editModeHorizontalAlign?: 'left' | 'right';
};
const StyledCellBaseContainer = styled.div`
align-items: center;
box-sizing: border-box;
cursor: pointer;
display: flex;
height: ${({ theme }) => theme.spacing(8)};
position: relative;
user-select: none;
width: 100%;
`;
const StyledCellBooleancontainer = styled.div`
margin-left: 5px;
`;
function capitalizeFirstLetter(value: string) {
return value.charAt(0).toUpperCase() + value.slice(1);
}
export function GenericEditableBooleanCell({ viewField }: OwnProps) {
const currentRowEntityId = useCurrentRowEntityId();
const [fieldValue, setFieldValue] = useRecoilState<boolean>(
tableEntityFieldFamilySelector({
entityId: currentRowEntityId ?? '',
fieldName: viewField.metadata.fieldName,
}),
);
const updateField = useUpdateEntityField();
function handleClick() {
const newValue = !fieldValue;
try {
setFieldValue(newValue);
if (currentRowEntityId && updateField) {
updateField(currentRowEntityId, viewField, newValue);
}
} catch (error) {
console.warn(
`In GenericEditableBooleanCellEditMode, Invalid value: ${newValue}, ${error}`,
);
}
}
return (
<StyledCellBaseContainer>
<EditableCellDisplayContainer onClick={handleClick}>
{fieldValue ? <IconCheck /> : <IconX />}
<StyledCellBooleancontainer>
{fieldValue !== undefined &&
capitalizeFirstLetter(fieldValue.toString())}
</StyledCellBooleancontainer>
</EditableCellDisplayContainer>
</StyledCellBaseContainer>
);
}

View File

@ -0,0 +1,47 @@
import { useRecoilValue } from 'recoil';
import {
ViewFieldDefinition,
ViewFieldMoneyMetadata,
} from '@/ui/editable-field/types/ViewField';
import { EditableCell } from '@/ui/table/editable-cell/components/EditableCell';
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
import { tableEntityFieldFamilySelector } from '@/ui/table/states/selectors/tableEntityFieldFamilySelector';
import { GenericEditableMoneyCellEditMode } from './GenericEditableMoneyCellEditMode';
type OwnProps = {
viewField: ViewFieldDefinition<ViewFieldMoneyMetadata>;
editModeHorizontalAlign?: 'left' | 'right';
};
function formatNumber(value: number) {
// Formats the value to a string and add commas to it ex: 50,000 | 500,000
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
export function GenericEditableMoneyCell({
viewField,
editModeHorizontalAlign,
}: OwnProps) {
const currentRowEntityId = useCurrentRowEntityId();
const fieldValue = useRecoilValue<number>(
tableEntityFieldFamilySelector({
entityId: currentRowEntityId ?? '',
fieldName: viewField.metadata.fieldName,
}),
);
return (
<EditableCell
editModeHorizontalAlign={editModeHorizontalAlign}
editModeContent={
<GenericEditableMoneyCellEditMode viewField={viewField} />
}
nonEditModeContent={
<>{fieldValue ? `$${formatNumber(fieldValue)}` : ''}</>
}
></EditableCell>
);
}

View File

@ -0,0 +1,58 @@
import { useRecoilState } from 'recoil';
import {
ViewFieldDefinition,
ViewFieldMoneyMetadata,
} from '@/ui/editable-field/types/ViewField';
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
import { useUpdateEntityField } from '@/ui/table/hooks/useUpdateEntityField';
import { tableEntityFieldFamilySelector } from '@/ui/table/states/selectors/tableEntityFieldFamilySelector';
import { TextCellEdit } from './TextCellEdit';
type OwnProps = {
viewField: ViewFieldDefinition<ViewFieldMoneyMetadata>;
};
export function GenericEditableMoneyCellEditMode({ viewField }: OwnProps) {
const currentRowEntityId = useCurrentRowEntityId();
const [fieldValue, setFieldValue] = useRecoilState<string>(
tableEntityFieldFamilySelector({
entityId: currentRowEntityId ?? '',
fieldName: viewField.metadata.fieldName,
}),
);
const updateField = useUpdateEntityField();
function handleSubmit(newText: string) {
if (newText === fieldValue) return;
try {
const numberValue = parseInt(newText);
if (isNaN(numberValue)) {
throw new Error('Not a number');
}
if (numberValue > 2000000000) {
throw new Error('Number too big');
}
setFieldValue(numberValue.toString());
if (currentRowEntityId && updateField) {
updateField(currentRowEntityId, viewField, numberValue);
}
} catch (error) {
console.warn(
`In GenericEditableMoneyCellEditMode, Invalid number: ${newText}, ${error}`,
);
}
}
return (
<TextCellEdit autoFocus value={fieldValue ?? ''} onSubmit={handleSubmit} />
);
}

View File

@ -1,5 +1,7 @@
import { useContext } from 'react';
import { isViewFieldBoolean } from '@/ui/editable-field/types/guards/isViewFieldBoolean';
import { isViewFieldBooleanValue } from '@/ui/editable-field/types/guards/isViewFieldBooleanValue';
import { isViewFieldChip } from '@/ui/editable-field/types/guards/isViewFieldChip';
import { isViewFieldDate } from '@/ui/editable-field/types/guards/isViewFieldDate';
import { isViewFieldDateValue } from '@/ui/editable-field/types/guards/isViewFieldDateValue';
@ -7,6 +9,8 @@ import { isViewFieldDoubleText } from '@/ui/editable-field/types/guards/isViewFi
import { isViewFieldDoubleTextChip } from '@/ui/editable-field/types/guards/isViewFieldDoubleTextChip';
import { isViewFieldDoubleTextChipValue } from '@/ui/editable-field/types/guards/isViewFieldDoubleTextChipValue';
import { isViewFieldDoubleTextValue } from '@/ui/editable-field/types/guards/isViewFieldDoubleTextValue';
import { isViewFieldMoney } from '@/ui/editable-field/types/guards/isViewFieldMoney';
import { isViewFieldMoneyValue } from '@/ui/editable-field/types/guards/isViewFieldMoneyValue';
import { isViewFieldNumber } from '@/ui/editable-field/types/guards/isViewFieldNumber';
import { isViewFieldNumberValue } from '@/ui/editable-field/types/guards/isViewFieldNumberValue';
import { isViewFieldPhone } from '@/ui/editable-field/types/guards/isViewFieldPhone';
@ -202,6 +206,32 @@ export function useUpdateEntityField() {
) {
const newContent = newFieldValueUnknown;
updateEntity({
variables: {
where: { id: currentEntityId },
data: { [viewField.metadata.fieldName]: newContent },
},
});
// Boolean
} else if (
isViewFieldBoolean(viewField) &&
isViewFieldBooleanValue(newFieldValueUnknown)
) {
const newContent = newFieldValueUnknown;
updateEntity({
variables: {
where: { id: currentEntityId },
data: { [viewField.metadata.fieldName]: newContent },
},
});
// Money
} else if (
isViewFieldMoney(viewField) &&
isViewFieldMoneyValue(newFieldValueUnknown)
) {
const newContent = newFieldValueUnknown;
updateEntity({
variables: {
where: { id: currentEntityId },

View File

@ -11,6 +11,9 @@ type MockedCompany = Pick<
| 'address'
| 'employees'
| 'linkedinUrl'
| 'xUrl'
| 'annualRecurringRevenue'
| 'idealCustomerProfile'
| '_activityCount'
> & {
accountOwner: Pick<
@ -34,6 +37,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
address: '17 rue de clignancourt',
employees: 12,
linkedinUrl: 'https://www.linkedin.com/company/airbnb/',
xUrl: 'https://twitter.com/airbnb',
annualRecurringRevenue: 500000,
idealCustomerProfile: true,
_activityCount: 1,
accountOwner: {
email: 'charles@test.com',
@ -54,6 +60,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
address: '',
employees: 1,
linkedinUrl: 'https://www.linkedin.com/company/aircall/',
xUrl: 'https://twitter.com/aircall',
annualRecurringRevenue: 50000,
idealCustomerProfile: false,
_activityCount: 1,
accountOwner: null,
__typename: 'Company',
@ -66,6 +75,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
address: '',
employees: 1,
linkedinUrl: 'https://www.linkedin.com/company/algolia/',
xUrl: 'https://twitter.com/algolia',
annualRecurringRevenue: 500000,
idealCustomerProfile: true,
_activityCount: 1,
accountOwner: null,
__typename: 'Company',
@ -78,6 +90,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
address: '',
employees: 10,
linkedinUrl: 'https://www.linkedin.com/company/apple/',
xUrl: 'https://twitter.com/apple',
annualRecurringRevenue: 5000000,
idealCustomerProfile: false,
_activityCount: 0,
accountOwner: null,
__typename: 'Company',
@ -90,6 +105,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
address: '10 rue de la Paix',
employees: 1,
linkedinUrl: 'https://www.linkedin.com/company/qonto/',
xUrl: 'https://twitter.com/qonto',
annualRecurringRevenue: 500000,
idealCustomerProfile: false,
_activityCount: 2,
accountOwner: null,
__typename: 'Company',
@ -102,6 +120,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
address: '',
employees: 1,
linkedinUrl: 'https://www.linkedin.com/company/facebook/',
xUrl: 'https://twitter.com/facebook',
annualRecurringRevenue: 5000000,
idealCustomerProfile: true,
_activityCount: 13,
accountOwner: null,
__typename: 'Company',
@ -114,6 +135,9 @@ export const mockedCompaniesData: Array<MockedCompany> = [
address: '',
employees: 1,
linkedinUrl: 'https://www.linkedin.com/company/sequoia/',
xUrl: 'https://twitter.com/sequoia',
annualRecurringRevenue: 500000,
idealCustomerProfile: true,
_activityCount: 1,
accountOwner: null,
__typename: 'Company',

View File

@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "companies" ADD COLUMN "annualRecurringRevenue" INTEGER,
ADD COLUMN "idealCustomerProfile" BOOLEAN DEFAULT false,
ADD COLUMN "xUrl" TEXT;

View File

@ -226,6 +226,15 @@ model Company {
/// @Validator.IsString()
/// @Validator.IsOptional()
linkedinUrl String?
/// @Validator.IsNumber()
/// @Validator.IsOptional()
annualRecurringRevenue Int?
/// @Validator.IsBoolean()
/// @Validator.IsOptional()
idealCustomerProfile Boolean @default(false)
/// @Validator.IsString()
/// @Validator.IsOptional()
xUrl String?
/// @Validator.IsString()
/// @Validator.IsOptional()
address String