From b114bca43e259d283ca1a8bd56a2902cc7c59256 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Wed, 5 Mar 2025 22:00:42 -0800 Subject: [PATCH] Create recipe auto-chooser in photo form --- app/admin/photos/[photoId]/edit/page.tsx | 12 ++++- src/components/FieldSetWithStatus.tsx | 6 +++ src/components/TagInput.tsx | 61 ++++++++++++++++++------ src/photo/PhotoEditPageClient.tsx | 4 ++ src/photo/PhotoGridSidebar.tsx | 3 +- src/photo/cache.ts | 10 +++- src/photo/form/PhotoForm.tsx | 9 ++++ src/photo/form/index.ts | 6 +++ src/recipe/index.ts | 21 +++++--- 9 files changed, 107 insertions(+), 25 deletions(-) diff --git a/app/admin/photos/[photoId]/edit/page.tsx b/app/admin/photos/[photoId]/edit/page.tsx index a0b1419a..e81de2c7 100644 --- a/app/admin/photos/[photoId]/edit/page.tsx +++ b/app/admin/photos/[photoId]/edit/page.tsx @@ -1,11 +1,16 @@ import { redirect } from 'next/navigation'; -import { getPhotoNoStore, getUniqueTagsCached } from '@/photo/cache'; +import { + getPhotoNoStore, + getUniqueRecipesCached, + getUniqueTagsCached, +} from '@/photo/cache'; import { PATH_ADMIN } from '@/app/paths'; import PhotoEditPageClient from '@/photo/PhotoEditPageClient'; import { AI_TEXT_GENERATION_ENABLED, BLUR_ENABLED, IS_PREVIEW, + SHOW_RECIPES, } from '@/app/config'; import { blurImageFromUrl, resizeImageFromUrl } from '@/photo/server'; import { getNextImageUrlForManipulation } from '@/platforms/next-image'; @@ -23,6 +28,10 @@ export default async function PhotoEditPage({ const uniqueTags = await getUniqueTagsCached(); + const uniqueRecipes = SHOW_RECIPES + ? await getUniqueRecipesCached() + : []; + const hasAiTextGeneration = AI_TEXT_GENERATION_ENABLED; // Only generate image thumbnails when AI generation is enabled @@ -42,6 +51,7 @@ export default async function PhotoEditPage({ : type === 'textarea' ?