Fix plant placement + add a Seed Tray (#39) (#42)
Build image / build-and-push (push) Successful in 21s

Use the full Plant the picker returns (fixes the silent placement failure) and add a per-garden Seed Tray for quick repeat placing. Review fixes: disarm on tray-remove, cap load, consolidate toolbar guards, rename interface, tidy.

Closes #39.

Co-authored-by: Steve Dudenhoeffer <[email protected]>
This commit was merged in pull request #42.
This commit is contained in:
2026-07-19 06:09:51 +00:00
committed by steve
parent fef3f601bf
commit 5cdc2779d7
4 changed files with 226 additions and 25 deletions
+20 -1
View File
@@ -3,11 +3,12 @@
// PATCH with the row version; a 409 rolls back to the server's current row and
// toasts (see DESIGN § Sync).
import { useCallback } from 'react'
import { queryOptions, useMutation, useQuery, useQueryClient, type QueryClient } from '@tanstack/react-query'
import { z } from 'zod'
import { ApiError, api } from './api'
import { gardenSchema } from './gardens'
import { plantSchema } from './plants'
import { plantSchema, type Plant } from './plants'
import { serverPlantingSchema, type ServerPlanting } from './plantings'
import { toast } from '@/components/ui/toast'
import type { EditorObject, ObjectShapeKind } from '@/editor/types'
@@ -77,6 +78,24 @@ export function useGardenFull(gardenId: number) {
return useQuery(gardenFullQueryOptions(gardenId))
}
/**
* Ensure a plant is present in the /full cache's `plants` list. The full payload
* carries only the garden's *referenced* plants (ListReferencedPlants), so a
* plant chosen from the full catalog but not yet placed here is absent — its
* plops would render without an icon/color until the next refetch. Call this
* when arming/placing such a plant so it renders immediately. No-op if present.
*/
export function useEnsurePlantInFull(gardenId: number) {
const qc = useQueryClient()
return useCallback(
(plant: Plant) =>
patchFullCache(qc, gardenId, (full) =>
full.plants.some((p) => p.id === plant.id) ? full : { ...full, plants: [...full.plants, plant] },
),
[qc, gardenId],
)
}
// --- mutations -------------------------------------------------------------
export interface ObjectCreate {