From 82a4738d95cb8da7c9ac45789b4878ab03b778f4 Mon Sep 17 00:00:00 2001 From: Tero Halla-aho Date: Sat, 29 Nov 2025 19:42:21 +0200 Subject: [PATCH] Improve localization AI helper layout --- app/listings/new/page.tsx | 110 ++++++++++++++++++++++++++------------ lib/i18n.ts | 9 ++++ 2 files changed, 84 insertions(+), 35 deletions(-) diff --git a/app/listings/new/page.tsx b/app/listings/new/page.tsx index a3277be..3f72b02 100644 --- a/app/listings/new/page.tsx +++ b/app/listings/new/page.tsx @@ -59,6 +59,7 @@ export default function NewListingPage() { const [loading, setLoading] = useState(false); const [isAuthed, setIsAuthed] = useState(false); const [aiResponse, setAiResponse] = useState(''); + const [copyStatus, setCopyStatus] = useState<'idle' | 'copied' | 'error'>('idle'); useEffect(() => { setCurrentLocale(uiLocale as Locale); @@ -192,6 +193,18 @@ export default function NewListingPage() { } } + async function copyAiPrompt() { + try { + if (!navigator?.clipboard) throw new Error('clipboard unavailable'); + await navigator.clipboard.writeText(aiPrompt); + setCopyStatus('copied'); + setTimeout(() => setCopyStatus('idle'), 1500); + } catch (err) { + setCopyStatus('error'); + setTimeout(() => setCopyStatus('idle'), 2000); + } + } + function parseImages(): ImageInput[] { return selectedImages.map((img) => ({ data: img.dataUrl, @@ -306,7 +319,7 @@ export default function NewListingPage() { } return ( -
+

{t('createListingTitle')}