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

amélioration

parent b843bd7f
No related branches found
No related tags found
1 merge request!6amélioration des liens entre back et front suite à un changement back
......@@ -84,9 +84,9 @@ function Navbar() {
</a>
<ul className="dropdown-menu" aria-labelledby="entreprisesDropdown">
<li><Link className="dropdown-item" to="/entreprises">📜 Liste des Entreprises</Link></li>
{(hasRole("ROLE_ENTREPRISE") || hasRole("ROLE_ADMIN")) && (
<li><Link className="dropdown-item" to="/ajouter-entreprise">➕ Ajouter/Modifier une Entreprise</Link></li>
)}
</ul>
</li>
)}
......
......@@ -34,10 +34,11 @@ function StageForm() {
}
const newStage = {
title,
name: title, // ✅ Change from "" to title
description,
enterprise: { id: parseInt(enterpriseId, 10) }, // Send enterprise as an object
enterprise: { id: parseInt(enterpriseId, 10) }, // Keep this as it is
};
console.log("📌 Sending stage data:", newStage);
......
......@@ -12,15 +12,18 @@ function StageList() {
const fetchStages = () => {
fetch("http://localhost:8080/api/stages")
.then((response) => response.json())
.then((data) => setStages(data))
.catch((error) => console.error("Error fetching stages:", error));
.then((response) => response.json())
.then((data) => {
console.log("📌 Stages loaded:", data); // ✅ Debugging Log
setStages(data);
})
.catch((error) => console.error("Error fetching stages:", error));
};
// Handle Delete
const handleDelete = (id) => {
if (window.confirm("Voulez-vous vraiment supprimer ce stage ?")) {
fetch(`http://localhost:8080/api/stages/${id}`, {
fetch(`http://localhost:8080/api/stages/delete/${id}`, {
method: "DELETE",
})
.then(() => {
......
......@@ -38,16 +38,17 @@ function UpdateStageForm() {
const handleSubmit = (e) => {
e.preventDefault();
fetch(`http://localhost:8080/api/stages/${id}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(stage),
fetch(`http://localhost:8080/api/stages/${id}`)
.then((res) => res.json())
.then((data) => {
console.log("📌 Loaded stage:", data); // ✅ Debugging Log
setStage({
name: data.name || "", // ✅ Ensure name is stored
description: data.description || "",
enterprise: data.enterprise || null
});
})
.then(() => {
alert("Stage mis à jour !");
navigate("/stages");
})
.catch((err) => console.error("Erreur:", err));
.catch((err) => console.error("Erreur:", err));
};
return (
......
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