diff --git a/client/src/App.jsx b/client/src/App.jsx
index f57a36f..2000cb6 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -39,6 +39,8 @@ import "aos/dist/aos.css";
import Collab from "./component/Collab";
import FAQ from "./component/Faq";
import CreateBlog from "./component/CreateBlog";
+import Projects from "./component/Projects";
+import UploadProject from "./component/UploadProject";
// Main Layout Component
const Layout = ({ children, mode, setProgress, toggleMode, showAlert }) => {
@@ -53,6 +55,7 @@ const Layout = ({ children, mode, setProgress, toggleMode, showAlert }) => {
blog="Blogs"
discussion="Discussion"
contributors="Contributors"
+ projects="Projects"
Feedback="Feedback"
showAlert={showAlert}
mode={mode}
@@ -147,6 +150,8 @@ function App() {
} />
} />
} />
+ } />
+ } />
} />
} />
} />
diff --git a/client/src/component/Navbar.jsx b/client/src/component/Navbar.jsx
index 5c367f3..7293845 100644
--- a/client/src/component/Navbar.jsx
+++ b/client/src/component/Navbar.jsx
@@ -225,6 +225,16 @@ function Navbar(props) {
{props.contributors}
+
Loading...
;
+ }
+
+ if (error) {
+ return
-
+
+
+ Upload Your Project
+
+
+
+
- )
-}
+ );
+};
-// Props Vadilation
UploadProject.propTypes = {
- title: PropTypes.string,
- desc: PropTypes.string,
- showAlert: PropTypes.func,
+
+ mode: PropTypes.string,
+
};
-export default UploadProject
\ No newline at end of file
+export default UploadProject;
diff --git a/server/Controllers/projectController.js b/server/Controllers/projectController.js
new file mode 100644
index 0000000..fda139f
--- /dev/null
+++ b/server/Controllers/projectController.js
@@ -0,0 +1,33 @@
+const Project = require('../Models/ProjectSchema.js');
+
+exports.postProject = async (req, res) => {
+ const { title, description, githubLink, deploymentLink } = req.body;
+
+ if (!title || !description) {
+ return res.status(400).json({ message: 'Title and description are required' });
+ }
+
+ try {
+ const newProject = new Project({
+ title,
+ description,
+ githubLink,
+ deploymentLink,
+ });
+
+ await newProject.save();
+
+ return res.status(201).json({ message: 'Project created successfully', project: newProject });
+ } catch (error) {
+ return res.status(500).json({ message: 'Error creating project', error });
+ }
+};
+
+exports.getAllProjects = async (req, res) => {
+ try {
+ const projects = await Project.find();
+ return res.status(200).json(projects);
+ } catch (error) {
+ return res.status(500).json({ message: 'Error fetching projects', error });
+ }
+};
diff --git a/server/Models/ProjectSchema.js b/server/Models/ProjectSchema.js
new file mode 100644
index 0000000..61c0107
--- /dev/null
+++ b/server/Models/ProjectSchema.js
@@ -0,0 +1,12 @@
+const mongoose = require('mongoose');
+
+const projectSchema = new mongoose.Schema({
+ title: { type: String, required: true },
+ description: { type: String, required: true },
+ githubLink: { type: String },
+ deploymentLink: { type: String },
+});
+
+const Project = mongoose.model('Project', projectSchema);
+
+module.exports = Project;
diff --git a/server/index.js b/server/index.js
index 4fbf7f8..dea3894 100644
--- a/server/index.js
+++ b/server/index.js
@@ -48,6 +48,7 @@ app.use("/api/feedback", require("./routes/feedback"));
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"));
// Socket.io connection handling
const users = {};
diff --git a/server/routes/projects.js b/server/routes/projects.js
index e422db1..d0f1794 100644
--- a/server/routes/projects.js
+++ b/server/routes/projects.js
@@ -3,14 +3,14 @@ const router = express.Router();
const Project = require('../Models/Project');
const fetchuser = require('../middleware/fetchuser');
const { validationResult, body } = require('express-validator'); // Add 'body' here
-const {
+const {
fetchallglobalprojects,
fetchalluserprojects,
addproject,
updateproject,
deleteproject,
uploadProjectImage,
- getProjectImage
+ getProjectImage
} = require('../Controllers/projects');
// ROUTE 1 : Get All Global Projects : GET: "/api/projects/fetchallglobalprojects". No Login required
diff --git a/server/routes/projectsRoute.js b/server/routes/projectsRoute.js
new file mode 100644
index 0000000..e411fc8
--- /dev/null
+++ b/server/routes/projectsRoute.js
@@ -0,0 +1,9 @@
+const express = require('express');
+const router = express.Router();
+const projectController = require('../Controllers/projectController.js');
+
+router.post('/post-project', projectController.postProject);
+router.get('/all-projects', projectController.getAllProjects);
+
+
+module.exports = router;