Moving queries into dedicated files (#1210)
* Moving queries into dedicated files * fix ci
This commit is contained in:
16
front/src/modules/companies/hooks/useCompanyQuery.ts
Normal file
16
front/src/modules/companies/hooks/useCompanyQuery.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
|
||||
import { genericEntitiesFamilyState } from '@/ui/editable-field/states/genericEntitiesFamilyState';
|
||||
import { useGetCompanyQuery } from '~/generated/graphql';
|
||||
|
||||
export function useCompanyQuery(id: string) {
|
||||
const updateCompanyShowPage = useSetRecoilState(
|
||||
genericEntitiesFamilyState(id),
|
||||
);
|
||||
return useGetCompanyQuery({
|
||||
variables: { where: { id } },
|
||||
onCompleted: (data) => {
|
||||
updateCompanyShowPage(data?.findUniqueCompany);
|
||||
},
|
||||
});
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||
|
||||
import { GET_PIPELINES } from '@/pipeline/queries';
|
||||
import { GET_PIPELINES } from '@/pipeline/graphql/queries/getPipelines';
|
||||
import { useResetTableRowSelection } from '@/ui/table/hooks/useResetTableRowSelection';
|
||||
import { selectedRowIdsSelector } from '@/ui/table/states/selectors/selectedRowIdsSelector';
|
||||
import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
|
||||
import { ActivityTargetableEntityForSelect } from '@/activities/types/ActivityTargetableEntityForSelect';
|
||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||
import { useSearchCompanyQuery } from '~/generated/graphql';
|
||||
import { getLogoUrlFromDomainName } from '~/utils';
|
||||
|
||||
export function useFilteredSearchCompanyQuery({
|
||||
searchFilter,
|
||||
selectedIds = [],
|
||||
limit,
|
||||
}: {
|
||||
searchFilter: string;
|
||||
selectedIds?: string[];
|
||||
limit?: number;
|
||||
}) {
|
||||
return useFilteredSearchEntityQuery({
|
||||
queryHook: useSearchCompanyQuery,
|
||||
searchOnFields: ['name'],
|
||||
orderByField: 'name',
|
||||
selectedIds: selectedIds,
|
||||
mappingFunction: (company) =>
|
||||
({
|
||||
id: company.id,
|
||||
entityType: ActivityTargetableEntityType.Company,
|
||||
name: company.name,
|
||||
avatarUrl: getLogoUrlFromDomainName(company.domainName),
|
||||
avatarType: 'squared',
|
||||
} as ActivityTargetableEntityForSelect),
|
||||
searchFilter,
|
||||
limit,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user