diff --git a/frontend/src/components/partners/partners.js b/frontend/src/components/partners/partners.js index 3557a5e7d0..2a01708188 100644 --- a/frontend/src/components/partners/partners.js +++ b/frontend/src/components/partners/partners.js @@ -95,7 +95,7 @@ export function PartnersCard({ details }) { - + { const [partnerStats, setPartnerStats] = useState(null); const [error, loading, partner] = useFetch(`partners/${id}/`); - // navigate to /leaderboard path when no tab param present - useEffect(() => { - if (!tabname) { - navigate('leaderboard'); - } - }, [navigate, tabname]); - const fetchData = async (name) => { try { let hashtag = name.trim(); @@ -73,12 +66,10 @@ export const PartnersStats = () => { function getTabContent() { switch (tabname) { - case 'leaderboard': - return ; case 'mapswipe': return ; default: - return <>; + return ; } } @@ -91,6 +82,8 @@ export const PartnersStats = () => { ? tabData.filter((tab) => tab.id !== 'mapswipe') : tabData; + const activeTab = tabname === 'mapswipe' ? 'mapswipe' : 'leaderboard'; + return ( { role="button" tabIndex={0} className={`flex items-center pointer partners-tab-item ${ - tabname === tabId ? 'bg-tan blue-dark' : 'bg-grey-dark white' + activeTab === tabId ? 'bg-tan blue-dark' : 'bg-grey-dark white' }`} - onClick={() => navigate(`/partners/${id}/stats/${tabId}`)} + onClick={() => + tabId === 'leaderboard' + ? navigate(`/partners/${id}/stats`) + : navigate(`/partners/${id}/stats/${tabId}`) + } onKeyDown={() => {}} >

{title}