* feature: add rightEndContent to editable cell * refactor: use rightEndContent instead of comments sections * refactor: move commentCount in a var * feature: get commentsCount from backend * refactor: use an index * feature: use commentCount from backend on people * refactor: rename commentCount for companies * refactor: use generated queries, instead of useQuery
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { gql } from '@apollo/client';
|
|
|
|
import {
|
|
useGetCompanyCountsQuery,
|
|
useGetPeopleCountsQuery,
|
|
} from '../../../generated/graphql';
|
|
|
|
export const GET_COMPANY_COMMENT_COUNT = gql`
|
|
query GetCompanyCounts($where: CompanyWhereInput) {
|
|
companies: findManyCompany(where: $where) {
|
|
commentsCount: _commentCount
|
|
}
|
|
}
|
|
`;
|
|
|
|
export const useCompanyCommentsCountQuery = (companyId: string) => {
|
|
const { data, ...rest } = useGetCompanyCountsQuery({
|
|
variables: { where: { id: { equals: companyId } } },
|
|
});
|
|
return { ...rest, data: data?.companies[0].commentsCount };
|
|
};
|
|
|
|
export const GET_PEOPLE_COMMENT_COUNT = gql`
|
|
query GetPeopleCounts($where: PersonWhereInput) {
|
|
people: findManyPerson(where: $where) {
|
|
commentsCount: _commentCount
|
|
}
|
|
}
|
|
`;
|
|
|
|
export const usePeopleCommentsCountQuery = (personId: string) => {
|
|
const { data, ...rest } = useGetPeopleCountsQuery({
|
|
variables: { where: { id: { equals: personId } } },
|
|
});
|
|
return { ...rest, data: data?.people[0].commentsCount };
|
|
};
|