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',
|
||||
|
||||
@ -19,7 +19,7 @@ const mocks = [
|
||||
request: {
|
||||
query: GET_PEOPLE,
|
||||
variables: {
|
||||
orderBy: [{ created_at: 'desc' }],
|
||||
orderBy: [{ createdAt: 'desc' }],
|
||||
where: {},
|
||||
},
|
||||
},
|
||||
@ -33,7 +33,7 @@ const mocks = [
|
||||
request: {
|
||||
query: GET_PEOPLE,
|
||||
variables: {
|
||||
orderBy: [{ created_at: 'desc' }],
|
||||
orderBy: [{ createdAt: 'desc' }],
|
||||
where: {},
|
||||
},
|
||||
},
|
||||
|
||||
@ -3,7 +3,8 @@
|
||||
exports[`PeopleFilter should render the filter city which is text search 1`] = `
|
||||
Object {
|
||||
"city": Object {
|
||||
"_ilike": "%Paris%",
|
||||
"contains": "%Paris%",
|
||||
"mode": "insensitive",
|
||||
},
|
||||
}
|
||||
`;
|
||||
@ -11,8 +12,10 @@ Object {
|
||||
exports[`PeopleFilter should render the filter company_name which relation search 1`] = `
|
||||
Object {
|
||||
"company": Object {
|
||||
"name": Object {
|
||||
"_eq": "test-name",
|
||||
"is": Object {
|
||||
"name": Object {
|
||||
"equals": "test-name",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ import {
|
||||
TbPhone,
|
||||
TbUser,
|
||||
} from 'react-icons/tb';
|
||||
import { QueryMode } from '../../generated/graphql';
|
||||
|
||||
const columnHelper = createColumnHelper<Person>();
|
||||
|
||||
@ -118,7 +119,10 @@ export const usePeopleColumns = () => {
|
||||
{
|
||||
query: SEARCH_COMPANY_QUERY,
|
||||
template: (searchInput: string) => ({
|
||||
name: { _ilike: `%${searchInput}%` },
|
||||
name: {
|
||||
contains: `%${searchInput}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
}),
|
||||
resultMapper: (company) => ({
|
||||
render: (company) => company.name,
|
||||
|
||||
@ -13,6 +13,7 @@ import {
|
||||
TbPhone,
|
||||
TbUser,
|
||||
} from 'react-icons/tb';
|
||||
import { QueryMode } from '../../generated/graphql';
|
||||
|
||||
export const fullnameFilter = {
|
||||
key: 'fullname',
|
||||
@ -24,9 +25,19 @@ export const fullnameFilter = {
|
||||
label: 'Contains',
|
||||
id: 'like',
|
||||
whereTemplate: (searchString) => ({
|
||||
_or: [
|
||||
{ firstname: { _ilike: `%${searchString}%` } },
|
||||
{ lastname: { _ilike: `%${searchString}%` } },
|
||||
OR: [
|
||||
{
|
||||
firstname: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
{
|
||||
lastname: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
@ -34,12 +45,24 @@ export const fullnameFilter = {
|
||||
label: 'Does not contain',
|
||||
id: 'not_like',
|
||||
whereTemplate: (searchString) => ({
|
||||
_not: {
|
||||
_and: [
|
||||
{ firstname: { _ilike: `%${searchString}%` } },
|
||||
{ lastname: { _ilike: `%${searchString}%` } },
|
||||
],
|
||||
},
|
||||
NOT: [
|
||||
{
|
||||
AND: [
|
||||
{
|
||||
firstname: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
{
|
||||
lastname: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
@ -55,14 +78,21 @@ export const emailFilter = {
|
||||
label: 'Contains',
|
||||
id: 'like',
|
||||
whereTemplate: (searchString) => ({
|
||||
email: { _ilike: `%${searchString}%` },
|
||||
email: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Does not contain',
|
||||
id: 'not_like',
|
||||
whereTemplate: (searchString) => ({
|
||||
_not: { email: { _ilike: `%${searchString}%` } },
|
||||
NOT: [
|
||||
{
|
||||
email: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
@ -76,7 +106,7 @@ export const companyFilter = {
|
||||
searchConfig: {
|
||||
query: SEARCH_COMPANY_QUERY,
|
||||
template: (searchString: string) => ({
|
||||
name: { _ilike: `%${searchString}%` },
|
||||
name: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
|
||||
}),
|
||||
resultMapper: (data) => ({
|
||||
value: mapToCompany(data),
|
||||
@ -89,14 +119,14 @@ export const companyFilter = {
|
||||
label: 'Is',
|
||||
id: 'is',
|
||||
whereTemplate: (company) => ({
|
||||
company: { name: { _eq: company.name } },
|
||||
company: { is: { name: { equals: company.name } } },
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Is not',
|
||||
id: 'is_not',
|
||||
whereTemplate: (company) => ({
|
||||
_not: { company: { name: { _eq: company.name } } },
|
||||
NOT: [{ company: { is: { name: { equals: company.name } } } }],
|
||||
}),
|
||||
},
|
||||
],
|
||||
@ -112,14 +142,21 @@ export const phoneFilter = {
|
||||
label: 'Contains',
|
||||
id: 'like',
|
||||
whereTemplate: (searchString) => ({
|
||||
phone: { _ilike: `%${searchString}%` },
|
||||
phone: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Does not contain',
|
||||
id: 'not_like',
|
||||
whereTemplate: (searchString) => ({
|
||||
_not: { phone: { _ilike: `%${searchString}%` } },
|
||||
NOT: [
|
||||
{
|
||||
phone: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
@ -135,8 +172,8 @@ export const creationDateFilter = {
|
||||
label: 'Greater than',
|
||||
id: 'greater_than',
|
||||
whereTemplate: (searchString) => ({
|
||||
created_at: {
|
||||
_gte: searchString,
|
||||
createdAt: {
|
||||
gte: searchString,
|
||||
},
|
||||
}),
|
||||
},
|
||||
@ -144,8 +181,8 @@ export const creationDateFilter = {
|
||||
label: 'Less than',
|
||||
id: 'less_than',
|
||||
whereTemplate: (searchString) => ({
|
||||
created_at: {
|
||||
_lte: searchString,
|
||||
createdAt: {
|
||||
lte: searchString,
|
||||
},
|
||||
}),
|
||||
},
|
||||
@ -162,14 +199,21 @@ export const cityFilter = {
|
||||
label: 'Contains',
|
||||
id: 'like',
|
||||
whereTemplate: (searchString) => ({
|
||||
city: { _ilike: `%${searchString}%` },
|
||||
city: { contains: `%${searchString}%`, mode: QueryMode.Insensitive },
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Does not contain',
|
||||
id: 'not_like',
|
||||
whereTemplate: (searchString) => ({
|
||||
_not: { city: { _ilike: `%${searchString}%` } },
|
||||
NOT: [
|
||||
{
|
||||
city: {
|
||||
contains: `%${searchString}%`,
|
||||
mode: QueryMode.Insensitive,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { Order_By, People_Order_By } from '../../generated/graphql';
|
||||
import {
|
||||
SortOrder as Order_By,
|
||||
PersonOrderByWithRelationInput as People_Order_By,
|
||||
} from '../../generated/graphql';
|
||||
import { SortType } from '../../interfaces/sorts/interface';
|
||||
import {
|
||||
TbBuilding,
|
||||
@ -40,7 +43,7 @@ export const availableSorts = [
|
||||
_type: 'default_sort',
|
||||
},
|
||||
{
|
||||
key: 'created_at',
|
||||
key: 'createdAt',
|
||||
label: 'Created at',
|
||||
icon: <TbCalendar size={16} />,
|
||||
_type: 'default_sort',
|
||||
|
||||
Reference in New Issue
Block a user