From 17756ffd7314ec573286882fb6c8d7b98d191d06 Mon Sep 17 00:00:00 2001 From: Sawan Date: Sat, 9 Nov 2024 21:58:40 +0530 Subject: [PATCH 1/2] Remove cached FAQ.jsx --- client/src/component/FAQ.jsx | 51 ------------------------------------ 1 file changed, 51 deletions(-) delete mode 100644 client/src/component/FAQ.jsx diff --git a/client/src/component/FAQ.jsx b/client/src/component/FAQ.jsx deleted file mode 100644 index ae2e048..0000000 --- a/client/src/component/FAQ.jsx +++ /dev/null @@ -1,51 +0,0 @@ -// component/FAQ.jsx -import React, { useState } from 'react'; -import './FAQ.css'; // Import the CSS file for styling - -const FAQ = () => { - const [activeIndex, setActiveIndex] = useState(null); - - const toggleAnswer = (index) => { - setActiveIndex(activeIndex === index ? null : index); - }; - - return ( -
-

Frequently Asked Questions

- {faqData.map((item, index) => ( -
-

toggleAnswer(index)} className="faq-question"> - {item.question} -

- {activeIndex === index &&

{item.answer}

} -
- ))} -
- ); -}; - -const faqData = [ - { - question: "What is BitBox?", - answer: "BitBox is a user-friendly platform that simplifies version control and collaboration for developers.", - }, - { - question: "How does BitBox enhance collaboration?", - answer: "BitBox offers intuitive tools that enable both solo programmers and large teams to manage projects efficiently.", - }, - { - question: "How do I get started with BitBox?", - answer: "You can sign up for an account on BitBox and start managing your projects right away.", - }, - { - question: "Is BitBox compatible with modern development workflows?", - answer: "Yes, BitBox seamlessly integrates with modern development workflows, providing fast and reliable performance.", - }, - { - question: "How can I contact support if I need help?", - answer: "You can reach out to support through the 'Contact Us' page or by emailing support@example.com.", - }, -]; - - -export default FAQ; From c4d21f83c5a5746ee6f55cc351c06972378a8054 Mon Sep 17 00:00:00 2001 From: Sawan Date: Sat, 9 Nov 2024 22:23:51 +0530 Subject: [PATCH 2/2] Added discussion forum --- client/package-lock.json | 1 - client/src/App.jsx | 2 + client/src/component/DiscussionForum.jsx | 156 +++++++++++++++++++++++ client/src/component/faq.jsx | 55 ++++++++ package-lock.json | 2 +- 5 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 client/src/component/DiscussionForum.jsx create mode 100644 client/src/component/faq.jsx diff --git a/client/package-lock.json b/client/package-lock.json index 0246cf8..65e9880 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -2045,7 +2045,6 @@ }, "node_modules/@types/react-dom": { "version": "18.3.1", - "dev": true, "license": "MIT", "dependencies": { "@types/react": "*" diff --git a/client/src/App.jsx b/client/src/App.jsx index 5a69abf..2a0844e 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -38,6 +38,7 @@ import "aos/dist/aos.css"; import Collab from "./component/Collab"; import CreateBlog from "./component/CreateBlog"; import UploadProject from "./component/UploadProject"; +import DiscussionForum from "./component/DiscussionForum"; const Layout = ({ children, mode, setProgress, toggleMode, showAlert }) => { return ( @@ -146,6 +147,7 @@ function App() { } /> } /> } /> + } /> } /> diff --git a/client/src/component/DiscussionForum.jsx b/client/src/component/DiscussionForum.jsx new file mode 100644 index 0000000..3da0732 --- /dev/null +++ b/client/src/component/DiscussionForum.jsx @@ -0,0 +1,156 @@ +import { useState, useEffect } from 'react'; + +const DiscussionForum = (props) => { + const [questions, setQuestions] = useState([]); + + // Fetch questions from localStorage + useEffect(() => { + const storedQuestions = localStorage.getItem('questions'); + if (storedQuestions) { + setQuestions(JSON.parse(storedQuestions)); + } + }, []); + + // Save questions to localStorage + const saveQuestions = (updatedQuestions) => { + setQuestions(updatedQuestions); + localStorage.setItem('questions', JSON.stringify(updatedQuestions)); + }; + + // Helper function to save a new question + const addQuestion = (content) => { + const newQuestion = { + id: Date.now().toString(), + content, + answered: false, + answer: '', + }; + + const updatedQuestions = [...questions, newQuestion]; + saveQuestions(updatedQuestions); + }; + + // Helper function to add an answer to a question + const addAnswer = (questionId, answerContent) => { + const updatedQuestions = questions.map((question) => + question.id === questionId + ? { ...question, answered: true, answer: answerContent } + : question + ); + saveQuestions(updatedQuestions); + }; + + // Function to render the Question Card + const renderQuestionCard = (question) => { + return ( +
+

{question.content}

+ {question.answered ? ( +
+

Answer:

+

{question.answer}

+
+ ) : ( + + )} +
+ ); + }; + + // Function to render the Answer Form + const AnswerForm = ({ questionId }) => { + const [answer, setAnswer] = useState(''); + + const handleSubmit = (e) => { + e.preventDefault(); + if (answer.trim()) { + addAnswer(questionId, answer); + setAnswer(''); + } + }; + + return ( +
+