diff --git a/packages/web/components/Landing/WhoAreWe.tsx b/packages/web/components/Landing/WhoAreWe.tsx index 54273e509..0b7dd7b88 100644 --- a/packages/web/components/Landing/WhoAreWe.tsx +++ b/packages/web/components/Landing/WhoAreWe.tsx @@ -81,6 +81,7 @@ export const WhoAreWe: React.FC< const { players } = usePlayerFilter(); const topPlayers = useMemo(() => players.slice(0, 7), [players]); + const topPatrons = useMemo(() => patrons.slice(0, 7), [patrons]); return ( 01Players (Builders) {topPlayers && ( - + )} 02Patrons (Funders) - {patrons && } + {topPatrons && } 03Elders (Advisors) - {patrons && } + {players && } 04MetaAlliance (Member projects) - {guilds && } + {guilds && } diff --git a/packages/web/pages/community/index.tsx b/packages/web/pages/community/index.tsx index 3757e2c28..cf39ae950 100644 --- a/packages/web/pages/community/index.tsx +++ b/packages/web/pages/community/index.tsx @@ -1,8 +1,5 @@ import { Box, - Button, - Flex, - HStack, MetaHeading, Tab, TabList, @@ -19,16 +16,19 @@ import GuildsPage from 'pages/guilds'; import PatronsPage from 'pages/patrons'; import Players from 'pages/players'; import React, { useEffect, useState } from 'react'; +import { useRouter } from 'next/router'; type Props = InferGetStaticPropsType; export const getStaticProps = async () => { const patronsLimit = 150; const patrons = await getPatrons(patronsLimit); + const pSeedPrice = await getPSeedPrice().catch((error) => { console.error('Error fetching pSeed price', error); return null; }); + return { props: { guilds: await getGuilds(), @@ -43,64 +43,84 @@ const UnifiedCommunityPage: React.FC = ({ guilds, patrons, pSeedPrice, -}) => ( - - - Community - - - - - Players - - - Guilds - - - Patrons - - {/* Elders */} - - - - - - - - - - - - {/* - Elders - */} - - - - - -); +}) => { + + const router = useRouter(); + const [activeTab, setActiveTab] = useState<{ link: string, index: number }>({ link: 'Players', index: 0 }); + + const communityTabs = [ + { link: 'Players', component: }, + { link: 'Guilds', component: }, + { link: 'Patrons', component: } + ] + + useEffect(() => { + const { query } = router; + if (query.tab) { + const index = communityTabs.findIndex(tab => tab.link === query.tab); + setActiveTab({ link: query.tab as string, index }); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [router.query]); + + const handleTabChange = (index: number) => { + const tab = communityTabs[index]; + setActiveTab({ link: tab.link, index }); + router.push(`/community/?tab=${tab.link}`, undefined, { shallow: true }); + }; + + return ( + + + Community + + + + <> + { + communityTabs.map(({ link }) => { + return( + + {link} + + ) + }) + } + + + + + { + communityTabs.map(({ link, component }) => { + return ( + + {component} + + ) + }) + } + + + + + + + ) + +}; + export default UnifiedCommunityPage;