diff --git a/www/.env.template b/www/.env.template index d1646c1..24ea366 100644 --- a/www/.env.template +++ b/www/.env.template @@ -20,6 +20,9 @@ NEXT_PUBLIC_STRIPE_ENABLED=false STRIPE_SECRET_KEY= NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY= STRIPE_WEBHOOK_SECRET= +# Turnstile (optional) +NEXT_PUBLIC_TURNSTILE_SITE_KEY= +TURNSTILE_SECRET_KEY= # Agent AI_API_KEY= MODEL= diff --git a/www/app/Chat.tsx b/www/app/Chat.tsx index d2a6e9b..00794fe 100644 --- a/www/app/Chat.tsx +++ b/www/app/Chat.tsx @@ -9,6 +9,7 @@ import Swal from 'sweetalert2'; import { useRef, useEffect, useState, ElementRef, useMemo } from 'react'; // import { useRouter } from 'next/navigation'; import { usePostHog } from 'posthog-js/react'; +import Turnstile, { useTurnstile } from 'react-turnstile'; // import { createClient } from '@/utils/supabase/client'; import { Reaction } from '@/components/messagebox'; @@ -136,6 +137,10 @@ export default function Chat({ const messageContainerRef = useRef>(null); const [, scrollToBottom] = useAutoScroll(messageContainerRef); + const turnstileEnabled = process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY !== null; + const turnstileSiteKey = process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY || ''; + const turnstile = useTurnstile(); + const messageListRef = useRef(null); const firstChat = useMemo(() => { return ( @@ -505,7 +510,7 @@ What\'s on your mind? Let\'s dive in. 🌱`,
{ e.preventDefault(); if (canSend && input.current?.value && canUseApp) { @@ -514,42 +519,56 @@ What\'s on your mind? Let\'s dive in. 🌱`, } }} > -