Move code to a lib, remove table dependancy (#606)
* Move code to a lib, remove table dependancy * Abstract yable context from filters * Update missing hook * Remove wording of active filter, simplify naming for edited filters * lint
This commit is contained in:
@ -6,9 +6,9 @@ import {
|
||||
defaultOrderBy,
|
||||
useCompaniesQuery,
|
||||
} from '@/companies/services';
|
||||
import { reduceSortsToOrderBy } from '@/filters-and-sorts/helpers';
|
||||
import { activeTableFiltersScopedState } from '@/filters-and-sorts/states/activeTableFiltersScopedState';
|
||||
import { turnFilterIntoWhereClause } from '@/filters-and-sorts/utils/turnFilterIntoWhereClause';
|
||||
import { reduceSortsToOrderBy } from '@/lib/filters-and-sorts/helpers';
|
||||
import { filtersScopedState } from '@/lib/filters-and-sorts/states/filtersScopedState';
|
||||
import { turnFilterIntoWhereClause } from '@/lib/filters-and-sorts/utils/turnFilterIntoWhereClause';
|
||||
import { useRecoilScopedValue } from '@/recoil-scope/hooks/useRecoilScopedValue';
|
||||
import { EntityTable } from '@/ui/components/table/EntityTable';
|
||||
import { HooksEntityTable } from '@/ui/components/table/HooksEntityTable';
|
||||
@ -27,10 +27,7 @@ export function CompanyTable() {
|
||||
setOrderBy(sorts.length ? reduceSortsToOrderBy(sorts) : defaultOrderBy);
|
||||
}, []);
|
||||
|
||||
const filters = useRecoilScopedValue(
|
||||
activeTableFiltersScopedState,
|
||||
TableContext,
|
||||
);
|
||||
const filters = useRecoilScopedValue(filtersScopedState, TableContext);
|
||||
|
||||
const whereFilters = useMemo(() => {
|
||||
if (!filters.length) return undefined;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { TableFilterDefinitionByEntity } from '@/filters-and-sorts/types/TableFilterDefinitionByEntity';
|
||||
import { FilterDefinitionByEntity } from '@/lib/filters-and-sorts/types/FilterDefinitionByEntity';
|
||||
import {
|
||||
IconBuildingSkyscraper,
|
||||
IconCalendarEvent,
|
||||
@ -11,7 +11,7 @@ import { icon } from '@/ui/themes/icon';
|
||||
import { FilterDropdownUserSearchSelect } from '@/users/components/FilterDropdownUserSearchSelect';
|
||||
import { Company } from '~/generated/graphql';
|
||||
|
||||
export const companiesFilters: TableFilterDefinitionByEntity<Company>[] = [
|
||||
export const companiesFilters: FilterDefinitionByEntity<Company>[] = [
|
||||
{
|
||||
field: 'name',
|
||||
label: 'Name',
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { SortType } from '@/filters-and-sorts/interfaces/sorts/interface';
|
||||
import { SortType } from '@/lib/filters-and-sorts/interfaces/sorts/interface';
|
||||
import {
|
||||
IconBuildingSkyscraper,
|
||||
IconCalendarEvent,
|
||||
|
||||
@ -2,9 +2,9 @@ import { useCallback, useMemo, useState } from 'react';
|
||||
import { IconList } from '@tabler/icons-react';
|
||||
|
||||
import { defaultOrderBy } from '@/companies/services';
|
||||
import { reduceSortsToOrderBy } from '@/filters-and-sorts/helpers';
|
||||
import { activeTableFiltersScopedState } from '@/filters-and-sorts/states/activeTableFiltersScopedState';
|
||||
import { turnFilterIntoWhereClause } from '@/filters-and-sorts/utils/turnFilterIntoWhereClause';
|
||||
import { reduceSortsToOrderBy } from '@/lib/filters-and-sorts/helpers';
|
||||
import { filtersScopedState } from '@/lib/filters-and-sorts/states/filtersScopedState';
|
||||
import { turnFilterIntoWhereClause } from '@/lib/filters-and-sorts/utils/turnFilterIntoWhereClause';
|
||||
import { PeopleSelectedSortType, usePeopleQuery } from '@/people/services';
|
||||
import { useRecoilScopedValue } from '@/recoil-scope/hooks/useRecoilScopedValue';
|
||||
import { EntityTable } from '@/ui/components/table/EntityTable';
|
||||
@ -24,10 +24,7 @@ export function PeopleTable() {
|
||||
setOrderBy(sorts.length ? reduceSortsToOrderBy(sorts) : defaultOrderBy);
|
||||
}, []);
|
||||
|
||||
const filters = useRecoilScopedValue(
|
||||
activeTableFiltersScopedState,
|
||||
TableContext,
|
||||
);
|
||||
const filters = useRecoilScopedValue(filtersScopedState, TableContext);
|
||||
|
||||
const whereFilters = useMemo(() => {
|
||||
return { AND: filters.map(turnFilterIntoWhereClause) };
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { FilterDropdownCompanySearchSelect } from '@/companies/components/FilterDropdownCompanySearchSelect';
|
||||
import { TableFilterDefinitionByEntity } from '@/filters-and-sorts/types/TableFilterDefinitionByEntity';
|
||||
import { FilterDefinitionByEntity } from '@/lib/filters-and-sorts/types/FilterDefinitionByEntity';
|
||||
import {
|
||||
IconBuildingSkyscraper,
|
||||
IconCalendarEvent,
|
||||
@ -11,7 +11,7 @@ import {
|
||||
import { icon } from '@/ui/themes/icon';
|
||||
import { Person } from '~/generated/graphql';
|
||||
|
||||
export const peopleFilters: TableFilterDefinitionByEntity<Person>[] = [
|
||||
export const peopleFilters: FilterDefinitionByEntity<Person>[] = [
|
||||
{
|
||||
field: 'firstName',
|
||||
label: 'First name',
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { SortType } from '@/filters-and-sorts/interfaces/sorts/interface';
|
||||
import { SortType } from '@/lib/filters-and-sorts/interfaces/sorts/interface';
|
||||
import {
|
||||
IconBuildingSkyscraper,
|
||||
IconCalendarEvent,
|
||||
|
||||
Reference in New Issue
Block a user