Migrate view field to new data model - Part 2 (#2270)

* Migrate view field to new data model

* Migrate view fields to new model
This commit is contained in:
Charles Bochet
2023-10-28 19:13:48 +02:00
committed by GitHub
parent b591023eb3
commit 685d342170
168 changed files with 960 additions and 4568 deletions

View File

@ -3,13 +3,9 @@ import { useEffect } from 'react';
import { companiesAvailableFieldDefinitions } from '@/companies/constants/companiesAvailableFieldDefinitions';
import { availableTableColumnsScopedState } from '@/ui/data/data-table/states/availableTableColumnsScopedState';
import { TableRecoilScopeContext } from '@/ui/data/data-table/states/recoil-scope-contexts/TableRecoilScopeContext';
import { tableColumnsScopedState } from '@/ui/data/data-table/states/tableColumnsScopedState';
import { tableFiltersScopedState } from '@/ui/data/data-table/states/tableFiltersScopedState';
import { tableSortsScopedState } from '@/ui/data/data-table/states/tableSortsScopedState';
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
import { useView } from '@/views/hooks/useView';
import { useViewInternalStates } from '@/views/hooks/useViewInternalStates';
import { ViewType } from '~/generated/graphql';
import { ViewType } from '@/views/types/ViewType';
import { companyAvailableFilters } from '~/pages/companies/companies-filters';
import { companyAvailableSorts } from '~/pages/companies/companies-sorts';
@ -21,23 +17,6 @@ const CompanyTableEffect = () => {
setViewType,
setViewObjectId,
} = useView();
const { currentViewFields, currentViewSorts, currentViewFilters } =
useViewInternalStates();
const [, setTableColumns] = useRecoilScopedState(
tableColumnsScopedState,
TableRecoilScopeContext,
);
const [, setTableSorts] = useRecoilScopedState(
tableSortsScopedState,
TableRecoilScopeContext,
);
const [, setTableFilters] = useRecoilScopedState(
tableFiltersScopedState,
TableRecoilScopeContext,
);
const [, setAvailableTableColumns] = useRecoilScopedState(
availableTableColumnsScopedState,
@ -57,33 +36,32 @@ const CompanyTableEffect = () => {
setAvailableFilters,
setAvailableSorts,
setAvailableTableColumns,
setTableColumns,
setViewObjectId,
setViewType,
]);
useEffect(() => {
if (currentViewFields) {
setTableColumns([...currentViewFields].sort((a, b) => a.index - b.index));
}
}, [currentViewFields, setTableColumns]);
// useEffect(() => {
// if (currentViewFields) {
// setTableColumns([...currentViewFields].sort((a, b) => a.index - b.index));
// }
// }, [currentViewFields, setTableColumns]);
useEffect(() => {
if (currentViewSorts) {
setTableSorts(currentViewSorts);
}
}, [currentViewFields, currentViewSorts, setTableColumns, setTableSorts]);
// useEffect(() => {
// if (currentViewSorts) {
// setTableSorts(currentViewSorts);
// }
// }, [currentViewFields, currentViewSorts, setTableColumns, setTableSorts]);
useEffect(() => {
if (currentViewFilters) {
setTableFilters(currentViewFilters);
}
}, [
currentViewFields,
currentViewFilters,
setTableColumns,
setTableFilters,
setTableSorts,
]);
// useEffect(() => {
// if (currentViewFilters) {
// setTableFilters(currentViewFilters);
// }
// }, [
// currentViewFields,
// currentViewFilters,
// setTableColumns,
// setTableFilters,
// setTableSorts,
// ]);
return <></>;
};