feat: garden containers crud (task 71)

- add listContainers/getContainer/searchContainers queries
- add createContainer/updateContainer/deleteContainer server actions with logActivity
- add ContainerList, ContainerDetail, ContainerForm client components
- add /garden, /garden/containers/[id], /garden/containers/new pages
- register garden.container entity with share + search in manifest
- add sprout icon to NavIcon registry
- add garden e2e test spec
This commit is contained in:
ginnoir
2026-06-01 19:28:34 -05:00
parent 2fd0677c5f
commit 5f6b756342
12 changed files with 756 additions and 4 deletions
@@ -0,0 +1,40 @@
import { and, eq } from "drizzle-orm";
import { db } from "@/lib/db";
import { gardenContainers, gardenPlants } from "../schema";
export type ContainerShareData = {
id: string;
name: string;
type: string;
locationNotes: string | null;
coverImageUrl: string | null;
plants: { id: string; name: string; scientificName: string | null }[];
};
export async function loadContainerForShare(id: string): Promise<ContainerShareData | null> {
const [container] = await db
.select()
.from(gardenContainers)
.where(eq(gardenContainers.id, id))
.limit(1);
if (!container) return null;
const plants = await db
.select({
id: gardenPlants.id,
name: gardenPlants.name,
scientificName: gardenPlants.scientificName,
})
.from(gardenPlants)
.where(and(eq(gardenPlants.containerId, id)));
return {
id: container.id,
name: container.name,
type: container.type,
locationNotes: container.locationNotes,
coverImageUrl: container.coverImageUrl,
plants,
};
}