import type { SessionTopLocationsReport } from "@/features/analytics/session-analytics-contract";
import { RevenueRanking } from "./revenue-ranking";

export function TopLocationsPanel({
  bestData,
  bestError,
  worstData,
  worstError,
  startDate,
  endDate,
  today,
}: {
  bestData: SessionTopLocationsReport | null;
  bestError: string | null;
  worstData: SessionTopLocationsReport | null;
  worstError: string | null;
  startDate: string;
  endDate: string;
  today: string;
}) {
  return (
    <div className="grid grid-cols-1 gap-5 lg:grid-cols-2">
      <RevenueRanking
        title="Top 10 Best Performing Locations"
        items={bestData?.locations ?? null}
        error={bestError}
        entityName="Location"
        entity="location"
        sortOrder="desc"
        startDate={startDate}
        endDate={endDate}
        today={today}
      />
      <RevenueRanking
        title="Top 10 Worst Performing Locations"
        items={worstData?.locations ?? null}
        error={worstError}
        chartColors={["var(--destructive)"]}
        entityName="Location"
        entity="location"
        sortOrder="asc"
        startDate={startDate}
        endDate={endDate}
        today={today}
      />
    </div>
  );
}
