diff --git a/.env b/.env index 48f3eb8d..05090db8 100644 --- a/.env +++ b/.env @@ -50,3 +50,4 @@ TEST_POSTGRES_USER=encrypted:BK9zSnMHMV9qOSMhWXL3/CCW2kba6YuK4FWyedqmymvbeKS5Io1 TEST_POSTGRES_PASSWORD=encrypted:BO2T9M18B6ZRGXbkrARGI5Y/39VAJTKk6bh6U26awqLOI3oo64U25FUJnQZDt41hQx1dDOEFw5VQn8xn9jEMohgqftc38/5J1163A2SUxgpwqX+E+LIMVpAdF/5DdwY6kgZmHvNqSoojLon8JjGi/xYzvYZYp14u GOOGLE_MAPS_API_KEY="encrypted:BPEXj1LGaBGLofjSbq1f+a2g2UY0a52eKoE0EigAmBR9hEqhUBII3uxOoePs8emRckKJTOsVQhvEF4R6ljPgjRTbTe4CHJOtePtrrqZdfeXM6j+ihQYPU33Xj7HMWJ4nJqwC3qlyHCXfsNyUqtWqt+ogJ8BcxdRXalPZ29hc08oLC1Cz5kuzkA==" COOKIE_SECRET_KEY="encrypted:BGPsrFyF8pfvWalH7FTVOsk/YF2IE1Rij5bU4Cd+L1yfE30CuH4eAW6BtNuI0z7CSsGprh40Ff1CFLjYUKDoiB2YLh3V958LfCrMBTepT+1c541LPisVXIJBaYELuAKLYisv2ea56cAoaEgplV1o0IX8y9HRd0Aee7I57UG0Akl6YOVxKjCgL9dNix5K5BlLbmETcxQiIy4SueaZ5DrQlJo=" +GEMINI_API_KEY="encrypted:BP2mtWbB8yFLXhkV2pA+pwTnTRYVRlPPIt7yaV8rzLOaDz0dbUjbJj2o3AOesuzus31KyKfZbES7pH4KK4EzQ0UrVy4XDFv21rsBAAPpBBtntjuEFzsDyVAEWtzCnjSj1bTuKPh5lPbCL5iud6Sr1w3QJpJetktt+Ev+JESbDEe0yu3nO1N5uQ==" diff --git a/.env.prod b/.env.prod index e1b8006f..39420a64 100644 --- a/.env.prod +++ b/.env.prod @@ -20,3 +20,4 @@ VITE_GOOGLE_MAPS_API_KEY="encrypted:BL51xaluiOOL5lSdrtOgqh5DUURc4YNXXtstGJisVDh6 # ================================== # バックエンド用 (server/.env) # ================================== +GEMINI_API_KEY="encrypted:BNVJDvide1SMKfMAgfG5oFh/pFHEqiRbziDIaB9JxK3P5e8C3aNsFXp7MR4pasot/VoOq5xXHTDGg/zvfyjxyvOwJNVW3b6c1bafSfvw4Nu1K4vkgodKYuYiFpEvogXilIimcZmvJ4E9jZtAZHAG7Mem1GdtUXevTfuTss2K7r5cEt3iaWbFyg==" diff --git a/.env.stg b/.env.stg index 7ac14547..bfc85069 100644 --- a/.env.stg +++ b/.env.stg @@ -20,3 +20,4 @@ VITE_GOOGLE_MAPS_API_KEY="encrypted:BDktow+Fasf1jaW5SImOYFQ4loQ/Y35aVFvW4WF2eRZo # ================================== # バックエンド用 (server/.env) # ================================== +GEMINI_API_KEY="encrypted:BE7OVmuLqqHT41hGaPrculoSaKO3Hn+DMBRKsLPldxMK/RVEl+hm2W4vHbITzNS0MatZ9CMBTUF2lQNNpWISRF8S601UvQo4uEJSQc9rRTNpLNyg2J3A256nF773JSXZv2WKuMA22VtOFQTnGFbgrDfmU5t26/xdNv8IcMu6kyRndTl3+90+aw==" diff --git a/frontend/src/components/tripUrl/TripUrlFormatSection.tsx b/frontend/src/components/tripUrl/TripUrlFormatSection.tsx new file mode 100644 index 00000000..34b1c77a --- /dev/null +++ b/frontend/src/components/tripUrl/TripUrlFormatSection.tsx @@ -0,0 +1,92 @@ +import { useEffect, useState } from 'react'; +import { toast } from 'sonner'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; +import { Textarea } from '@/components/ui/textarea'; +import { useFormatTripUrl } from '@/hooks/useTripUrls'; +import { TRIP_URL_FORMAT_INTENT_MAX_LENGTH, TRIP_URL_FORMAT_SOURCE_MAX_LENGTH } from '@/types'; + +interface TripUrlFormatSectionProps { + tripId: number; + /** ダイアログの開閉状態。true → false → true で内部入力をリセット */ + open: boolean; + /** 整形成功時に呼ばれるコールバック。markdown を memo の末尾に追記する想定 */ + onAppend: (markdown: string) => void; +} + +export const TripUrlFormatSection = ({ tripId, open, onAppend }: TripUrlFormatSectionProps) => { + const [sourceText, setSourceText] = useState(''); + const [intent, setIntent] = useState(''); + const { formatTripUrl, isFormatting } = useFormatTripUrl(tripId); + + // ダイアログが開き直されたタイミングで入力をリセット + useEffect(() => { + if (open) { + setSourceText(''); + setIntent(''); + } + }, [open]); + + const handleFormat = async () => { + const trimmedSource = sourceText.trim(); + if (!trimmedSource) { + toast.error('整形対象テキストを入力してください'); + return; + } + const result = await formatTripUrl({ + sourceText, + intent: intent.trim() || null, + }); + if (result?.markdown) { + onAppend(result.markdown); + // 連続整形しやすいように整形対象だけクリア(指示は残す) + setSourceText(''); + toast.success('AI 整形をメモに追記しました'); + } + }; + + return ( +
+
+

AI で整形(任意)

+

結果はメモ末尾に追記されます

+
+ +
+ +