'use client';

import React from 'react';
import { useRouter } from 'next/navigation';
import { LeaderboardsTemplate } from '@/templates/LeaderboardsTemplate';
import type { LeaderboardsViewData } from '@/lib/view-data/LeaderboardsViewData';
import { routes } from '@/lib/routing/RouteConfig';

interface LeaderboardsPageClientProps {
  viewData: LeaderboardsViewData;
}

export function LeaderboardsPageClient({ viewData }: LeaderboardsPageClientProps) {
  const router = useRouter();

  const handleDriverClick = (driverId: string) => {
    router.push(routes.driver.detail(driverId));
  };

  const handleTeamClick = (teamId: string) => {
    router.push(routes.team.detail(teamId));
  };

  const handleNavigateToDrivers = () => {
    router.push(routes.leaderboards.drivers);
  };

  const handleNavigateToTeams = () => {
    router.push(routes.team.leaderboard);
  };

  return (
    <LeaderboardsTemplate
      viewData={viewData}
      onDriverClick={handleDriverClick}
      onTeamClick={handleTeamClick}
      onNavigateToDrivers={handleNavigateToDrivers}
      onNavigateToTeams={handleNavigateToTeams}
    />
  );
}
