Skip to content

Commit

Permalink
Renamed boolean variable and extract repeated code into a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Made1ra committed Nov 25, 2024
1 parent ffb4ffe commit 02b1455
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 02b1455

Please sign in to comment.