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 { availableSortsScopedState } from '@/ui/view-bar/states/availableSortsScopedState';
|
||||
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 { savedFiltersFamilyState } from '@/ui/view-bar/states/savedFiltersFamilyState';
|
||||
import { savedSortsFamilyState } from '@/ui/view-bar/states/savedSortsFamilyState';
|
||||
@ -41,6 +42,10 @@ export const HooksCompanyBoardEffect = () => {
|
||||
CompanyBoardRecoilScopeContext,
|
||||
);
|
||||
|
||||
const [, setEntityCountInCurrentView] = useRecoilState(
|
||||
entityCountInCurrentViewState,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setAvailableFilters(opportunitiesBoardOptions.filters);
|
||||
setAvailableSorts(opportunitiesBoardOptions.sorts);
|
||||
@ -158,6 +163,7 @@ export const HooksCompanyBoardEffect = () => {
|
||||
setActionBarEntries();
|
||||
setContextMenuEntries();
|
||||
updateCompanyBoard(pipeline, pipelineProgresses, companiesData.companies);
|
||||
setEntityCountInCurrentView(companiesData.companies.length);
|
||||
}
|
||||
}, [
|
||||
loading,
|
||||
@ -169,6 +175,7 @@ export const HooksCompanyBoardEffect = () => {
|
||||
setContextMenuEntries,
|
||||
searchParams,
|
||||
handleViewSelect,
|
||||
setEntityCountInCurrentView,
|
||||
]);
|
||||
|
||||
return <></>;
|
||||
|
||||
@ -7,6 +7,7 @@ import { tableRowIdsState } from '@/ui/table/states/tableRowIdsState';
|
||||
import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
||||
import { availableFiltersScopedState } from '@/ui/view-bar/states/availableFiltersScopedState';
|
||||
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 { SortDefinition } from '@/ui/view-bar/types/SortDefinition';
|
||||
|
||||
@ -49,10 +50,13 @@ export const useSetEntityTableData = () => {
|
||||
|
||||
set(numberOfTableRowsState, entityIds.length);
|
||||
|
||||
set(entityCountInCurrentViewState, entityIds.length);
|
||||
|
||||
set(
|
||||
availableFiltersScopedState(tableContextScopeId),
|
||||
filterDefinitionArray,
|
||||
);
|
||||
|
||||
set(
|
||||
availableSortsScopedState(tableContextScopeId),
|
||||
sortDefinitionArray,
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
import { MouseEvent, useContext } from 'react';
|
||||
import { useTheme } from '@emotion/react';
|
||||
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 { 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 { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
||||
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 { savedFiltersFamilyState } from '@/ui/view-bar/states/savedFiltersFamilyState';
|
||||
import { savedSortsFamilyState } from '@/ui/view-bar/states/savedSortsFamilyState';
|
||||
@ -89,11 +95,16 @@ export const ViewsDropdownButton = ({
|
||||
currentViewScopedSelector,
|
||||
ViewBarRecoilScopeContext,
|
||||
);
|
||||
|
||||
const [views] = useRecoilScopedState(
|
||||
viewsScopedState,
|
||||
ViewBarRecoilScopeContext,
|
||||
);
|
||||
|
||||
const entityCount = useRecoilValue(
|
||||
entityCountInCurrentViewState as RecoilValueReadOnly<number>,
|
||||
);
|
||||
|
||||
const { isDropdownButtonOpen, closeDropdownButton, toggleDropdownButton } =
|
||||
useDropdownButton({
|
||||
dropdownId: ViewsDropdownId,
|
||||
@ -167,7 +178,7 @@ export const ViewsDropdownButton = ({
|
||||
{currentView?.name || defaultViewName}
|
||||
</StyledViewName>
|
||||
<StyledDropdownLabelAdornments>
|
||||
· {views.length} <IconChevronDown size={theme.icon.size.sm} />
|
||||
· {entityCount} <IconChevronDown size={theme.icon.size.sm} />
|
||||
</StyledDropdownLabelAdornments>
|
||||
</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