import { notFound } from "next/navigation";
import { listCalendars } from "@/modules/garden/server/calendar-bridge";
import { getCareLogs, getCareSchedules, getPlant } from "@/modules/garden/server/queries";
import { PlantDetail } from "@/modules/garden/components/plant-detail";
import { getShareLinksForEntity } from "@/modules/_core/share";

export default async function PlantPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const [plant, careLogs, careSchedules, calendars, shareLinks] = await Promise.all([
    getPlant(id),
    getCareLogs(id),
    getCareSchedules(id),
    listCalendars(),
    getShareLinksForEntity("garden.plant", id),
  ]);
  if (!plant) notFound();

  return (
    <div className="page-content">
      <PlantDetail
        plant={plant}
        careLogs={careLogs}
        careSchedules={careSchedules}
        calendars={calendars}
        shareLinks={shareLinks}
      />
    </div>
  );
}
