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