Files
twenty/front/src/services/companies/select.ts
Sammy Teillet b8cd842633 Sammy/t 194 aau when i set sort back and forth the (#103)
* bugfix: use original row id in cells to make sure it rerenders

* feature: implement multiple sorts

* bugfix: recreate new array to make sure component rerenders

* feature: orderBy is an array to keep orders

* test: snapshot the searchTemplate methods

* feature: remove the console log and return undefined

* feature: use orderByTemplate instead of hardcoded orderBy

* refactor: move sort and where filters helpers out of service

* refactor: rename file helper

* refactor: move assert function in test
2023-05-05 16:22:47 +02:00

39 lines
992 B
TypeScript

import { QueryResult, gql, useQuery } from '@apollo/client';
import { Order_By, Companies_Order_By } from '../../generated/graphql';
import { GraphqlQueryCompany } from '../../interfaces/company.interface';
import { SelectedSortType } from '../../components/table/table-header/interface';
export type CompaniesSelectedSortType = SelectedSortType<Companies_Order_By>;
export const GET_COMPANIES = gql`
query GetCompanies($orderBy: [companies_order_by!]) {
companies(order_by: $orderBy) {
id
domain_name
name
created_at
address
employees
account_owner {
id
email
displayName
}
}
}
`;
export function useCompaniesQuery(
orderBy: Companies_Order_By[],
): QueryResult<{ companies: GraphqlQueryCompany[] }> {
return useQuery<{ companies: GraphqlQueryCompany[] }>(GET_COMPANIES, {
variables: { orderBy },
});
}
export const defaultOrderBy: Companies_Order_By[] = [
{
name: Order_By.Asc,
},
];