'use client';
import React from 'react';
import { Breadcrumbs } from '@/ui/Breadcrumbs';
import { SlotTemplates } from '@/components/sponsors/SlotTemplates';
import { SponsorInsightsCard } from '@/components/sponsors/SponsorInsightsCard';
import { useSponsorMode } from '@/hooks/sponsor/useSponsorMode';
import { Box } from '@/ui/Box';
import { Button } from '@/ui/Button';
import { Card } from '@/ui/Card';
import { Container } from '@/ui/Container';
import { Grid } from '@/ui/Grid';
import { GridItem } from '@/ui/GridItem';
import { Heading } from '@/ui/Heading';
import { Stack } from '@/ui/Stack';
import { Text } from '@/ui/Text';
import { HorizontalStatItem } from '@/ui/HorizontalStatItem';
import { TeamAdmin } from '@/components/teams/TeamAdmin';
import { TeamHero } from '@/ui/TeamHero';
import { TeamRoster } from '@/components/teams/TeamRoster';
import { TeamStandings } from '@/components/teams/TeamStandings';
import type { TeamDetailViewData } from '@/lib/view-data/TeamDetailViewData';
type Tab = 'overview' | 'roster' | 'standings' | 'admin';
export interface TeamDetailTemplateProps {
viewData: TeamDetailViewData;
activeTab: Tab;
loading: boolean;
// Event handlers
onTabChange: (tab: Tab) => void;
onUpdate: () => void;
onRemoveMember: (driverId: string) => void;
onChangeRole: (driverId: string, newRole: 'owner' | 'admin' | 'member') => void;
onGoBack: () => void;
}
export function TeamDetailTemplate({
viewData,
activeTab,
loading,
onTabChange,
onUpdate,
onRemoveMember,
onChangeRole,
onGoBack,
}: TeamDetailTemplateProps) {
const isSponsorMode = useSponsorMode();
const team = viewData.team;
// Show loading state
if (loading) {
return (
Loading team...
);
}
// Show not found state
if (!team) {
return (
Team Not Found
The team you're looking for doesn't exist or has been disbanded.
);
}
return (
{/* Breadcrumb */}
{/* Sponsor Insights Card */}
{isSponsorMode && team && (
window.location.href = href}
/>
)}
({ id }))
}}
memberCount={viewData.memberships.length}
onUpdate={onUpdate}
/>
{/* Tabs */}
{viewData.tabs.map((tab) => (
tab.visible && (
onTabChange(tab.id)}
pb={3}
cursor="pointer"
borderBottom={activeTab === tab.id ? '2px solid' : '2px solid'}
borderColor={activeTab === tab.id ? 'border-primary-blue' : 'border-transparent'}
color={activeTab === tab.id ? 'text-primary-blue' : 'text-gray-400'}
>
{tab.label}
)
))}
{activeTab === 'overview' && (
About
{team.description}
Quick Stats
{team.category && (
)}
{team.leagues && team.leagues.length > 0 && (
)}
{team.createdAt && (
)}
Recent Activity
No recent activity to display
)}
{activeTab === 'roster' && (
)}
{activeTab === 'standings' && (
)}
{activeTab === 'admin' && viewData.isAdmin && (
)}
);
}