-
Notifications
You must be signed in to change notification settings - Fork 7
Groupe E - Sprint 1 API/UI Done #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c9318ee
Done with sprint 1
Nanvithaa a0c08fd
Resolve conflict merge origin main
HozenDev 99f8d5f
Resolve conflicts Group E
HozenDev 09b3edd
resolve compilation errors
HozenDev 946eb76
Resolve files deleted and modified for nothing
HozenDev 71a01f6
Resolve files not updated
HozenDev 5f9a083
change bad User schema for our work
HozenDev cca982e
Use Home instead of SignIn page
HozenDev 4b952c5
Better Supervisor UI, Remove unused files
HozenDev 9cd0d30
Changed made
MRPHFitch 299fb71
Changes made
MRPHFitch 01d96cf
A3 form change
Charan-Nimmagadda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import React from "react"; | ||
|
|
||
| const CoordinatorDashboard = () => { | ||
| return ( | ||
| <div style={{ padding: "20px", textAlign: "center" }}> | ||
| <h2>Coordinator Dashboard</h2> | ||
| <p>Welcome, Coordinator!</p> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default CoordinatorDashboard; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import React, { useEffect, useState, useCallback } from "react"; | ||
| import axios from "axios"; | ||
| import '../styles/SupervisorDashboard.css'; | ||
|
|
||
| const SupervisorDashboard = () => { | ||
| const [submissions, setSubmissions] = useState([]); | ||
| const url = process.env.REACT_APP_API_URL | ||
|
|
||
| const fetchPendingSubmissions = useCallback(async () => { | ||
| try { | ||
| const response = await axios.get(url + "/api/submissions/pending"); | ||
| setSubmissions(response.data); | ||
| } catch (err) { | ||
| console.error("Error fetching submissions:", err); | ||
| } | ||
| }, [url]); | ||
|
|
||
| useEffect(() => { | ||
| fetchPendingSubmissions(); | ||
| }, [fetchPendingSubmissions]); | ||
|
|
||
|
|
||
| const handleDecision = async (id, action) => { | ||
| try { | ||
| const endpoint = url + `/api/submissions/${id}/${action}`; | ||
| await axios.post(endpoint); | ||
| alert(`Submission ${action}d successfully!`); | ||
| fetchPendingSubmissions(); // refresh list | ||
| } catch (err) { | ||
| console.error("Error updating submission:", err); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="dashboard-container"> | ||
| <h1 className="dashboard-title">Supervisor Dashboard</h1> | ||
| <h2>Pending Approvals</h2> | ||
| <ul className="pending-approvals"> | ||
| {submissions.length === 0 ? ( | ||
| <div className="empty-message-container"> | ||
| <div className="empty-message">No pending approvals at this time.</div> | ||
| </div> | ||
| ) : ( | ||
| submissions.map(item => ( | ||
| <li key={item._id}> | ||
| {item.name} - Details: {item.details} - Status: {item.supervisor_status} | ||
| <div> | ||
| <button className="approve" onClick={() => handleDecision(item._id, "approve")}>Approve</button> | ||
| <button className="reject" onClick={() => handleDecision(item._id, "reject")}>Reject</button> | ||
| </div> | ||
| </li> | ||
| )) | ||
| )} | ||
| </ul> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SupervisorDashboard; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| .dashboard-container { | ||
| padding: 20px; | ||
| background-color: #f9f9f9; | ||
| border-radius: 8px; | ||
| box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); | ||
| } | ||
|
|
||
| .dashboard-container h2 { | ||
| font-size: 20px; | ||
| margin-bottom: 20px; | ||
| color: #333; | ||
| } | ||
|
|
||
| .dashboard-title { | ||
| font-size: 24px; | ||
| margin-bottom: 20px; | ||
| color: #333; | ||
| } | ||
|
|
||
| .pending-approvals { | ||
| list-style-type: none; | ||
| padding: 0; | ||
| } | ||
|
|
||
| .pending-approvals li { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| padding: 20px; | ||
| margin: 40px 0; | ||
| background-color: #fff; | ||
| border-radius: 5px; | ||
| box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); | ||
| font-size: 16px; | ||
| } | ||
|
|
||
| .pending-approvals li button { | ||
| margin-left: 10px; | ||
| padding: 5px 10px; | ||
| border: none; | ||
| border-radius: 5px; | ||
| cursor: pointer; | ||
| transition: background-color 0.3s; | ||
| } | ||
|
|
||
| .approve{ | ||
| background-color: #28a745; /* Green background for approve button */ | ||
| color: white; | ||
| } | ||
|
|
||
| .reject{ | ||
| background-color: #dc3545; /* Red background for reject button */ | ||
| color: white; | ||
| } | ||
|
|
||
| .approve:hover { | ||
| background-color: #218838; | ||
| } | ||
|
|
||
| .reject:hover{ | ||
| background-color: #c82333; | ||
| } | ||
|
|
||
| .pending-approvals li button:focus { | ||
| outline: none; | ||
| } | ||
|
|
||
| .empty-message-container{ | ||
| display: flex; /* Use flexbox */ | ||
| justify-content: center; /* Center horizontally */ | ||
| align-items: center; /* Center vertically */ | ||
| height: 20vh; | ||
| } | ||
| .empty-message { | ||
| font-size: 28px; /* Adjust font size */ | ||
| color: #000000; /* Change text color for better visibility */ | ||
| text-align: center; /*Center the message*/ | ||
| margin: 20px 0; /* Add some margin for spacing */ | ||
| font-weight: bold; /* Make the message bold */ | ||
| } | ||
|
|
||
| form { | ||
| margin-bottom: 5px; | ||
| } | ||
|
|
||
| form input, | ||
| form textarea { | ||
| width: 100%; | ||
| padding: 10px; | ||
| margin: 5px 0; | ||
| border: 1px solid #ccc; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| form button { | ||
| padding: 10px 15px; | ||
| background-color: #007bff; | ||
| color: white; | ||
| border: none; | ||
| border-radius: 5px; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| form button:hover { | ||
| background-color: #0056b3; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| const Submission = require("../models/Submission"); | ||
|
|
||
| // ✅ Get pending submissions for supervisor | ||
| exports.getPendingSubmissions = async (req, res) => { | ||
| try { | ||
| const submissions = await Submission.find({ supervisor_status: "pending" }); | ||
| res.json(submissions); | ||
| } catch (err) { | ||
| res.status(500).json({ message: "Failed to fetch pending submissions", error: err }); | ||
| } | ||
| }; | ||
|
|
||
| // ✅ Supervisor Approves | ||
| exports.approveSubmission = async (req, res) => { | ||
| const { id } = req.params; | ||
|
|
||
| try { | ||
| const submission = await Submission.findByIdAndUpdate( | ||
| id, | ||
| { supervisor_status: "Approved" }, | ||
| { new: true } | ||
| ); | ||
|
|
||
| if (!submission) { | ||
| return res.status(404).json({ message: "Submission not found" }); | ||
| } | ||
|
|
||
| res.json({ | ||
| message: "Submission approved and forwarded to Coordinator", | ||
| updatedSubmission: submission | ||
| }); | ||
|
|
||
| } catch (err) { | ||
| res.status(500).json({ message: "Approval failed", error: err }); | ||
| } | ||
| }; | ||
|
|
||
| // ❌ Supervisor Rejects | ||
| exports.rejectSubmission = async (req, res) => { | ||
| const { id } = req.params; | ||
|
|
||
| try { | ||
| const submission = await Submission.findByIdAndUpdate( | ||
| id, | ||
| { supervisor_status: "Rejected" }, | ||
| { new: true } | ||
| ); | ||
|
|
||
| if (!submission) { | ||
| return res.status(404).json({ message: "Submission not found" }); | ||
| } | ||
|
|
||
| res.json({ | ||
| message: "Submission rejected", | ||
| updatedSubmission: submission | ||
| }); | ||
|
|
||
| } catch (err) { | ||
| res.status(500).json({ message: "Rejection failed", error: err }); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| exports.isSupervisor = (req, res, next) => { | ||
| // const supervisor = Sup.find({$id: username}) | ||
|
|
||
|
|
||
| req.user = { role: 'supervisor' }; // Mocking user role for demo | ||
| if (req.user.role === "supervisor") { | ||
| next(); | ||
| } else { | ||
| res.status(403).json({ message: "Access denied. Not a supervisor." }); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| const mongoose = require("mongoose"); | ||
|
|
||
| const submissionSchema = new mongoose.Schema({ | ||
| name: { type: String, required: true }, | ||
| student_name: { type: String, required: true }, | ||
| details: { type: String, required: true }, | ||
| supervisor_status: { type: String, default: "pending" }, | ||
| supervisor_comment: { type: String }, | ||
| coordinator_status: { type: String, default: "pending" }, | ||
| coordinator_comment: { type: String }, | ||
| }, { timestamps: true }); | ||
|
|
||
| module.exports = mongoose.model("Submission", submissionSchema); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| const express = require("express"); | ||
| const router = express.Router(); | ||
| const { getPendingSubmissions, approveSubmission, rejectSubmission } = require("../controllers/approvalController"); | ||
| const { isSupervisor } = require("../middleware/authMiddleware"); | ||
|
|
||
| router.get("/submissions/pending", isSupervisor, getPendingSubmissions); | ||
| router.post("/submissions/:id/approve", isSupervisor, approveSubmission); | ||
| router.post("/submissions/:id/reject", isSupervisor, rejectSubmission); | ||
|
|
||
| module.exports = router; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.