diff --git a/packages/nextjs/components/ChatSearchBar.tsx b/packages/nextjs/components/ChatSearchBar.tsx index 654e05e..0fe7ab9 100644 --- a/packages/nextjs/components/ChatSearchBar.tsx +++ b/packages/nextjs/components/ChatSearchBar.tsx @@ -3,23 +3,23 @@ import { MagnifyingGlassIcon, PaperAirplaneIcon, XMarkIcon, TrophyIcon } from "@ import { motion, AnimatePresence } from "framer-motion"; interface Message { - text: string; - isUser: boolean; + text: string; + isUser: boolean; } const ChatSearchBar: FC = () => { - const [isChat, setIsChat] = useState(false); - const [inputText, setInputText] = useState(""); - const [messages, setMessages] = useState([]); - const [showCTA, setShowCTA] = useState(false); - - useEffect(() => { - // Show CTA after 2 seconds - const timer = setTimeout(() => setShowCTA(true), 2000); - return () => clearTimeout(timer); - }, []); - - const dailyChallenges = `Today's Challenges 🏋️‍♂️: + const [isChat, setIsChat] = useState(false); + const [inputText, setInputText] = useState(""); + const [messages, setMessages] = useState([]); + const [showCTA, setShowCTA] = useState(false); + + useEffect(() => { + // Show CTA after 2 seconds + const timer = setTimeout(() => setShowCTA(true), 2000); + return () => clearTimeout(timer); + }, []); + + const dailyChallenges = `Today's Challenges 🏋️‍♂️: 1. 10 Push-ups 2. 20 Sit-ups 3. 30 Jumping Jacks @@ -29,164 +29,173 @@ const ChatSearchBar: FC = () => { Complete these exercises to earn 0.01 ETH! Reply 'done' when you've completed the challenge.`; - const handleDailyChallenges = () => { - setIsChat(true); - setShowCTA(false); - setMessages([ - { - text: dailyChallenges, - isUser: false, - }, - ]); - }; - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - if (!inputText.trim()) return; - - setMessages(prev => [...prev, { text: inputText, isUser: true }]); - - // Bot response logic - setTimeout(() => { - let botResponse = "This is a sample response from the bot."; - - // Check if user completed challenge - if (inputText.toLowerCase() === "done") { - botResponse = "Congratulations! 🎉 You've completed today's challenge. Your reward of 0.01 ETH will be processed shortly."; - } - - setMessages(prev => [ - ...prev, - { - text: botResponse, - isUser: false, - }, - ]); - }, 1000); - - setInputText(""); - }; - - return ( - <> - {/* Pointing Arrow CTA */} - - {showCTA && !isChat && ( - - - {/* Glow effect */} -
- -
-

- Daily Challenge is here! 💪 -

- {/* Arrow pointing down */} -
-
-
-
-
-
- )} -
- - {/* Chat Interface */} -
{ + setIsChat(true); + setShowCTA(false); + setMessages([ + { + text: dailyChallenges, + isUser: false, + }, + ]); + }; + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + if (!inputText.trim()) return; + + setMessages(prev => [...prev, { text: inputText, isUser: true }]); + + // Bot response logic + setTimeout(() => { + let botResponse = "This is a sample response from the bot."; + + // Check if user completed challenge + if (inputText.toLowerCase() === "done") { + botResponse = "Congratulations! 🎉 You've completed today's challenge. Your reward of 0.01 ETH will be processed shortly."; + } + + setMessages(prev => [ + ...prev, + { + text: botResponse, + isUser: false, + }, + ]); + }, 1000); + + setInputText(""); + }; + + return ( + <> + {/* Pointing Arrow CTA */} + + {showCTA && !isChat && ( + + + {/* Glow effect */} +
+ +
+ {/* Close button */} + + +

+ Daily Challenge is here! 💪 +

+ {/* Arrow pointing down */} +
+
+
+
+
+
+ )} +
+ + {/* Chat Interface */} +
- {/* Chat Header */} - {isChat && ( -
-

Chat Assistant

- -
- )} - - {/* Chat Messages */} -
- {messages.map((message, index) => ( -
-
+ {/* Chat Header */} + {isChat && ( +
+

Chat Assistant

+ +
+ )} + + {/* Chat Messages */} +
+ {messages.map((message, index) => ( +
+
- {message.text.split('\n').map((line, i) => ( -
{line}
- ))} -
-
- ))} -
- - {/* Input Bar */} -
-
- {/* Daily Challenges Button */} - - -
- setInputText(e.target.value)} - onFocus={() => setIsChat(true)} - className="w-full px-4 py-2 rounded-xl bg-[#000001] text-[#fbf8fe] + > + + {/* Subtle highlight on hover */} +
+ + +
+ setInputText(e.target.value)} + onFocus={() => setIsChat(true)} + className="w-full px-4 py-2 rounded-xl bg-[#000001] text-[#fbf8fe] placeholder-[#a3a2a7] focus:outline-none focus:ring-2 focus:ring-[#11ce6f]" - /> - {!isChat && ( - - )} + /> + {!isChat && ( + + )} +
+ {isChat && ( + + )} + +
- {isChat && ( - - )} - -
-
- - ); + + ); }; export default ChatSearchBar; \ No newline at end of file