Files
twenty/front/src/modules/companies/queries/show.ts
Weiko 4eb4d1488c Use FieldDefinition for company show page (#1171)
* Use FieldDefinition for company show page

* removing console.log

* fix conflicts

* fix address placeholder + company show page field definition ordering

* fix story

* add replacePlaceholder

* use AppPath enum in stories

* add routeParams

* fix people input story
2023-08-11 14:31:52 -07:00

48 lines
1013 B
TypeScript

import { gql } from '@apollo/client';
import { useSetRecoilState } from 'recoil';
import { genericEntitiesFamilyState } from '@/ui/editable-field/states/genericEntitiesFamilyState';
import { useGetCompanyQuery } from '~/generated/graphql';
export const GET_COMPANY = gql`
query GetCompany($where: CompanyWhereUniqueInput!) {
findUniqueCompany(where: $where) {
id
domainName
name
createdAt
address
linkedinUrl
employees
_activityCount
accountOwner {
id
email
displayName
avatarUrl
}
Favorite {
id
person {
id
}
company {
id
}
}
}
}
`;
export function useCompanyQuery(id: string) {
const updateCompanyShowPage = useSetRecoilState(
genericEntitiesFamilyState(id),
);
return useGetCompanyQuery({
variables: { where: { id } },
onCompleted: (data) => {
updateCompanyShowPage(data?.findUniqueCompany);
},
});
}