diff --git a/src/app/api/garden/species-search/route.ts b/src/app/api/garden/species-search/route.ts new file mode 100644 index 0000000..4fd2e29 --- /dev/null +++ b/src/app/api/garden/species-search/route.ts @@ -0,0 +1,17 @@ +import { NextResponse } from "next/server"; +import { getCurrentSession } from "@/lib/session"; +import { searchSpecies } from "@/modules/garden/server/species-lookup"; + +export async function GET(request: Request) { + try { + await getCurrentSession(); + } catch { + return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); + } + + const { searchParams } = new URL(request.url); + const q = searchParams.get("q") ?? ""; + + const results = await searchSpecies(q); + return NextResponse.json(results); +} diff --git a/src/app/garden/page.tsx b/src/app/garden/page.tsx index 148558c..fbe29df 100644 --- a/src/app/garden/page.tsx +++ b/src/app/garden/page.tsx @@ -1,12 +1,47 @@ -import { listContainers } from "@/modules/garden/server/queries"; +import Link from "next/link"; +import { listContainers, listPlants } from "@/modules/garden/server/queries"; import { ContainerList } from "@/modules/garden/components/container-list"; +import { PlantList } from "@/modules/garden/components/plant-list"; + +type Props = { + searchParams: Promise<{ tab?: string }>; +}; + +export default async function GardenPage({ searchParams }: Props) { + const { tab = "containers" } = await searchParams; + const isPlants = tab === "plants"; + + const [containers, plants] = await Promise.all([ + listContainers(), + isPlants ? listPlants() : Promise.resolve([]), + ]); -export default async function GardenPage() { - const containers = await listContainers(); return (
{plant.scientificName}
+ )} ++ Recent care +
+No photos yet.
+ ) : ( +{galleryError}
} + +Care tracking coming soon.
+ )} +No plants yet.
+ + Add your first plant + +{plant.name}
+Care overdue
+ )} +{d.scientificName}
+ )} ++ {d.healthStatus} · {d.category} +
+ {d.wateringNotes && ( ++ Watering +
+{d.wateringNotes}
++ Fertilizing +
+{d.fertilizingNotes}
+{d.notes}
} + {d.images.length > 1 && ( +