Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from 'lucide-react';
import { Button } from '@/components/ui/button';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import Image from 'next/image';
import {
Tooltip,
Expand Down Expand Up @@ -56,20 +57,30 @@ interface NavButtonProps {
href: string;
children: React.ReactNode;
hasCompletedSetup: boolean;
isActive: boolean;
}

const NavButton = ({ href, children, hasCompletedSetup }: NavButtonProps) => {
const NavButton = ({ href, children, hasCompletedSetup, isActive }: NavButtonProps) => {
if (!hasCompletedSetup && href !== '/dashboard/setup') {
return <DisabledButton>{children}</DisabledButton>;
}
return (
<Button variant="ghost" className="w-full justify-start" asChild>
<Button
variant="ghost"
className={cn(
'w-full justify-start relative transition-colors',
isActive &&
'bg-primary/15 text-primary hover:bg-primary/20 hover:text-primary before:absolute before:left-0 before:top-1/2 before:-translate-y-1/2 before:h-3/5 before:w-[3px] before:rounded-full before:bg-primary'
)}
asChild
>
<Link href={href}>{children}</Link>
</Button>
);
};

export function DashboardSidebar({ className = '' }: SidebarProps) {
const pathname = usePathname();
const { data: session } = authClient.useSession();
const userId = session?.user?.id;

Expand All @@ -80,6 +91,9 @@ export function DashboardSidebar({ className = '' }: SidebarProps) {

const hasCompletedSetup = Boolean(userProfile?.first_name && userProfile?.team);

const isActive = (href: string) =>
href === '/dashboard' ? pathname === '/dashboard' : pathname.startsWith(href);

return (
<div className={cn('pb-12 min-h-screen', className)}>
<div className="space-y-4 py-4">
Expand Down Expand Up @@ -114,45 +128,45 @@ export function DashboardSidebar({ className = '' }: SidebarProps) {
<div className="px-3">
<div className="space-y-1">
{!hasCompletedSetup && (
<NavButton href="/dashboard/setup" hasCompletedSetup={hasCompletedSetup}>
<NavButton href="/dashboard/setup" hasCompletedSetup={hasCompletedSetup} isActive={isActive('/dashboard/setup')}>
<div className="flex items-center gap-2">
<User className="h-4 w-4" />
Get Started (Required)
</div>
</NavButton>
)}

<NavButton href="/dashboard" hasCompletedSetup={hasCompletedSetup}>
<NavButton href="/dashboard" hasCompletedSetup={hasCompletedSetup} isActive={isActive('/dashboard')}>
<div className="flex items-center gap-2">
<Home className="h-4 w-4" />
Overview
</div>
</NavButton>
<NavButton href="/dashboard/matches" hasCompletedSetup={hasCompletedSetup}>
<NavButton href="/dashboard/matches" hasCompletedSetup={hasCompletedSetup} isActive={isActive('/dashboard/matches')}>
<div className="flex items-center gap-2">
<Calendar className="h-4 w-4" />
Matches
</div>
</NavButton>
<NavButton href="/dashboard/teams" hasCompletedSetup={hasCompletedSetup}>
<NavButton href="/dashboard/teams" hasCompletedSetup={hasCompletedSetup} isActive={isActive('/dashboard/teams')}>
<div className="flex items-center gap-2">
<Users className="h-4 w-4" />
All Teams
</div>
</NavButton>
<NavButton href="/dashboard/leaderboard" hasCompletedSetup={hasCompletedSetup}>
<NavButton href="/dashboard/leaderboard" hasCompletedSetup={hasCompletedSetup} isActive={isActive('/dashboard/leaderboard')}>
<div className="flex items-center gap-2">
<Trophy className="h-4 w-4" />
Leaderboard
</div>
</NavButton>
<NavButton href="/dashboard/tournaments" hasCompletedSetup={hasCompletedSetup}>
<NavButton href="/dashboard/tournaments" hasCompletedSetup={hasCompletedSetup} isActive={isActive('/dashboard/tournaments')}>
<div className="flex items-center gap-2">
<Swords className="h-4 w-4" />
Tournaments
</div>
</NavButton>
<NavButton href="/dashboard/practice" hasCompletedSetup={hasCompletedSetup}>
<NavButton href="/dashboard/practice" hasCompletedSetup={hasCompletedSetup} isActive={isActive('/dashboard/practice')}>
<div className="flex items-center gap-2">
<Gamepad2 className="h-4 w-4" />
Practice
Expand All @@ -161,13 +175,13 @@ export function DashboardSidebar({ className = '' }: SidebarProps) {

{hasCompletedSetup && (
<div className="pt-4 mt-4 border-t border-border space-y-1">
<NavButton href="/dashboard/profile" hasCompletedSetup={hasCompletedSetup}>
<NavButton href="/dashboard/profile" hasCompletedSetup={hasCompletedSetup} isActive={isActive('/dashboard/profile')}>
<div className="flex items-center gap-2">
<User className="h-4 w-4" />
My Profile
</div>
</NavButton>
<NavButton href="/dashboard/team" hasCompletedSetup={hasCompletedSetup}>
<NavButton href="/dashboard/team" hasCompletedSetup={hasCompletedSetup} isActive={isActive('/dashboard/team')}>
<div className="flex items-center gap-2">
<Shield className="h-4 w-4" />
My Team
Expand Down
Loading