import { RulebookTabs, type RulebookSection } from '@/components/leagues/RulebookTabs';
import { PointsTable } from '@/components/races/PointsTable';
import type { LeagueRulebookViewData } from '@/lib/view-data/LeagueRulebookViewData';
import { Box } from '@/ui/Box';
import { Grid } from '@/ui/Grid';
import { Heading } from '@/ui/Heading';
import { Icon } from '@/ui/Icon';
import { Stack } from '@/ui/Stack';
import { Surface } from '@/ui/Surface';
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/ui/Table';
import { Text } from '@/ui/Text';
import { AlertTriangle, Book, Clock, Info, Scale, Shield, type LucideIcon } from 'lucide-react';
interface LeagueRulebookTemplateProps {
viewData: LeagueRulebookViewData;
activeSection: RulebookSection;
onSectionChange: (section: RulebookSection) => void;
loading?: boolean;
}
export function LeagueRulebookTemplate({
viewData,
activeSection,
onSectionChange,
loading = false,
}: LeagueRulebookTemplateProps) {
if (loading) {
return (
Loading rulebook...
);
}
if (!viewData || !viewData.scoringConfig) {
return (
Unable to load rulebook
);
}
const { scoringConfig } = viewData;
const primaryChampionship = scoringConfig.championships.find((c: any) => c.type === 'driver') ?? scoringConfig.championships[0];
const positionPoints = primaryChampionship?.pointsPreview || [];
return (
{/* Navigation Tabs */}
{/* Content Sections */}
{activeSection === 'scoring' && (
{/* Quick Stats */}
{/* Weekend Structure */}
WEEKEND STRUCTURE
{/* Points Table */}
{/* Bonus Points */}
{primaryChampionship?.bonusSummary && primaryChampionship.bonusSummary.length > 0 && (
BONUS POINTS
{primaryChampionship.bonusSummary.map((bonus, idx) => (
+
{bonus}
))}
)}
)}
{activeSection === 'conduct' && (
DRIVER CONDUCT
)}
{activeSection === 'protests' && (
PROTEST PROCESS
)}
{activeSection === 'penalties' && (
PENALTY GUIDELINES
Infraction
Typical Penalty
)}
);
}
function StatItem({ icon, label, value, color }: { icon: LucideIcon, label: string, value: string | number, color: string }) {
return (
{label.toUpperCase()}
{value}
);
}
function TimingItem({ label, value }: { label: string, value: string }) {
return (
{label}
{value}
);
}
function ConductItem({ number, title, text }: { number: number, title: string, text: string }) {
return (
{number}. {title}
{text}
);
}
function PenaltyRow({ infraction, penalty, isSevere }: { infraction: string, penalty: string, isSevere?: boolean }) {
return (
{infraction}
{penalty}
);
}