Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,9 @@ dist
.yarn/install-state.gz
.pnp.*

package-lock.json
# Ignore package-lock.json in all folders
**/package-lock.json
/package-lock.json
/client/package-lock.json
/server/package-lock.json

3 changes: 3 additions & 0 deletions client/src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ function Layout() {
<li>
<Link to="/contact">Contact</Link>
</li>
<li>
<Link to="/weekly-report">Weekly Report</Link>
</li>
</ul>
</nav>
</header>
Expand Down
37 changes: 20 additions & 17 deletions client/src/pages/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ function SignUp() {
const passwordsMatch = password === confirmPassword;

const createUser = async (e) => {
console.log("createUser() called");

e.preventDefault();
try {
const response = await axios.post(
Expand All @@ -60,16 +62,17 @@ function SignUp() {
role,
}
);


console.log("Signup response:", response.data);

// if (response.data && response.data.user) {
// localStorage.setItem("user", JSON.stringify({ user: response.data.user }));
// }

if (role === "student") {
setResponseMessage("Token requested and email sent.");
} else {
setResponseMessage("Account created successfully.");
}

// Reset form after successful submission
setFullName("");
setOuEmail("");
Expand Down Expand Up @@ -306,18 +309,18 @@ function SignUp() {
</div>

{role === "student" && (
<div className="form-group">
<label htmlFor="academicAdvisor">Academic Advisor</label>
<input
type="text"
id="advisor"
value={academicAdvisor}
onChange={(e) => setAcademicAdvisor(e.target.value)}
placeholder="Enter your academic advisor's name"
required
/>
</div>
)}
<div className="form-group">
<label htmlFor="academicAdvisor">Academic Advisor</label>
<input
type="text"
id="advisor"
value={academicAdvisor}
onChange={(e) => setAcademicAdvisor(e.target.value)}
placeholder="Enter your academic advisor's name"
required
/>
</div>
)}

<div className="form-group">
<label>
Expand Down Expand Up @@ -354,4 +357,4 @@ function SignUp() {
);
}

export default SignUp;
export default SignUp;
45 changes: 45 additions & 0 deletions client/src/pages/WeeklyProgressReportForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* WeeklyProgressReportForm.css */

.a2-form-container {
max-width: 700px;
margin: auto;
padding: 2rem;
border: 1px solid #ccc;
background: #f9f9f9;
border-radius: 8px;
}

.form-row {
display: flex;
gap: 1rem;
margin-bottom: 1rem;
justify-content: space-between;
}

.form-row label {
flex: 1;
}

.form-group {
margin-bottom: 1rem;
}

textarea {
width: 100%;
height: 100px;
}

.submit-button {
background: maroon;
color: white;
padding: 0.7rem 1.5rem;
border: none;
border-radius: 6px;
cursor: pointer;
}

.form-message {
margin-top: 1rem;
color: green;
}

132 changes: 132 additions & 0 deletions client/src/pages/WeeklyProgressReportForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@


import React, { useState } from "react";
import axios from "axios";
import "./WeeklyProgressReportForm.css"; // optional: for clean styling

const WeeklyProgressReportForm = () => {
const [formData, setFormData] = useState({
week: "Week 1",
hours: "",
tasks: "",
lessons: "",
supervisorComments: "",
});

const [message, setMessage] = useState("");

const handleChange = (e) => {
const { name, value } = e.target;
setFormData((prev) => ({ ...prev, [name]: value }));
};

const handleSubmit = async (e) => {
e.preventDefault();

// Get the user ID from localStorage (ensure it exists)
// const user = JSON.parse(localStorage.getItem("user"));
// const studentId = user?.user?._id;

// // Check if studentId exists in localStorage
// if (!studentId) {
// setMessage("Student ID not found. Please log in again.");
// return;
// }

// Check that all required fields are filled
if (!formData.week || !formData.hours || !formData.tasks || !formData.lessons) {
setMessage("Please fill in all the fields.");
return;
}

//const payload = { studentId, ...formData };
const payload = { ...formData };

try {
// Sending the form data to the backend
const res = await axios.post(`${process.env.REACT_APP_API_URL}/api/reports`, payload);

// Display success message
setMessage(res.data.message || "Report submitted!");
setFormData({
week: "Week 1",
hours: "",
tasks: "",
lessons: "",
supervisorComments: "",
});
} catch (err) {
console.error(err);
setMessage("Submission failed. Try again.");
}
};


return (
<div className="a2-form-container">
<h2>A.2 - Weekly Progress Report</h2>
<form onSubmit={handleSubmit} className="a2-form">
<div className="form-row">
<label>
Logbook Week:
<select name="week" value={formData.week} onChange={handleChange}>
{Array.from({ length: 15 }, (_, i) => (
<option key={i} value={`Week ${i + 1}`}>
Week {i + 1}
</option>
))}
</select>
</label>
<label>
Number of Hours:
<input
type="number"
name="hours"
value={formData.hours}
onChange={handleChange}
required
placeholder="e.g., 12"
/>
</label>
</div>

<div className="form-group">
<label>Tasks Performed:</label>
<textarea
name="tasks"
value={formData.tasks}
onChange={handleChange}
required
/>
</div>

<div className="form-group">
<label>Lessons Learned:</label>
<textarea
name="lessons"
value={formData.lessons}
onChange={handleChange}
required
/>
</div>

<div className="form-group">
<label>Internship Supervisor Approval & Comments:</label>
<textarea
name="supervisorComments"
value={formData.supervisorComments}
onChange={handleChange}
placeholder="(Optional) If supervisor is filling directly"
/>
</div>

<button type="submit" className="submit-button">
Submit Report
</button>
</form>
{message && <p className="form-message">{message}</p>}
</div>
);
};

export default WeeklyProgressReportForm;
9 changes: 7 additions & 2 deletions client/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Layout from "./components/Layout";
import Home from "./pages/Home";
import SignUp from "./pages/SignUp";
import NotFound from "./pages/NotFound";
import WeeklyProgressReportForm from "./pages/WeeklyProgressReportForm";
import A3JobEvaluationForm from "./pages/A3JobEvaluationForm";
import SupervisorDashboard from "./pages/SupervisorDashboard";
import CoordinatorDashboard from "./pages/CoordinatorDashboard";
Expand All @@ -30,10 +31,14 @@ const router = createBrowserRouter([
path: "signup",
element: <SignUp />,
},
{
path: "weekly-report",
element: <WeeklyProgressReportForm />,
},
{
path: "a1-form",
element: <A1InternshipRequestForm />,
},
},
{
path: "evaluation",
element: <A3JobEvaluationForm />,
Expand All @@ -46,9 +51,9 @@ const router = createBrowserRouter([
path: "coordinator-dashboard",
element: <CoordinatorDashboard />,
},
// Add more routes as needed
],
},
]);


export default router;
2 changes: 1 addition & 1 deletion client/src/utils/emailUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

// Define the API base URL
const API_BASE_URL = process.env.REACT_APP_API_URL || "http://localhost:5000";
const API_BASE_URL = process.env.REACT_APP_API_URL;

/**
* Send an email with custom content
Expand Down
4 changes: 1 addition & 3 deletions server/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
PORT=5001
MONGO_URI=mongodb://localhost:27017/IPMS



# Email Configuration
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
Expand All @@ -13,4 +11,4 @@ EMAIL_PASSWORD=rmrl msnq kflk uimr
EMAIL_DEFAULT_SENDER=sep.ipms.spring2025@gmail.com

# Secret
JWT_SECRET=supersecretkey123
JWT_SECRET=supersecretkey123
Loading