import Card from '@/components/ui/Card';
import type { DashboardFeedItemSummaryViewModel } from '@/lib/view-models/DashboardOverviewViewModel';
import FeedList from '@/components/feed/FeedList';
import UpcomingRacesSidebar from '@/components/races/UpcomingRacesSidebar';
import LatestResultsSidebar from '@/components/races/LatestResultsSidebar';

type FeedUpcomingRace = {
  id: string;
  track: string;
  car: string;
  scheduledAt: string | Date;
};

type FeedLatestResult = {
  raceId: string;
  track: string;
  car: string;
  winnerName: string;
  scheduledAt: string | Date;
};

interface FeedLayoutProps {
  feedItems: DashboardFeedItemSummaryViewModel[];
  upcomingRaces: FeedUpcomingRace[];
  latestResults: FeedLatestResult[];
}

export default function FeedLayout({
  feedItems,
  upcomingRaces,
  latestResults
}: FeedLayoutProps) {
  return (
    <section className="max-w-7xl mx-auto mt-16 mb-20">
      <div className="flex flex-col gap-8 lg:grid lg:grid-cols-3">
        <div className="lg:col-span-2 space-y-4">
          <div className="flex items-baseline justify-between gap-4">
            <div>
              <h2 className="text-2xl font-semibold text-white">Activity</h2>
              <p className="text-sm text-gray-400">
                See what your friends and leagues are doing right now.
              </p>
            </div>
          </div>
          <Card className="bg-iron-gray/80">
            <FeedList items={feedItems} />
          </Card>
        </div>
        <aside className="space-y-6">
          <UpcomingRacesSidebar races={upcomingRaces} />
          <LatestResultsSidebar results={latestResults} />
        </aside>
      </div>
    </section>
  );
}
