fix count with opportunities page (#1839)
* fix count with opportunities page * make unscoped atom entityCountInCurrentViewState
This commit is contained in:
@ -11,6 +11,7 @@ import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilSco
|
|||||||
import { availableFiltersScopedState } from '@/ui/view-bar/states/availableFiltersScopedState';
|
import { availableFiltersScopedState } from '@/ui/view-bar/states/availableFiltersScopedState';
|
||||||
import { availableSortsScopedState } from '@/ui/view-bar/states/availableSortsScopedState';
|
import { availableSortsScopedState } from '@/ui/view-bar/states/availableSortsScopedState';
|
||||||
import { currentViewIdScopedState } from '@/ui/view-bar/states/currentViewIdScopedState';
|
import { currentViewIdScopedState } from '@/ui/view-bar/states/currentViewIdScopedState';
|
||||||
|
import { entityCountInCurrentViewState } from '@/ui/view-bar/states/entityCountInCurrentViewState';
|
||||||
import { filtersScopedState } from '@/ui/view-bar/states/filtersScopedState';
|
import { filtersScopedState } from '@/ui/view-bar/states/filtersScopedState';
|
||||||
import { savedFiltersFamilyState } from '@/ui/view-bar/states/savedFiltersFamilyState';
|
import { savedFiltersFamilyState } from '@/ui/view-bar/states/savedFiltersFamilyState';
|
||||||
import { savedSortsFamilyState } from '@/ui/view-bar/states/savedSortsFamilyState';
|
import { savedSortsFamilyState } from '@/ui/view-bar/states/savedSortsFamilyState';
|
||||||
@ -41,6 +42,10 @@ export const HooksCompanyBoardEffect = () => {
|
|||||||
CompanyBoardRecoilScopeContext,
|
CompanyBoardRecoilScopeContext,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [, setEntityCountInCurrentView] = useRecoilState(
|
||||||
|
entityCountInCurrentViewState,
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setAvailableFilters(opportunitiesBoardOptions.filters);
|
setAvailableFilters(opportunitiesBoardOptions.filters);
|
||||||
setAvailableSorts(opportunitiesBoardOptions.sorts);
|
setAvailableSorts(opportunitiesBoardOptions.sorts);
|
||||||
@ -158,6 +163,7 @@ export const HooksCompanyBoardEffect = () => {
|
|||||||
setActionBarEntries();
|
setActionBarEntries();
|
||||||
setContextMenuEntries();
|
setContextMenuEntries();
|
||||||
updateCompanyBoard(pipeline, pipelineProgresses, companiesData.companies);
|
updateCompanyBoard(pipeline, pipelineProgresses, companiesData.companies);
|
||||||
|
setEntityCountInCurrentView(companiesData.companies.length);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
loading,
|
loading,
|
||||||
@ -169,6 +175,7 @@ export const HooksCompanyBoardEffect = () => {
|
|||||||
setContextMenuEntries,
|
setContextMenuEntries,
|
||||||
searchParams,
|
searchParams,
|
||||||
handleViewSelect,
|
handleViewSelect,
|
||||||
|
setEntityCountInCurrentView,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return <></>;
|
return <></>;
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
|
|||||||
import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
||||||
import { availableFiltersScopedState } from '@/ui/view-bar/states/availableFiltersScopedState';
|
import { availableFiltersScopedState } from '@/ui/view-bar/states/availableFiltersScopedState';
|
||||||
import { availableSortsScopedState } from '@/ui/view-bar/states/availableSortsScopedState';
|
import { availableSortsScopedState } from '@/ui/view-bar/states/availableSortsScopedState';
|
||||||
|
import { entityCountInCurrentViewState } from '@/ui/view-bar/states/entityCountInCurrentViewState';
|
||||||
import { FilterDefinition } from '@/ui/view-bar/types/FilterDefinition';
|
import { FilterDefinition } from '@/ui/view-bar/types/FilterDefinition';
|
||||||
import { SortDefinition } from '@/ui/view-bar/types/SortDefinition';
|
import { SortDefinition } from '@/ui/view-bar/types/SortDefinition';
|
||||||
|
|
||||||
@ -49,10 +50,13 @@ export const useSetEntityTableData = () => {
|
|||||||
|
|
||||||
set(numberOfTableRowsState, entityIds.length);
|
set(numberOfTableRowsState, entityIds.length);
|
||||||
|
|
||||||
|
set(entityCountInCurrentViewState, entityIds.length);
|
||||||
|
|
||||||
set(
|
set(
|
||||||
availableFiltersScopedState(tableContextScopeId),
|
availableFiltersScopedState(tableContextScopeId),
|
||||||
filterDefinitionArray,
|
filterDefinitionArray,
|
||||||
);
|
);
|
||||||
|
|
||||||
set(
|
set(
|
||||||
availableSortsScopedState(tableContextScopeId),
|
availableSortsScopedState(tableContextScopeId),
|
||||||
sortDefinitionArray,
|
sortDefinitionArray,
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
import { MouseEvent, useContext } from 'react';
|
import { MouseEvent, useContext } from 'react';
|
||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { useRecoilCallback, useSetRecoilState } from 'recoil';
|
import {
|
||||||
|
RecoilValueReadOnly,
|
||||||
|
useRecoilCallback,
|
||||||
|
useRecoilValue,
|
||||||
|
useSetRecoilState,
|
||||||
|
} from 'recoil';
|
||||||
|
|
||||||
import { DropdownButton } from '@/ui/dropdown/components/DropdownButton';
|
import { DropdownButton } from '@/ui/dropdown/components/DropdownButton';
|
||||||
import { StyledDropdownButtonContainer } from '@/ui/dropdown/components/StyledDropdownButtonContainer';
|
import { StyledDropdownButtonContainer } from '@/ui/dropdown/components/StyledDropdownButtonContainer';
|
||||||
@ -23,6 +28,7 @@ import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoi
|
|||||||
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
|
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
|
||||||
import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
||||||
import { currentViewIdScopedState } from '@/ui/view-bar/states/currentViewIdScopedState';
|
import { currentViewIdScopedState } from '@/ui/view-bar/states/currentViewIdScopedState';
|
||||||
|
import { entityCountInCurrentViewState } from '@/ui/view-bar/states/entityCountInCurrentViewState';
|
||||||
import { filtersScopedState } from '@/ui/view-bar/states/filtersScopedState';
|
import { filtersScopedState } from '@/ui/view-bar/states/filtersScopedState';
|
||||||
import { savedFiltersFamilyState } from '@/ui/view-bar/states/savedFiltersFamilyState';
|
import { savedFiltersFamilyState } from '@/ui/view-bar/states/savedFiltersFamilyState';
|
||||||
import { savedSortsFamilyState } from '@/ui/view-bar/states/savedSortsFamilyState';
|
import { savedSortsFamilyState } from '@/ui/view-bar/states/savedSortsFamilyState';
|
||||||
@ -89,11 +95,16 @@ export const ViewsDropdownButton = ({
|
|||||||
currentViewScopedSelector,
|
currentViewScopedSelector,
|
||||||
ViewBarRecoilScopeContext,
|
ViewBarRecoilScopeContext,
|
||||||
);
|
);
|
||||||
|
|
||||||
const [views] = useRecoilScopedState(
|
const [views] = useRecoilScopedState(
|
||||||
viewsScopedState,
|
viewsScopedState,
|
||||||
ViewBarRecoilScopeContext,
|
ViewBarRecoilScopeContext,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const entityCount = useRecoilValue(
|
||||||
|
entityCountInCurrentViewState as RecoilValueReadOnly<number>,
|
||||||
|
);
|
||||||
|
|
||||||
const { isDropdownButtonOpen, closeDropdownButton, toggleDropdownButton } =
|
const { isDropdownButtonOpen, closeDropdownButton, toggleDropdownButton } =
|
||||||
useDropdownButton({
|
useDropdownButton({
|
||||||
dropdownId: ViewsDropdownId,
|
dropdownId: ViewsDropdownId,
|
||||||
@ -167,7 +178,7 @@ export const ViewsDropdownButton = ({
|
|||||||
{currentView?.name || defaultViewName}
|
{currentView?.name || defaultViewName}
|
||||||
</StyledViewName>
|
</StyledViewName>
|
||||||
<StyledDropdownLabelAdornments>
|
<StyledDropdownLabelAdornments>
|
||||||
· {views.length} <IconChevronDown size={theme.icon.size.sm} />
|
· {entityCount} <IconChevronDown size={theme.icon.size.sm} />
|
||||||
</StyledDropdownLabelAdornments>
|
</StyledDropdownLabelAdornments>
|
||||||
</StyledDropdownButtonContainer>
|
</StyledDropdownButtonContainer>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
import { atom } from 'recoil';
|
||||||
|
|
||||||
|
export const entityCountInCurrentViewState = atom<number>({
|
||||||
|
key: 'entityCountInCurrentViewState',
|
||||||
|
default: 0,
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user