Skip to content

Commit

Permalink
fix: tab navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianeboe committed Apr 13, 2022
1 parent 557dbd4 commit 67157b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_ARWEAVE_CDN_HOST=/api/arweave/txt
NEXT_PUBLIC_MARKETPLACE_ENABLED=true
FEATURED_STOREFRONTS_URL="https://bafkreigvmqgo5l6zvoc6gscqhrm6a2qboio2jbgpkewv6pwylgbf4v52ai.ipfs.nftstorage.link/"
NEXT_PUBLIC_INDEXER_GRAPHQL_URL="https://graph-test.holaplex.com/v1"
# NEXT_PUBLIC_INDEXER_GRAPHQL_URL="https://graph-test.holaplex.com/v1"
27 changes: 8 additions & 19 deletions src/common/components/elements/ProfileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,25 @@ import { Tab } from '@headlessui/react';
import { useProfileData } from '@/common/context/ProfileData';

enum TabRoute {
OWNED,
COLLECTED,
CREATED,
ACTIVITY,
}

export const ProfileMenu: FC = () => {
const { publicKey } = useProfileData();
const router = useRouter();
const path = router.asPath;
const pathName = router.pathname;
const routeIndex = TabRoute.OWNED;
const [selectedIndex, setSelectedIndex] = useState(routeIndex);

useEffect(() => {
switch (pathName) {
case `/profiles/[publicKey]/created`:
setSelectedIndex(TabRoute.CREATED);
break;
case `/profiles/[publicKey]/activity`:
setSelectedIndex(TabRoute.ACTIVITY);
break;
default:
setSelectedIndex(TabRoute.OWNED);
break;
}
}, [pathName, path]);
const defaultTabIndex =
router.pathname === '/profiles/[publicKey]/activity'
? TabRoute.ACTIVITY
: `/profiles/[publicKey]/created`
? TabRoute.CREATED
: TabRoute.COLLECTED;

return (
<div className="mb-6 border-b-2 border-gray-800">
<Tab.Group selectedIndex={selectedIndex} onChange={setSelectedIndex}>
<Tab.Group defaultIndex={defaultTabIndex}>
<Tab.List className="-mb-px flex h-14 w-full justify-between sm:w-auto sm:justify-start ">
<Tab as={Fragment}>
{({ selected }) => (
Expand Down

0 comments on commit 67157b5

Please sign in to comment.