Skip to content
Snippets Groups Projects
Commit eb2ead10 authored by Fatima Ezzahra Majidi's avatar Fatima Ezzahra Majidi
Browse files

Merge branch 'master' into 'main'

Ajout de commantaire

See merge request !11
parents be78b1a1 1f7170fc
No related branches found
No related tags found
1 merge request!11Ajout de commantaire
......@@ -9,8 +9,10 @@ const CandidacyForm = () => {
const [formData, setFormData] = useState({
studentId: "",
stageId: "",
univSupervisorId: "", // Add supervisor field
univSupervisorId: "",
comment: "", // ✅ Ajout du champ comment
});
useEffect(() => {
fetch("http://localhost:8080/api/students")
......@@ -32,23 +34,33 @@ const CandidacyForm = () => {
const handleSubmit = (e) => {
e.preventDefault();
const candidacyData = {
student: { id: formData.studentId },
stage: { id: formData.stageId },
univSupervisor: { id: formData.univSupervisorId },
comment: formData.comment || "Aucun commentaire fourni", // ✅ Ajout du champ commentaire
};
console.log("📌 Sending Candidacy Data:", JSON.stringify(candidacyData, null, 2)); // Debug
fetch("http://localhost:8080/api/candidacies/add", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
student: { id: formData.studentId },
stage: { id: formData.stageId },
univSupervisor: { id: formData.univSupervisorId }, // Include supervisor
}),
credentials: "include",
body: JSON.stringify(candidacyData),
})
.then((res) => res.json())
.then((res) => {
console.log("📌 Response status:", res.status);
return res.json();
})
.then((data) => {
console.log("Candidacy added:", data);
alert("Candidacy added successfully!");
console.log("Candidacy added successfully:", data);
alert("Candidature ajoutée avec succès !");
})
.catch((err) => console.error("Error:", err));
.catch((err) => console.error("Error:", err.message));
};
// Handle cancel button
const handleCancel = () => {
Navigate("/candidatures"); // Redirect back to candidacy list
......@@ -95,6 +107,15 @@ const CandidacyForm = () => {
))}
</select>
</div>
<div className="mb-3">
<label className="form-label">Commentaire:</label>
<textarea
className="form-control"
name="comment"
value={formData.comment}
onChange={handleChange}
/>
</div>
{/* Select UnivSupervisor */}
<div className="mb-3">
......
......@@ -10,6 +10,7 @@ const CandidacyFormPrerempli = () => {
studentId: "",
stageId: stageId || "", // ✅ Pre-fill with stageId from URL
univSupervisorId: "",
comment: "",
});
/** 🔹 Load the logged-in student from localStorage */
......@@ -42,6 +43,7 @@ const CandidacyFormPrerempli = () => {
student: { id: formData.studentId },
stage: { id: formData.stageId },
univSupervisor: { id: formData.univSupervisorId },
comment: formData.comment || "Aucun commentaire fourni",
};
console.log("📌 Sending Candidacy Data:", JSON.stringify(candidacyData, null, 2));
......@@ -89,6 +91,15 @@ const CandidacyFormPrerempli = () => {
disabled
/>
</div>
<div className="mb-3">
<label className="form-label">Commentaire:</label>
<textarea
className="form-control"
name="comment"
value={formData.comment}
onChange={handleChange}
/>
</div>
{/* Select UnivSupervisor */}
<div className="mb-3">
......
......@@ -42,6 +42,7 @@ function CandidacyList() {
<th>Superviseur Universitaire</th>
<th>État de la Demande</th>
<th>Statut Accepté</th>
<th>Commentaire</th>
<th>Actions</th> {/* Added column for buttons */}
</tr>
</thead>
......@@ -54,6 +55,7 @@ function CandidacyList() {
<td>{candidacy.univSupervisor?.name || "Non attribué"}</td>
<td>{candidacy.requestState}</td>
<td>{candidacy.acceptedState}</td>
<td>{candidacy.comment || "Pas de commentaire"}</td>
<td>
<button
......
......@@ -58,7 +58,7 @@ function UpdateCandidacyForm() {
const handleSubmit = (e) => {
e.preventDefault();
fetch(`http://localhost:8080/api/candidacies/${id}`, {
fetch(`http://localhost:8080/api/candidacies/update/${id}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(candidacy),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment