Reorganize frontend and install Craco to alias modules (#190)
This commit is contained in:
48
front/src/modules/companies/services/select.ts
Normal file
48
front/src/modules/companies/services/select.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { gql, QueryResult, useQuery } from '@apollo/client';
|
||||
|
||||
import { SelectedSortType } from '@/filters-and-sorts/interfaces/sorts/interface';
|
||||
import {
|
||||
CompanyOrderByWithRelationInput as Companies_Order_By,
|
||||
CompanyWhereInput as Companies_Bool_Exp,
|
||||
SortOrder as Order_By,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
import { GraphqlQueryCompany } from '../interfaces/company.interface';
|
||||
|
||||
export type CompaniesSelectedSortType = SelectedSortType<Companies_Order_By>;
|
||||
|
||||
export const GET_COMPANIES = gql`
|
||||
query GetCompanies(
|
||||
$orderBy: [CompanyOrderByWithRelationInput!]
|
||||
$where: CompanyWhereInput
|
||||
) {
|
||||
companies: findManyCompany(orderBy: $orderBy, where: $where) {
|
||||
id
|
||||
domainName
|
||||
name
|
||||
createdAt
|
||||
address
|
||||
employees
|
||||
accountOwner {
|
||||
id
|
||||
email
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export function useCompaniesQuery(
|
||||
orderBy: Companies_Order_By[],
|
||||
where: Companies_Bool_Exp,
|
||||
): QueryResult<{ companies: GraphqlQueryCompany[] }> {
|
||||
return useQuery<{ companies: GraphqlQueryCompany[] }>(GET_COMPANIES, {
|
||||
variables: { orderBy, where },
|
||||
});
|
||||
}
|
||||
|
||||
export const defaultOrderBy: Companies_Order_By[] = [
|
||||
{
|
||||
createdAt: Order_By.Desc,
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user