Fix kanban view picker total count (#10898)
Fixes https://github.com/twentyhq/twenty/issues/9790 Before https://github.com/user-attachments/assets/332ec338-ce87-4d4d-ac47-a4e76dceb5b0 After https://github.com/user-attachments/assets/93a03842-386a-4e75-a709-85a91bbc7679 --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
import { useContextStoreObjectMetadataItemOrThrow } from '@/context-store/hooks/useContextStoreObjectMetadataItemOrThrow';
|
||||
import { useAggregateRecords } from '@/object-record/hooks/useAggregateRecords';
|
||||
import { currentRecordFilterGroupsComponentState } from '@/object-record/record-filter-group/states/currentRecordFilterGroupsComponentState';
|
||||
import { useFilterValueDependencies } from '@/object-record/record-filter/hooks/useFilterValueDependencies';
|
||||
import { currentRecordFiltersComponentState } from '@/object-record/record-filter/states/currentRecordFiltersComponentState';
|
||||
import { computeRecordGqlOperationFilter } from '@/object-record/record-filter/utils/computeViewRecordGqlOperationFilter';
|
||||
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
|
||||
export const useGetRecordIndexTotalCount = () => {
|
||||
const { objectMetadataItem } = useContextStoreObjectMetadataItemOrThrow();
|
||||
|
||||
const currentRecordFilterGroups = useRecoilComponentValueV2(
|
||||
currentRecordFilterGroupsComponentState,
|
||||
);
|
||||
|
||||
const currentRecordFilters = useRecoilComponentValueV2(
|
||||
currentRecordFiltersComponentState,
|
||||
);
|
||||
|
||||
const { filterValueDependencies } = useFilterValueDependencies();
|
||||
|
||||
const filter = computeRecordGqlOperationFilter({
|
||||
filterValueDependencies,
|
||||
recordFilters: currentRecordFilters,
|
||||
recordFilterGroups: currentRecordFilterGroups,
|
||||
fields: objectMetadataItem.fields,
|
||||
});
|
||||
|
||||
const { data, loading } = useAggregateRecords<{
|
||||
id: { COUNT: number };
|
||||
}>({
|
||||
objectNameSingular: objectMetadataItem.nameSingular,
|
||||
filter,
|
||||
recordGqlFieldsAggregate: {
|
||||
id: [AGGREGATE_OPERATIONS.count],
|
||||
},
|
||||
});
|
||||
|
||||
const totalCount = data?.id?.COUNT;
|
||||
|
||||
return {
|
||||
totalCount,
|
||||
loading,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user