diff --git a/client/package-lock.json b/client/package-lock.json index 6f53dec..8dc078b 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -6573,7 +6573,8 @@ }, "node_modules/react": { "version": "18.3.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "dependencies": { "loose-envify": "^1.1.0" }, diff --git a/client/src/App.jsx b/client/src/App.jsx index e8d4f2c..facb8b3 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -18,6 +18,7 @@ import ProjectState from "./context/ProjectState"; import ProfileState from "./context/ProfileState"; import CodeOfConduct from "./component/Footers/Codeofconduct"; import Feedback from "./component/Footers/Feedback"; +import Faqsec from "./component/Faqsec" import ContactUs from "./component/Footers/Contactus"; import PrivacyPolicy from "./component/Footers/Privacypolicy"; import TermOfUse from "./component/Footers/TermOfUse"; @@ -153,6 +154,7 @@ function App() { } /> } /> } /> + } /> } /> diff --git a/client/src/assets/images/vector-faq-frequently-asked-questions.png b/client/src/assets/images/vector-faq-frequently-asked-questions.png new file mode 100644 index 0000000..f3f245b Binary files /dev/null and b/client/src/assets/images/vector-faq-frequently-asked-questions.png differ diff --git a/client/src/component/Faqsec.jsx b/client/src/component/Faqsec.jsx new file mode 100644 index 0000000..bfd6e40 --- /dev/null +++ b/client/src/component/Faqsec.jsx @@ -0,0 +1,54 @@ +import { useState } from 'react'; +import faqimage from "../assets/images/vector-faq-frequently-asked-questions.png" +const FAQSection = () => { + const [activeIndex, setActiveIndex] = useState(null); + + const faqs = [ + { question: "What is Bitbox?", answer: "Bitbox is a collaborative platform for developers to share and find solutions to coding projects, enhancing project development and troubleshooting." }, + { question: "Who can use Bitbox?", answer: "Bitbox is suitable for developers, students, and tech enthusiasts seeking collaboration on coding projects or guidance." }, + { question: "How can I submit a project on Bitbox?", answer: "Sign up and click 'Submit Project' to share details and engage with the community." }, + { question: "Is Bitbox free to use?", answer: "Yes, Bitbox is currently free for project submission and collaboration." }, + { question: "Can I get feedback on my code?", answer: "Yes, community members can provide feedback and suggestions on projects." }, + { question: "What types of projects are welcome on Bitbox?", answer: "All coding projects across languages and frameworks are welcome on Bitbox." }, + { question: "How do I report inappropriate content?", answer: "Click the 'Report' button on any content, and our moderators will review it." }, + { question: "Can I connect with other users?", answer: "Yes, you can comment on projects and join discussions to collaborate." }, + { question: "Is Bitbox limited to specific programming languages?", answer: "No, Bitbox supports projects in various programming languages and frameworks." }, + { question: "How do I stay updated on new projects?", answer: "Sign up for notifications or follow popular projects for updates on the latest content." } +]; + + + const handleToggle = (index) => { + setActiveIndex(activeIndex === index ? null : index); + }; + + return ( +
+

Frequently Asked Questions

+ +
+
+ Description w-1/2 +
+
+ {faqs.map((faq, index) => ( +
+
handleToggle(index)} + > +

{faq.question}

+
+ {activeIndex === index && ( +
+

{faq.answer}

+
+ )} +
+ ))} +
+
+
+ ); +}; + +export default FAQSection; diff --git a/client/src/component/Footer.jsx b/client/src/component/Footer.jsx index 65ab651..159ed9b 100644 --- a/client/src/component/Footer.jsx +++ b/client/src/component/Footer.jsx @@ -227,6 +227,9 @@ const Footer = (props) => {
  • Terms of use
  • +
  • + FAQs +
  • diff --git a/server/Controllers/adminController.js b/server/Controllers/adminController.js new file mode 100644 index 0000000..c4e1e7e --- /dev/null +++ b/server/Controllers/adminController.js @@ -0,0 +1,87 @@ +const Admin = require("../Models/Admin"); +const bcrypt = require("bcrypt"); +var jwt = require("jsonwebtoken"); +const nodemailer = require("nodemailer"); +const crypto = require("crypto"); +require('dotenv').config(); // Load environment variables from .env file +const { body, validationResult } = require("express-validator"); +const login= async (req, res) => { + let success = false; + console.log("see"); + + // Check for validation errors + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ errors: errors.array() }); + } + + const { email, password } = req.body; + + try { + let user = await Admin.findOne({ email }); + + // If user does not exist + if (!user) { + return res.status(400).json({ + success, + error: "Please try to login with correct credentials", + }); + } + + // Compare provided password with stored password + const passwordCompare = await bcrypt.compare(password, user.password); + + if (!passwordCompare) { + return res.status(400).json({ + success, + error: "Please try to login with correct credentials", + }); + } + + // Create JWT payload + const data = { + user: { + id: user.id, + }, + }; + + // Sign the JWT + const authtoken = jwt.sign(data, process.env.JWT_SECRET); + // Send token in response to be stored in localStorage on the client + return res.status(200).json({ success: true, authtoken }); + } catch (error) { + console.error(error.message); + return res.status(500).send("Internal Server Error"); + } +} +const createAdmin=async (req, res) => { + const { name, email, password } = req.body; + + try { + const saltRounds = 10; + const hashedPassword = await bcrypt.hash(password, saltRounds); + + // Create a new user (save in your database) + const user = new Admin({ name, email, password: hashedPassword }); + + await user.save(); + return res.status(201).json({ success: true, message: "Admin created successfully"}) + } catch (error) { + res.status(500).json({ success: false, message: error.message }); + } + }; +const logout=async (req,res)=>{ + // Optionally, you can clear the cookie if you're using cookies for sessions + res.clearCookie('connect.sid'); // Replace 'connect.sid' with your session cookie name + + // Send a success response + return res.status(200).json({ message: 'Successfully logged out.' }); + +} +const dashboard= null; + + +module.exports = { + login, + createAdmin, +}; diff --git a/server/Models/Admin.js b/server/Models/Admin.js new file mode 100644 index 0000000..786193d --- /dev/null +++ b/server/Models/Admin.js @@ -0,0 +1,31 @@ +const mongoose = require("mongoose"); +const { Schema } = mongoose; + +const AdminSchema = new Schema( + { + imageUrl: { + type: String, + required: false + }, + name: { + type: String, + required: true + }, + email: { + type: String, + required: true, + unique: true, + match: [/\S+@\S+\.\S+/, 'Please enter a valid email address'], + }, + password: { + type: String, + required: true, + minlength: 8 // Minimum length for password + }, + }, + { timestamps: true } +); + +const Admin = mongoose.model('Admin', AdminSchema); +module.exports = Admin; + diff --git a/server/index.js b/server/index.js index 300c76a..1178aac 100644 --- a/server/index.js +++ b/server/index.js @@ -52,6 +52,7 @@ app.use("/api/contact", require("./routes/contact")); app.use("/api/blog", require("./routes/blog")); app.use("/api/visitor", require("./routes/visitor")); app.use("/api/showcaseProjects", require("./routes/projectsRoute")); +app.use("/api/admin", require("./routes/adminRoute")) app.use("/api/discussion", require("./routes/discussionRoutes")); // Socket.io connection handling diff --git a/server/routes/adminRoute.js b/server/routes/adminRoute.js new file mode 100644 index 0000000..bd3ab82 --- /dev/null +++ b/server/routes/adminRoute.js @@ -0,0 +1,18 @@ + +const express = require("express"); +var jwt = require("jsonwebtoken"); +const {login,createAdmin}= require("../Controllers/adminController") +const User = require("../Models/Admin.js"); +const bcrypt = require("bcrypt"); +const router = express.Router(); +require("dotenv").config(); +const { body, validationResult } = require("express-validator"); +const { OAuth2Client } = require("google-auth-library"); +const rateLimit = require("express-rate-limit"); +require('dotenv').config(); // Load environment variables from .env file + + +router.post("/login",login) +router.post("/create",createAdmin) + +module.exports = router; \ No newline at end of file