diff --git a/src/containers/my-cooperations/cooperation-details/CooperationDetails.tsx b/src/containers/my-cooperations/cooperation-details/CooperationDetails.tsx index 218eb6979..81d8c0892 100644 --- a/src/containers/my-cooperations/cooperation-details/CooperationDetails.tsx +++ b/src/containers/my-cooperations/cooperation-details/CooperationDetails.tsx @@ -57,19 +57,17 @@ const CooperationDetails = () => { const [searchParams, setSearchParams] = useSearchParams() - const hasTabInSearchParams = Object.values(CooperationTabsEnum).includes( - searchParams.get('tab') as CooperationTabsEnum - ) + const tab = searchParams.get('tab') as CooperationTabsEnum + + const isTabInSearchParams = Object.values(CooperationTabsEnum).includes(tab) - const activeTab = hasTabInSearchParams - ? (searchParams.get('tab') as CooperationTabsEnum) - : CooperationTabsEnum.Activities + const activeTab = isTabInSearchParams ? tab : CooperationTabsEnum.Activities useEffect(() => { - if (!hasTabInSearchParams) { + if (!isTabInSearchParams) { setSearchParams({ tab: CooperationTabsEnum.Activities }) } - }, [hasTabInSearchParams, setSearchParams]) + }, [isTabInSearchParams, setSearchParams]) const responseError = useCallback( () => navigate(errorRoutes.notFound.path),