Skip to content

Commit

Permalink
Merge pull request #2597 from cozy/fix/analysis-tab-routes-in-1-51-0
Browse files Browse the repository at this point in the history
Backport "Use absolute links for analysis tabs"
  • Loading branch information
PolariTOON authored Jan 17, 2023
2 parents c0186ae + 0a7803c commit 9958f90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
7 changes: 1 addition & 6 deletions src/ducks/analysis/AnalysisTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import { Tab, Tabs } from 'cozy-ui/transpiled/react/MuiTabs'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import Header from 'components/Header'

export const tabRoutes = {
categories: 'analysis/categories',
recurrence: 'analysis/recurrence'
}

export const activeTab = location =>
location.pathname.includes('categories') ? 'categories' : 'recurrence'
export const tabNames = ['categories', 'recurrence']
Expand All @@ -26,7 +21,7 @@ const AnalysisTabs = () => {
label={t(`Nav.${tabName}`)}
key={tabName}
name={tabName}
onClick={() => navigate(tabRoutes[tabName])}
onClick={() => navigate(`/analysis/${tabName}`)}
/>
))}
</Tabs>
Expand Down
6 changes: 2 additions & 4 deletions src/ducks/settings/TabsHeader/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from 'react'
import React from 'react'
import { useLocation, useNavigate } from 'react-router-dom'

import { useI18n } from 'cozy-ui/transpiled/react/I18n'
Expand All @@ -21,8 +21,6 @@ const TabsHeader = () => {

if (tabNames.indexOf(defaultTab) === -1) defaultTab = 'configuration'

const goTo = useCallback(url => () => navigate(url), [navigate])

return (
<>
<Padded className={isMobile ? 'u-p-0' : 'u-pb-half'}>
Expand All @@ -36,7 +34,7 @@ const TabsHeader = () => {
classes={{ root: i === 0 && !isMobile ? 'u-ml-2' : 0 }}
key={tabName}
name={tabName}
onClick={goTo(`/settings/${tabName}`)}
onClick={() => navigate(`/settings/${tabName}`)}
label={t(`Settings.${tabName}`)}
/>
))}
Expand Down

0 comments on commit 9958f90

Please sign in to comment.