Remove hasura and hasura-auth (#134)
* Remove hasura and hasura-auth * Move all models to prisma * Start implementing graphql * chore: clean package json * chore: make the code build * chore: get initial graphql.tsx file * feature: use typegql as qgl server * refactor: small refactoring * refactor: clean tests * bugfix: make all filters not case sensitive * chore: remove unused imports --------- Co-authored-by: Sammy Teillet <sammy.teillet@gmail.com>
This commit is contained in:
@ -20,7 +20,7 @@ import {
|
||||
reduceFiltersToWhere,
|
||||
reduceSortsToOrderBy,
|
||||
} from '../../components/table/table-header/helpers';
|
||||
import { Companies_Order_By } from '../../generated/graphql';
|
||||
import { CompanyOrderByWithRelationInput as Companies_Order_By } from '../../generated/graphql';
|
||||
import ActionBar from '../../components/table/action-bar/ActionBar';
|
||||
import { SelectedFilterType } from '../../interfaces/filters/interface';
|
||||
import { BoolExpType } from '../../interfaces/entities/generic.interface';
|
||||
|
||||
@ -5,6 +5,7 @@ import { lightTheme } from '../../../layout/styles/themes';
|
||||
import { GET_COMPANIES } from '../../../services/api/companies';
|
||||
import { mockCompaniesData } from '../__tests__/__data__/mock-data';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import { QueryMode } from '../../../generated/graphql';
|
||||
|
||||
const component = {
|
||||
title: 'Companies',
|
||||
@ -18,7 +19,7 @@ const mocks = [
|
||||
request: {
|
||||
query: GET_COMPANIES,
|
||||
variables: {
|
||||
orderBy: [{ created_at: 'desc' }],
|
||||
orderBy: [{ createdAt: 'desc' }],
|
||||
where: {},
|
||||
},
|
||||
},
|
||||
@ -32,7 +33,7 @@ const mocks = [
|
||||
request: {
|
||||
query: GET_COMPANIES,
|
||||
variables: {
|
||||
orderBy: [{ created_at: 'desc' }],
|
||||
orderBy: [{ createdAt: 'desc' }],
|
||||
where: {},
|
||||
},
|
||||
},
|
||||
@ -46,8 +47,10 @@ const mocks = [
|
||||
request: {
|
||||
query: GET_COMPANIES,
|
||||
variables: {
|
||||
orderBy: [{ created_at: 'desc' }],
|
||||
where: { domain_name: { _ilike: '%aircal%' } },
|
||||
orderBy: [{ createdAt: 'desc' }],
|
||||
where: {
|
||||
domainName: { contains: '%aircal%', mode: QueryMode.Insensitive },
|
||||
},
|
||||
},
|
||||
},
|
||||
result: {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
exports[`Companies Filter should render the filter company_employees 1`] = `
|
||||
Object {
|
||||
"employees": Object {
|
||||
"_gte": 2,
|
||||
"gte": 2,
|
||||
},
|
||||
}
|
||||
`;
|
||||
@ -11,7 +11,8 @@ Object {
|
||||
exports[`Companies Filter should render the filter company_name 1`] = `
|
||||
Object {
|
||||
"name": Object {
|
||||
"_ilike": "%name%",
|
||||
"contains": "%name%",
|
||||
"mode": "insensitive",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
@ -27,6 +27,7 @@ import {
|
||||
TbSum,
|
||||
TbUser,
|
||||
} from 'react-icons/tb';
|
||||
import { QueryMode } from '../../generated/graphql';
|
||||
|
||||
const columnHelper = createColumnHelper<Company>();
|
||||
|
||||
@ -178,7 +179,10 @@ export const useCompaniesColumns = () => {
|
||||
{
|
||||
query: SEARCH_USER_QUERY,
|
||||
template: (searchInput: string) => ({
|
||||
displayName: { _ilike: `%${searchInput}%` },
|
||||
displayName: {
|
||||
contains: `%${searchInput}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
}),
|
||||
resultMapper: (accountOwner) => ({
|
||||
render: (accountOwner) => accountOwner.displayName,
|
||||
|
||||
@ -10,6 +10,7 @@ import { Company } from '../../interfaces/entities/company.interface';
|
||||
import { FilterConfigType } from '../../interfaces/filters/interface';
|
||||
import { SEARCH_USER_QUERY } from '../../services/api/search/search';
|
||||
import { User, mapToUser } from '../../interfaces/entities/user.interface';
|
||||
import { QueryMode } from '../../generated/graphql';
|
||||
|
||||
export const nameFilter = {
|
||||
key: 'company_name',
|
||||
@ -21,14 +22,21 @@ export const nameFilter = {
|
||||
label: 'Contains',
|
||||
id: 'like',
|
||||
whereTemplate: (searchString) => ({
|
||||
name: { _ilike: `%${searchString}%` },
|
||||
name: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Does not contain',
|
||||
id: 'not_like',
|
||||
whereTemplate: (searchString) => ({
|
||||
_not: { name: { _ilike: `%${searchString}%` } },
|
||||
NOT: [
|
||||
{
|
||||
name: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
@ -45,7 +53,7 @@ export const employeesFilter = {
|
||||
id: 'greater_than',
|
||||
whereTemplate: (searchString) => ({
|
||||
employees: {
|
||||
_gte: isNaN(Number(searchString)) ? undefined : Number(searchString),
|
||||
gte: isNaN(Number(searchString)) ? undefined : Number(searchString),
|
||||
},
|
||||
}),
|
||||
},
|
||||
@ -54,7 +62,7 @@ export const employeesFilter = {
|
||||
id: 'less_than',
|
||||
whereTemplate: (searchString) => ({
|
||||
employees: {
|
||||
_lte: isNaN(Number(searchString)) ? undefined : Number(searchString),
|
||||
lte: isNaN(Number(searchString)) ? undefined : Number(searchString),
|
||||
},
|
||||
}),
|
||||
},
|
||||
@ -71,14 +79,24 @@ export const urlFilter = {
|
||||
label: 'Contains',
|
||||
id: 'like',
|
||||
whereTemplate: (searchString) => ({
|
||||
domain_name: { _ilike: `%${searchString}%` },
|
||||
domainName: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Does not contain',
|
||||
id: 'not_like',
|
||||
whereTemplate: (searchString) => ({
|
||||
_not: { domain_name: { _ilike: `%${searchString}%` } },
|
||||
NOT: [
|
||||
{
|
||||
domainName: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
@ -94,14 +112,21 @@ export const addressFilter = {
|
||||
label: 'Contains',
|
||||
id: 'like',
|
||||
whereTemplate: (searchString) => ({
|
||||
address: { _ilike: `%${searchString}%` },
|
||||
address: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Does not contain',
|
||||
id: 'not_like',
|
||||
whereTemplate: (searchString) => ({
|
||||
_not: { address: { _ilike: `%${searchString}%` } },
|
||||
NOT: [
|
||||
{
|
||||
address: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
@ -117,8 +142,8 @@ export const creationDateFilter = {
|
||||
label: 'Greater than',
|
||||
id: 'greater_than',
|
||||
whereTemplate: (searchString) => ({
|
||||
created_at: {
|
||||
_gte: searchString,
|
||||
createdAt: {
|
||||
gte: searchString,
|
||||
},
|
||||
}),
|
||||
},
|
||||
@ -126,8 +151,8 @@ export const creationDateFilter = {
|
||||
label: 'Less than',
|
||||
id: 'less_than',
|
||||
whereTemplate: (searchString) => ({
|
||||
created_at: {
|
||||
_lte: searchString,
|
||||
createdAt: {
|
||||
lte: searchString,
|
||||
},
|
||||
}),
|
||||
},
|
||||
@ -142,7 +167,10 @@ export const accountOwnerFilter = {
|
||||
searchConfig: {
|
||||
query: SEARCH_USER_QUERY,
|
||||
template: (searchString: string) => ({
|
||||
displayName: { _ilike: `%${searchString}%` },
|
||||
displayName: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
}),
|
||||
resultMapper: (data) => ({
|
||||
value: mapToUser(data),
|
||||
@ -155,14 +183,20 @@ export const accountOwnerFilter = {
|
||||
label: 'Is',
|
||||
id: 'is',
|
||||
whereTemplate: (owner) => ({
|
||||
account_owner: { displayName: { _eq: owner.displayName } },
|
||||
accountOwner: { is: { displayName: { equals: owner.displayName } } },
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Is not',
|
||||
id: 'is_not',
|
||||
whereTemplate: (owner) => ({
|
||||
_not: { account_owner: { displayName: { _eq: owner.displayName } } },
|
||||
NOT: [
|
||||
{
|
||||
accountOwner: {
|
||||
is: { displayName: { equals: owner.displayName } },
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
|
||||
@ -5,7 +5,7 @@ import {
|
||||
TbMapPin,
|
||||
TbSum,
|
||||
} from 'react-icons/tb';
|
||||
import { Companies_Order_By } from '../../generated/graphql';
|
||||
import { CompanyOrderByWithRelationInput as Companies_Order_By } from '../../generated/graphql';
|
||||
import { SortType } from '../../interfaces/sorts/interface';
|
||||
|
||||
export const availableSorts = [
|
||||
@ -22,7 +22,7 @@ export const availableSorts = [
|
||||
_type: 'default_sort',
|
||||
},
|
||||
{
|
||||
key: 'domain_name',
|
||||
key: 'domainName',
|
||||
label: 'Url',
|
||||
icon: <TbLink size={16} />,
|
||||
_type: 'default_sort',
|
||||
@ -34,7 +34,7 @@ export const availableSorts = [
|
||||
_type: 'default_sort',
|
||||
},
|
||||
{
|
||||
key: 'created_at',
|
||||
key: 'createdAt',
|
||||
label: 'Creation',
|
||||
icon: <TbCalendar size={16} />,
|
||||
_type: 'default_sort',
|
||||
|
||||
Reference in New Issue
Block a user