Sammy/t 363 comments count at row level depends on total comments number (#192)

* 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
This commit is contained in:
Sammy Teillet
2023-06-05 14:41:27 +02:00
committed by GitHub
parent d3684b34c5
commit 6de90024ef
8 changed files with 162 additions and 22 deletions

View File

@ -0,0 +1 @@
export * from './select';

View File

@ -0,0 +1,36 @@
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 };
};