'use client';
import Breadcrumbs from '@/components/layout/Breadcrumbs';
import LeagueHeader from '@/components/leagues/LeagueHeader';
import { useEffectiveDriverId } from '@/hooks/useEffectiveDriverId';
import { useLeagueDetail } from '@/hooks/league/useLeagueDetail';
import { useParams, usePathname, useRouter } from 'next/navigation';
import React from 'react';
export default function LeagueLayout({
children,
}: {
children: React.ReactNode;
}) {
const params = useParams();
const pathname = usePathname();
const router = useRouter();
const leagueId = params.id as string;
const currentDriverId = useEffectiveDriverId();
const { data: leagueDetail, isLoading: loading } = useLeagueDetail(leagueId, currentDriverId ?? '');
if (loading) {
return (
);
}
if (!leagueDetail) {
return (
);
}
// Define tab configuration
const baseTabs = [
{ label: 'Overview', href: `/leagues/${leagueId}`, exact: true },
{ label: 'Schedule', href: `/leagues/${leagueId}/schedule`, exact: false },
{ label: 'Standings', href: `/leagues/${leagueId}/standings`, exact: false },
{ label: 'Rulebook', href: `/leagues/${leagueId}/rulebook`, exact: false },
];
const adminTabs = [
{ label: 'Schedule Admin', href: `/leagues/${leagueId}/schedule/admin`, exact: false },
{ label: 'Sponsorships', href: `/leagues/${leagueId}/sponsorships`, exact: false },
{ label: 'Stewarding', href: `/leagues/${leagueId}/stewarding`, exact: false },
{ label: 'Wallet', href: `/leagues/${leagueId}/wallet`, exact: false },
{ label: 'Settings', href: `/leagues/${leagueId}/settings`, exact: false },
];
const tabs = leagueDetail.isAdmin ? [...baseTabs, ...adminTabs] : baseTabs;
return (
{/* Tab Navigation */}
{tabs.map((tab) => (
))}
{children}
);
}