Reorganize context/states/selectors in dedicated folders (#1205)

* Reorganize context/states/selectors in dedicated folders

* linter
This commit is contained in:
Weiko
2023-08-14 15:08:47 -07:00
committed by GitHub
parent cd3a32e555
commit 7d900ad1c6
134 changed files with 251 additions and 320 deletions
@@ -1,6 +1,6 @@
import { useState } from 'react';
import { FieldContext } from '@/ui/editable-field/states/FieldContext';
import { FieldRecoilScopeContext } from '@/ui/editable-field/states/recoil-scope-contexts/FieldRecoilScopeContext';
import { DoubleTextInputEdit } from '@/ui/input/double-text/components/DoubleTextInputEdit';
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
import { Person, useUpdateOnePersonMutation } from '~/generated/graphql';
@@ -46,7 +46,7 @@ export function PeopleFullNameEditableField({ people }: OwnProps) {
}
return (
<RecoilScope SpecificContext={FieldContext}>
<RecoilScope SpecificContext={FieldRecoilScopeContext}>
<DoubleTextInputEdit
firstValuePlaceholder={'First name'} // Hack: Fake character to prevent password-manager from filling the field
secondValuePlaceholder={'Last name'} // Hack: Fake character to prevent password-manager from filling the field
@@ -5,7 +5,7 @@ import { availableFiltersScopedState } from '@/ui/filter-n-sort/states/available
import { useResetTableRowSelection } from '@/ui/table/hooks/useResetTableRowSelection';
import { isFetchingEntityTableDataState } from '@/ui/table/states/isFetchingEntityTableDataState';
import { numberOfTableRowsState } from '@/ui/table/states/numberOfTableRowsState';
import { TableContext } from '@/ui/table/states/TableContext';
import { TableRecoilScopeContext } from '@/ui/table/states/recoil-scope-contexts/TableRecoilScopeContext';
import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
import { currentPageLocationState } from '@/ui/utilities/loading-state/states/currentPageLocationState';
import { useContextScopeId } from '@/ui/utilities/recoil-scope/hooks/useContextScopeId';
@@ -24,7 +24,7 @@ import { peoplePhoneFamilyState } from '../states/peoplePhoneFamilyState';
export function useSetPeopleEntityTable() {
const resetTableRowSelection = useResetTableRowSelection();
const tableContextScopeId = useContextScopeId(TableContext);
const tableContextScopeId = useContextScopeId(TableRecoilScopeContext);
const currentLocation = useLocation().pathname;
@@ -1,11 +0,0 @@
import { atomFamily } from 'recoil';
import { GetPeopleQuery } from '~/generated/graphql';
export const peopleEntityTableFamilyState = atomFamily<
GetPeopleQuery['people'][0] | null,
string
>({
key: 'peopleEntityTableFamilyState',
default: null,
});
@@ -9,7 +9,7 @@ import { IconList } from '@/ui/icon';
import { EntityTable } from '@/ui/table/components/EntityTable';
import { GenericEntityTableData } from '@/ui/table/components/GenericEntityTableData';
import { useUpsertEntityTableItem } from '@/ui/table/hooks/useUpsertEntityTableItem';
import { TableContext } from '@/ui/table/states/TableContext';
import { TableRecoilScopeContext } from '@/ui/table/states/recoil-scope-contexts/TableRecoilScopeContext';
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
import { useTableViewFields } from '@/views/hooks/useTableViewFields';
import { useViewSorts } from '@/views/hooks/useViewSorts';
@@ -26,7 +26,10 @@ import { defaultOrderBy } from '../../queries';
export function PeopleTable() {
const currentViewId = useRecoilValue(currentViewIdState);
const orderBy = useRecoilScopedValue(sortsOrderByScopedState, TableContext);
const orderBy = useRecoilScopedValue(
sortsOrderByScopedState,
TableRecoilScopeContext,
);
const [updateEntityMutation] = useUpdateOnePersonMutation();
const upsertEntityTableItem = useUpsertEntityTableItem();
@@ -36,10 +39,13 @@ export function PeopleTable() {
});
const { updateSorts } = useViewSorts({
availableSorts,
Context: TableContext,
Context: TableRecoilScopeContext,
});
const filters = useRecoilScopedValue(filtersScopedState, TableContext);
const filters = useRecoilScopedValue(
filtersScopedState,
TableRecoilScopeContext,
);
const whereFilters = useMemo(() => {
return { AND: filters.map(turnFilterIntoWhereClause) };
@@ -5,7 +5,7 @@ import { GET_PEOPLE } from '@/people/queries';
import { IconTrash } from '@/ui/icon/index';
import { EntityTableActionBarButton } from '@/ui/table/action-bar/components/EntityTableActionBarButton';
import { useResetTableRowSelection } from '@/ui/table/hooks/useResetTableRowSelection';
import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector';
import { selectedRowIdsSelector } from '@/ui/table/states/selectors/selectedRowIdsSelector';
import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
import { useDeleteManyPersonMutation } from '~/generated/graphql';