From 9f087165681a5c85cdee160ac485e11ab8c3e359 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Thu, 21 Mar 2024 09:41:43 -0500 Subject: [PATCH] Finalize photo editing AI experience --- src/app/admin/photos/[photoId]/edit/page.tsx | 4 +- src/components/FieldSetWithStatus.tsx | 51 ++++++++++++-------- src/photo/PhotoEditPageClient.tsx | 32 ++++++------ src/photo/ai/AiButton.tsx | 28 +++++++++++ src/photo/ai/index.ts | 2 +- src/photo/ai/useAiImageQueries.ts | 12 +++-- src/photo/ai/useAiImageQuery.ts | 4 +- src/photo/ai/useTitleCaptionAiImageQuery.ts | 8 ++- src/photo/form/PhotoForm.tsx | 11 +++-- src/photo/form/index.ts | 15 +++++- src/site/globals.css | 13 +++-- 11 files changed, 124 insertions(+), 56 deletions(-) create mode 100644 src/photo/ai/AiButton.tsx diff --git a/src/app/admin/photos/[photoId]/edit/page.tsx b/src/app/admin/photos/[photoId]/edit/page.tsx index 767ba55b..c9a5c68c 100644 --- a/src/app/admin/photos/[photoId]/edit/page.tsx +++ b/src/app/admin/photos/[photoId]/edit/page.tsx @@ -15,13 +15,13 @@ export default async function PhotoEditPage({ const uniqueTags = await getUniqueTagsCached(); - const aiTextGeneration = AI_TEXT_GENERATION_ENABLED; + const hasAiTextGeneration = AI_TEXT_GENERATION_ENABLED; return ( ); }; diff --git a/src/components/FieldSetWithStatus.tsx b/src/components/FieldSetWithStatus.tsx index 85677d12..d681955d 100644 --- a/src/components/FieldSetWithStatus.tsx +++ b/src/components/FieldSetWithStatus.tsx @@ -101,25 +101,38 @@ export default function FieldSetWithStatus({ className={clsx(Boolean(error) && 'error')} readOnly={readOnly || pending || loading} /> - : onChange?.(type === 'checkbox' - ? e.target.value === 'true' ? 'false' : 'true' - : e.target.value)} - type={type} - autoComplete="off" - autoCapitalize={!capitalize ? 'off' : undefined} - readOnly={readOnly || pending || loading} - className={clsx( - type === 'text' && 'w-full', - Boolean(error) && 'error', - )} - />} + : type === 'textarea' + ?