Skip to content

Commit

Permalink
Merge branch 'main' into burger-menu-links
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv8433 authored Jun 9, 2024
2 parents 25985ce + 33bb92b commit 4182834
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 178 deletions.
49 changes: 32 additions & 17 deletions backend/src/controllers/openSourceController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,46 @@ require("dotenv").config();

const addProject = async (req, res) => {
try {
const {projectName, ownerUsername, tags, link, description} = req.body;
const { projectName, ownerUsername, tags, link, description } = req.body;

// Validation
if (!projectName || !ownerUsername || !link || !description) {
return res.status(400).json({ success: false, errors: ["All fields are required"] });
}

const newProject = await OpenSource.create({
projectName, ownerUsername, tags, link, description
})
});

if (!newProject)
return res.statsu(401).json({ success: false, errors: ["Issue Adding the Tool"] });

return res.status(201).json({ success: true });
}
catch (error) {
console.log(error);
if (!newProject) {
return res.status(401).json({ success: false, errors: ["Issue Adding the Tool"] });
}

return res.status(201).json({ success: true, project: newProject });
} catch (error) {
console.error(error);
return res.status(500).json({ success: false, errors: ["Internal Server Error"] });
}
}
};

const fetchAllProjects = async (req, res) => {
try {
const openSourceProjects = await OpenSource.find();
return res.status(200).json({ success: true, openSourceProjects: openSourceProjects });
}
catch (error) {
console.log(error);
const { page = 1, limit = 10 } = req.query;
const openSourceProjects = await OpenSource.find()
.skip((page - 1) * limit)
.limit(limit);

const totalProjects = await OpenSource.countDocuments();
return res.status(200).json({
success: true,
openSourceProjects,
totalPages: Math.ceil(totalProjects / limit),
currentPage: parseInt(page)
});
} catch (error) {
console.error(error);
return res.status(500).json({ success: false, errors: ["Internal Server Error"] });
}
}
};

module.exports = { addProject, fetchAllProjects };
module.exports = { addProject, fetchAllProjects };
163 changes: 26 additions & 137 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"antd": "^5.6.4",
"aos": "^2.3.4",
"axios": "^1.6.1",
Expand All @@ -18,10 +20,10 @@
"lottie-react": "^2.4.0",
"mongodb": "^6.2.0",
"pagination": "^0.4.6",
"react": "^18.2.0",
"react": "^18.3.1",
"react-accessible-accordion": "^5.0.0",
"react-chatbot-kit": "^2.2.2",
"react-dom": "^18.2.0",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"react-icons": "^4.12.0",
"react-paginate": "^8.2.0",
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ import CoursesPlatform from "./pages/CoursesPlatform";

function App() {
const [searchQuery, setSearchQuery] = useState("");

useEffect(() => {
AOS.init();
}, []);

return (
AOS.init(); return (
<>
<ScrollToTop />
<Navbar setSearchQuery={setSearchQuery} />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ChatAssistant/ChatAssistant.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from "react";
import Chatbot from "react-chatbot-kit";
import "react-chatbot-kit/build/main.css";
import config from "../ChatBot/config.jsx";
import config from "../ChatBot/config";
import MessageParser from "../ChatBot/MessageParser";
import ActionProvider from "../ChatBot/ActionProvider";
import "./ChatAssistant.css";
Expand Down
Loading

0 comments on commit 4182834

Please sign in to comment.