Fix Views on People page (#2265)

* fetching viewId for url

* fixed option menu name input

* fix table import

* fix unnecessary rerenders

* people working

---------

Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
This commit is contained in:
Charles Bochet
2023-10-27 18:20:58 +02:00
committed by GitHub
parent 35237c05f3
commit afd4b7c634
14 changed files with 202 additions and 75 deletions

View File

@ -1,3 +1,5 @@
import { useEffect } from 'react';
import { useSearchParams } from 'react-router-dom';
import { useRecoilCallback } from 'recoil';
import { ColumnDefinition } from '@/ui/data/data-table/types/ColumnDefinition';
@ -35,9 +37,12 @@ export const ViewBarEffect = () => {
setSavedViewFilters,
currentViewId,
setViews,
changeView,
setCurrentViewId,
} = useView();
const [searchParams] = useSearchParams();
const { viewType, viewObjectId } = useViewInternalStates(viewScopeId);
useGetViewFieldsQuery({
@ -112,7 +117,7 @@ export const ViewBarEffect = () => {
if (!nextViews.length) return;
if (!currentViewId) return setCurrentViewId(nextViews[0].id);
if (!currentViewId) return changeView(nextViews[0].id);
}),
});
@ -214,5 +219,12 @@ export const ViewBarEffect = () => {
}),
});
const currentViewIdFromUrl = searchParams.get('view');
useEffect(() => {
if (!currentViewIdFromUrl) return;
setCurrentViewId(currentViewIdFromUrl);
}, [currentViewIdFromUrl, setCurrentViewId]);
return <></>;
};