diff --git a/frontend/src/components/Olliebot.tsx b/frontend/src/components/Olliebot.tsx new file mode 100644 index 0000000..40e9d30 --- /dev/null +++ b/frontend/src/components/Olliebot.tsx @@ -0,0 +1,156 @@ +import React, { useState } from 'react'; +import { MessageCircle, X, ChevronDown, ChevronUp, HelpCircle } from 'lucide-react'; + +const Olliebot = () => { + const [isOpen, setIsOpen] = useState(false); + const [showFaqs, setShowFaqs] = useState(true); + + const toggleChat = () => { + setIsOpen(!isOpen); + }; + + const toggleFaqs = () => { + setShowFaqs(!showFaqs); + }; + + interface Message { + id: string; + text: string; + isUser: boolean; + } + + interface FaqItem { + id: string; + question: string; + answer: string; + } + + // All new messages are added here + const [messages, setMessages] = useState([ + { id: '1', text: "Hi! What can I help you with today?", isUser: false } + ]); + + // Mapping? Similar to how freerooms was done for search + const FaqItems: FaqItem[] = [ + { + id: "1", + question: "What is CSESoc?", + answer: "We're one of the largest computing societies in the southern hemisphere! Whether you're looking to improve your tech skills, network with like-minded peers, or explore career opportunities, CSESoc offers valuable resources and experiences for computer science and engineering students.", + }, + { + id: "2", + question: "How can I join CSESoc?", + answer: "Check our discord and website for updates! Spots open up every year :)", + }, + { + id: "3", + question: "What events do CSESoc run?", + answer: "We run events that range from fun social meetups to hackathons and training workshops. You can check out our full event listing at our facebook page and on discord announcements!", + }, + { + id: "4", + question: "Who's Ollie?", + answer: "That would be me! Wait, I'm actually a bot. Anyways, Ollie is CSESoc's ottersome little mascot!", + }, + ]; + + const addMessage = (text: string, isUser: boolean) => { + const newMessage: Message = { + id: Date.now().toString(), + text, + isUser, + }; + {/*Update array, append new message atop previous*/} + setMessages(prevMessages => [...prevMessages, newMessage]); + }; + + const handleFaqSelect = (faq: FaqItem) => { + addMessage(faq.question, true); + setTimeout(() => { + addMessage(faq.answer, false); + }, 500); + }; + + return ( +
+
+ {!isOpen ? ( +
+ +
+ ) : ( + <> +
+
+ + Olliebot +
+ +
+ + {/* Messages */} +
+ {messages.map((message) => ( +
+
+ {message.text} +
+
+ ))} +
+ + {/* FAQs */} +
+ + + {showFaqs && ( +
+ {FaqItems.map((faq) => ( + + ))} +
+ )} +
+ + )} +
+
+ ); +}; + +export default Olliebot; \ No newline at end of file diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index 7f243f2..781f3df 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -4,6 +4,7 @@ import Sponsors from '@/components/Sponsors/index'; import AboutHomePage from '@/components/About/AboutHomepage'; import EventsBrief from '@/components/Event/EventsBrief'; import TabTitle from 'next/head'; +import Olliebot from '@/components/Olliebot'; export default function HomePage() { return ( @@ -25,6 +26,8 @@ export default function HomePage() { + + );