import SummaryTable from "@/app/components/portfolio/summary/SummaryTable";
import {
  getNonDefaultPortfolioScenarios,
  getOverviewPortfolioData,
} from "../../utils";

export default async function PortfolioSummary(
  props: {
    params: Promise<{ slug: string }>;
  }
) {
  const params = await props.params;
  const portfolioId = params.slug;
  const data = await getOverviewPortfolioData(portfolioId);

  // Retrieve all of the names and ids of the portfolios, attributed to this user
  // Get user id from the session
  const scenarios = await getNonDefaultPortfolioScenarios(portfolioId);

  return (
    <div className="container mx-auto px-4">
      <h1 className="text-3xl text-gray-700 font-bold my-4">Summary</h1>
      <SummaryTable data={data} scenarios={scenarios} />
      <div className="text-sm text-gray-600 mb-5">
        * Valuation improvement is based on these studies from
        <a
          className="ml-1 underline"
          href="https://www.rightmove.co.uk/news/articles/property-news/average-uk-energy-bills-how-to-save-money/#:~:text=A%20'green%20premium'%20that%20could,Rightmove%20Greener%20Homes%20Report%202023)."
          target="_blank"
          rel="noopener noreferrer"
        >
          Rightmove
        </a>
        ,
        <a
          className="ml-1 underline"
          href="https://www.knightfrank.com/research/article/2022-10-11-improving-your-epc-rating-could-increase-your-homes-value-by-up-to-20"
          target="_blank"
          rel="noopener noreferrer"
        >
          Knight Frank
        </a>
        ,
        <a
          className="ml-1 underline"
          href="https://www.moneysupermarket.com/gas-and-electricity/value-of-efficiency/"
          target="_blank"
          rel="noopener noreferrer"
        >
          MoneySuperMarket
        </a>
        ,
        <a
          className="ml-1 underline"
          href="https://www.lloydsbankinggroup.com/media/press-releases/2021/halifax/homebuyers-pay-a-green-premium-of-40000-for-the-most-energy-efficient-properties.html"
          target="_blank"
          rel="noopener noreferrer"
        >
          Lloyds
        </a>
        , and
        <a
          className="ml-1 underline"
          href="https://www.nationwidehousepriceindex.co.uk/reports/energy-efficiency-ratings-currently-having-limited-impact-on-house-prices-despite-push-to-go-green"
          target="_blank"
          rel="noopener noreferrer"
        >
          Nationwide
        </a>
        .
      </div>
    </div>
  );
}
