From 1d13332b75e03508ad6ac4cfaee879d98230b917 Mon Sep 17 00:00:00 2001 From: Hepsox Date: Wed, 24 Jan 2024 17:15:39 +0100 Subject: [PATCH 1/9] Update user profile and experience/formation forms --- frontend/src/main.jsx | 2 +- frontend/src/pages/Experience/AddExperience.jsx | 6 +++--- frontend/src/pages/Formation/AddFormation.jsx | 9 +++------ frontend/src/pages/ProfileUser/UserProfileModel.jsx | 11 +---------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index 83739d1..488858b 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -82,7 +82,7 @@ const router = createBrowserRouter([ try { // D'abord, on va chercher le CV de l'utilisateur, ce qui nous intéresse est l'id du CV const cvData = await apiService.get( - `${import.meta.env.VITE_BACKEND_URL}/api/users/6/cvs` // TODO: remplacer le 5 par l'id de l'utilisateur connecté + `${import.meta.env.VITE_BACKEND_URL}/api/users/1/cvs` // TODO: remplacer le 5 par l'id de l'utilisateur connecté ); // Ensuite, on va chercher les expériences de l'utilisateur via l'id du CV qu'on vient de récupérer diff --git a/frontend/src/pages/Experience/AddExperience.jsx b/frontend/src/pages/Experience/AddExperience.jsx index 933cf48..48fa8a8 100644 --- a/frontend/src/pages/Experience/AddExperience.jsx +++ b/frontend/src/pages/Experience/AddExperience.jsx @@ -201,10 +201,10 @@ function AddExperience() { )} - + - - {/* */} ); diff --git a/frontend/src/pages/Formation/AddFormation.jsx b/frontend/src/pages/Formation/AddFormation.jsx index 9f0b3eb..142ba1c 100644 --- a/frontend/src/pages/Formation/AddFormation.jsx +++ b/frontend/src/pages/Formation/AddFormation.jsx @@ -1,6 +1,5 @@ import { useState, useEffect } from "react"; import { v4 as uuid } from "uuid"; -import ButtonMaxi from "../../components/Boutons/ButtonMaxi"; import Date from "../../components/Inputs/Date"; import Input from "../../components/Inputs/Input"; import Select from "../../components/Inputs/Select"; @@ -166,12 +165,10 @@ function AddFormation() { )} - + - ); diff --git a/frontend/src/pages/ProfileUser/UserProfileModel.jsx b/frontend/src/pages/ProfileUser/UserProfileModel.jsx index d0940bc..6f75dc9 100644 --- a/frontend/src/pages/ProfileUser/UserProfileModel.jsx +++ b/frontend/src/pages/ProfileUser/UserProfileModel.jsx @@ -16,16 +16,7 @@ import AddDetailsCV from "../../components/Add Something/AddSomething"; function UserProfileModel() { const { handleAddCv } = useUserContext(); - // const { - // errorMsg, - // succesMsg, - // msgContent, - // apiService, - // setSuccesMsg, - // setMsgContent, - // setErrorMsg, - // handleChange, - // } = useGlobalContext(); + const globalContext = useGlobalContext(); const navigate = useNavigate(); const [getSkills, setGetSkills] = useState([]); From 7bbf28e656861f6f4703cb7c82d376900577ff24 Mon Sep 17 00:00:00 2001 From: Hepsox Date: Wed, 24 Jan 2024 17:20:33 +0100 Subject: [PATCH 2/9] Remove commented code and update submit button text --- frontend/src/pages/Connexion/SignIn.jsx | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/frontend/src/pages/Connexion/SignIn.jsx b/frontend/src/pages/Connexion/SignIn.jsx index b222cfc..6d32f91 100644 --- a/frontend/src/pages/Connexion/SignIn.jsx +++ b/frontend/src/pages/Connexion/SignIn.jsx @@ -4,7 +4,6 @@ import Input from "../../components/Inputs/Input"; import CheckboxCondition from "../../components/Inputs/CheckboxCondition"; import CompetenceSwitch from "../../components/Competence Switch/CompetenceSwitch"; import HeaderLongTitle from "../../components/Headers/HeaderLongTitle"; -// import ButtonMaxi from "../../components/Boutons/ButtonMaxi"; import ErrorMsg from "../../components/Alertes Messages/ErrorMsg"; import AddSomething from "../../components/Add Something/AddSomething"; import Title from "../../components/Titles/Title"; @@ -263,15 +262,7 @@ function SignIn() { globalContext.handleCheckboxChange(setSignIn, "cguAgree") } /> - {/* Externatic */} - - globalContext.handleCheckboxChange(setSignIn, "addCvNow") - } - /> +
{globalContext.errorMsg && ( @@ -280,10 +271,13 @@ function SignIn() { )}
- - {/* */}
From a3c269f5a240458933157758e4c2ad6b958b87cb Mon Sep 17 00:00:00 2001 From: Hepsox Date: Wed, 24 Jan 2024 17:22:49 +0100 Subject: [PATCH 3/9] Remove unused component and update checkbox label --- frontend/src/pages/Connexion/SignIn.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/pages/Connexion/SignIn.jsx b/frontend/src/pages/Connexion/SignIn.jsx index 6d32f91..a44a976 100644 --- a/frontend/src/pages/Connexion/SignIn.jsx +++ b/frontend/src/pages/Connexion/SignIn.jsx @@ -5,7 +5,6 @@ import CheckboxCondition from "../../components/Inputs/CheckboxCondition"; import CompetenceSwitch from "../../components/Competence Switch/CompetenceSwitch"; import HeaderLongTitle from "../../components/Headers/HeaderLongTitle"; import ErrorMsg from "../../components/Alertes Messages/ErrorMsg"; -import AddSomething from "../../components/Add Something/AddSomething"; import Title from "../../components/Titles/Title"; import SuccesMsg from "../../components/Alertes Messages/SuccesMsg"; import { useGlobalContext } from "../../contexts/GlobalContext"; @@ -251,7 +250,6 @@ function SignIn() { globalContext.handleCheckboxChange(setSkills, "trello") } /> -
Date: Wed, 24 Jan 2024 19:16:20 +0100 Subject: [PATCH 4/9] Refactor user profile model and card formation components --- .../components/CardModel/CardFormation.jsx | 3 +- frontend/src/main.jsx | 54 +++++++++---------- .../pages/ProfileUser/UserProfileModel.jsx | 38 ++++++++++++- 3 files changed, 64 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/CardModel/CardFormation.jsx b/frontend/src/components/CardModel/CardFormation.jsx index 6fd830c..2c76c09 100644 --- a/frontend/src/components/CardModel/CardFormation.jsx +++ b/frontend/src/components/CardModel/CardFormation.jsx @@ -42,8 +42,7 @@ function CardFormation({ {formattedDateBegin} au {formattedDateEnd}

- {level} - {domaine} + {level} {domaine}

{name}

diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index 488858b..b5bc21e 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -78,35 +78,35 @@ const router = createBrowserRouter([ }, { path: "/edit-profile", - loader: async () => { - try { - // D'abord, on va chercher le CV de l'utilisateur, ce qui nous intéresse est l'id du CV - const cvData = await apiService.get( - `${import.meta.env.VITE_BACKEND_URL}/api/users/1/cvs` // TODO: remplacer le 5 par l'id de l'utilisateur connecté - ); + // loader: async () => { + // try { + // // D'abord, on va chercher le CV de l'utilisateur, ce qui nous intéresse est l'id du CV + // const cvData = await apiService.get( + // `${import.meta.env.VITE_BACKEND_URL}/api/users/1/cvs` // TODO: remplacer le 5 par l'id de l'utilisateur connecté + // ); - // Ensuite, on va chercher les expériences de l'utilisateur via l'id du CV qu'on vient de récupérer - // le but est de pouvoir faire SELECT * FROM experiences WHERE cv_id = cvData.data.id - const experienceData = await apiService.get( - `${import.meta.env.VITE_BACKEND_URL}/api/experiences/by-cv-id/${ - cvData.data.id - }` - ); - const courseData = await apiService.get( - `${import.meta.env.VITE_BACKEND_URL}/api/courses/by-cv-id/${ - cvData.data.id - }` - ); + // // Ensuite, on va chercher les expériences de l'utilisateur via l'id du CV qu'on vient de récupérer + // // le but est de pouvoir faire SELECT * FROM experiences WHERE cv_id = cvData.data.id + // const experienceData = await apiService.get( + // `${import.meta.env.VITE_BACKEND_URL}/api/experiences/by-cv-id/${ + // cvData.data.id + // }` + // ); + // const courseData = await apiService.get( + // `${import.meta.env.VITE_BACKEND_URL}/api/courses/by-cv-id/${ + // cvData.data.id + // }` + // ); - return { - experiences: experienceData.data, - courses: courseData.data, - }; - } catch (err) { - console.error(err.message); - return null; - } - }, + // return { + // experiences: experienceData.data, + // courses: courseData.data, + // }; + // } catch (err) { + // console.error(err.message); + // return null; + // } + // }, element: ( diff --git a/frontend/src/pages/ProfileUser/UserProfileModel.jsx b/frontend/src/pages/ProfileUser/UserProfileModel.jsx index 6f75dc9..6948dc1 100644 --- a/frontend/src/pages/ProfileUser/UserProfileModel.jsx +++ b/frontend/src/pages/ProfileUser/UserProfileModel.jsx @@ -1,4 +1,4 @@ -import { Outlet, useLoaderData, useNavigate } from "react-router-dom"; +import { Outlet, useNavigate } from "react-router-dom"; import { useEffect, useState } from "react"; import "./user-profile-model.css"; import Input from "../../components/Inputs/Input"; @@ -22,7 +22,12 @@ function UserProfileModel() { const [getSkills, setGetSkills] = useState([]); const [getProfile, setGetProfile] = useState({}); - const { experiences, courses } = useLoaderData(); + + const { user, apiService } = useGlobalContext(); + + const [experiences, setExperiences] = useState([]); + const [courses, setCourses] = useState([]); + // const { experiences, courses } = useLoaderData(); const handleExperienceDelete = async (id) => { if (!window.confirm("Voulez-vous vraiment supprimer cette expérience ?")) { @@ -73,6 +78,8 @@ function UserProfileModel() { }; useEffect(() => { + let cvId = null; + const getUserProfile = async () => { try { const response = await globalContext.apiService.get( @@ -94,8 +101,35 @@ function UserProfileModel() { console.error(err); } }; + + const fetchExperiences = async () => { + const experienceData = await apiService.get( + `${import.meta.env.VITE_BACKEND_URL}/api/experiences/by-cv-id/${cvId}` + ); + setExperiences(experienceData.data); + }; + + const fetchCourses = async () => { + const courseData = await apiService.get( + `${import.meta.env.VITE_BACKEND_URL}/api/courses/by-cv-id/${cvId}` + ); + setCourses(courseData.data); + }; + + const fetchCvId = async () => { + const cvData = await apiService.get( + `${import.meta.env.VITE_BACKEND_URL}/api/users/${user.id}/cvs` + ); + + cvId = cvData.data.id; + + fetchExperiences(); + fetchCourses(); + }; + getSkillsProfile(); getUserProfile(); + fetchCvId(); }, []); const handleCheckboxChanged = async (fieldName) => { From e11501f2e4467077e30090daeacd56d0bc861919 Mon Sep 17 00:00:00 2001 From: Hepsox Date: Wed, 24 Jan 2024 19:17:14 +0100 Subject: [PATCH 5/9] Remove commented out code in main.jsx --- frontend/src/main.jsx | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index b5bc21e..233f94a 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -78,35 +78,6 @@ const router = createBrowserRouter([ }, { path: "/edit-profile", - // loader: async () => { - // try { - // // D'abord, on va chercher le CV de l'utilisateur, ce qui nous intéresse est l'id du CV - // const cvData = await apiService.get( - // `${import.meta.env.VITE_BACKEND_URL}/api/users/1/cvs` // TODO: remplacer le 5 par l'id de l'utilisateur connecté - // ); - - // // Ensuite, on va chercher les expériences de l'utilisateur via l'id du CV qu'on vient de récupérer - // // le but est de pouvoir faire SELECT * FROM experiences WHERE cv_id = cvData.data.id - // const experienceData = await apiService.get( - // `${import.meta.env.VITE_BACKEND_URL}/api/experiences/by-cv-id/${ - // cvData.data.id - // }` - // ); - // const courseData = await apiService.get( - // `${import.meta.env.VITE_BACKEND_URL}/api/courses/by-cv-id/${ - // cvData.data.id - // }` - // ); - - // return { - // experiences: experienceData.data, - // courses: courseData.data, - // }; - // } catch (err) { - // console.error(err.message); - // return null; - // } - // }, element: ( From 83014f939784827f32e65a19c39d707c635e161e Mon Sep 17 00:00:00 2001 From: Hepsox Date: Wed, 24 Jan 2024 19:40:19 +0100 Subject: [PATCH 6/9] Message d'erreur si identifiants incorrects + refactor logContext --- frontend/src/contexts/LogContext.jsx | 39 ++++++++++++---------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/frontend/src/contexts/LogContext.jsx b/frontend/src/contexts/LogContext.jsx index 7b54f3e..aea55ac 100644 --- a/frontend/src/contexts/LogContext.jsx +++ b/frontend/src/contexts/LogContext.jsx @@ -5,16 +5,7 @@ import { useGlobalContext } from "./GlobalContext"; const LogContext = createContext(); function LogContextProvider({ children }) { - // Messages d'alertes. - const { - apiService, - setUser, - setSuccesMsg, - setMsgContent, - navigate, - setIsAdmin, - user, - } = useGlobalContext(); + const globalContext = useGlobalContext(); const [userConnected, setUserConnected] = useState(false); @@ -29,36 +20,40 @@ function LogContextProvider({ children }) { }; const handleSubmitLogIn = async () => { try { - const data = await apiService.post( + const data = await globalContext.apiService.post( `${import.meta.env.VITE_BACKEND_URL}/api/login`, logIn ); localStorage.setItem("token", data.token); - apiService.setToken(data.token); + globalContext.apiService.setToken(data.token); - const result = await apiService.get( + const result = await globalContext.apiService.get( `${import.meta.env.VITE_BACKEND_URL}/api/users/me` ); // alert(`Content de vous revoir ${result.data.email}`); // console.log(isAdmin); - setUser(result.data); - setIsAdmin(result.data.is_admin); - setMsgContent( - `Content de vous revoir ${user.firstname} ${user.lastname}! Connexion effectuée avec` + globalContext.setUser(result.data); + globalContext.setIsAdmin(result.data.is_admin); + globalContext.setMsgContent( + `Content de vous revoir ${globalContext.user.firstname} ${globalContext.user.lastname}! Connexion effectuée avec` ); - setSuccesMsg(true); + globalContext.setSuccesMsg(true); setTimeout(() => { - setSuccesMsg(false); + globalContext.setSuccesMsg(false); if (result.data.is_admin === 1) { - navigate("/dashboard"); + globalContext.navigate("/dashboard"); } - navigate("/"); + globalContext.navigate("/"); }, 2000); } catch (err) { console.error(err); - // alert(err.message); + globalContext.setMsgContent(`Mot de passe ou identifiant incorrect`); + globalContext.setErrorMsg(true); + setTimeout(() => { + globalContext.setErrorMsg(false); + }, 2000); } return null; From 38ea02873ccd21498bcd2f1841fbc092546498dd Mon Sep 17 00:00:00 2001 From: Hepsox Date: Wed, 24 Jan 2024 19:50:47 +0100 Subject: [PATCH 7/9] Update CSS and button text --- frontend/src/components/Inputs/input-search.css | 2 +- frontend/src/pages/Experience/AddExperience.jsx | 2 +- frontend/src/pages/Formation/AddFormation.jsx | 2 +- frontend/src/pages/HomeOffer/Home.jsx | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Inputs/input-search.css b/frontend/src/components/Inputs/input-search.css index c28f0fe..861dad4 100644 --- a/frontend/src/components/Inputs/input-search.css +++ b/frontend/src/components/Inputs/input-search.css @@ -11,7 +11,7 @@ font-size: 16px; font-weight: 500; width: 80%; - margin-top: 10px; + margin-top: 30px; margin-left: 20px; } .background-search input { diff --git a/frontend/src/pages/Experience/AddExperience.jsx b/frontend/src/pages/Experience/AddExperience.jsx index 48fa8a8..027171a 100644 --- a/frontend/src/pages/Experience/AddExperience.jsx +++ b/frontend/src/pages/Experience/AddExperience.jsx @@ -202,7 +202,7 @@ function AddExperience() { diff --git a/frontend/src/pages/Formation/AddFormation.jsx b/frontend/src/pages/Formation/AddFormation.jsx index 142ba1c..96442d2 100644 --- a/frontend/src/pages/Formation/AddFormation.jsx +++ b/frontend/src/pages/Formation/AddFormation.jsx @@ -166,7 +166,7 @@ function AddFormation() { )} diff --git a/frontend/src/pages/HomeOffer/Home.jsx b/frontend/src/pages/HomeOffer/Home.jsx index 943e01d..07b56c9 100644 --- a/frontend/src/pages/HomeOffer/Home.jsx +++ b/frontend/src/pages/HomeOffer/Home.jsx @@ -46,7 +46,11 @@ function Home() { return (
- +

Les offres qui matchent !

From c147a5fd32d568b7b0adc12117e87aaf4af6fc18 Mon Sep 17 00:00:00 2001 From: Hepsox Date: Wed, 24 Jan 2024 20:00:45 +0100 Subject: [PATCH 8/9] Refactor code and remove commented out lines --- frontend/src/components/Boutons/ButtonMaxi.jsx | 4 ---- frontend/src/components/CardModel/CardExperience.jsx | 1 - frontend/src/components/CardModel/CardFormation.jsx | 2 -- frontend/src/components/Headers/MenuBurger.jsx | 0 frontend/src/components/Headers/menu-burger.css | 0 frontend/src/contexts/LogContext.jsx | 2 +- frontend/src/main.jsx | 1 - frontend/src/pages/Connexion/SignIn.jsx | 2 +- frontend/src/pages/Experience/AddExperience.jsx | 10 ---------- frontend/src/pages/Formation/AddFormation.jsx | 9 --------- frontend/src/pages/HomeOffer/Home.jsx | 2 -- frontend/src/pages/Offer/EditOffer.jsx | 3 --- frontend/src/pages/Offer/ReadOffer.jsx | 2 -- 13 files changed, 2 insertions(+), 36 deletions(-) delete mode 100644 frontend/src/components/Headers/MenuBurger.jsx delete mode 100644 frontend/src/components/Headers/menu-burger.css diff --git a/frontend/src/components/Boutons/ButtonMaxi.jsx b/frontend/src/components/Boutons/ButtonMaxi.jsx index 28bd400..cafe814 100644 --- a/frontend/src/components/Boutons/ButtonMaxi.jsx +++ b/frontend/src/components/Boutons/ButtonMaxi.jsx @@ -14,9 +14,5 @@ ButtonMaxi.propTypes = { textBtn: PropTypes.string.isRequired, clickFunc: PropTypes.func.isRequired, }; -// ButtonMaxi.defaultProps = { -// textBtn: "Enregistrer", -// clickFunc: () => {}, -// }; export default ButtonMaxi; diff --git a/frontend/src/components/CardModel/CardExperience.jsx b/frontend/src/components/CardModel/CardExperience.jsx index d83f651..cc3ec4c 100644 --- a/frontend/src/components/CardModel/CardExperience.jsx +++ b/frontend/src/components/CardModel/CardExperience.jsx @@ -24,7 +24,6 @@ function CardExperience({ const dateBeginObject = new Date(dateBegin); const dateEndObject = new Date(dateEnd); - // Formater les dates selon le modèle souhaité const formattedDateBegin = format(dateBeginObject, "dd/MM/yyyy"); const formattedDateEnd = format(dateEndObject, "dd/MM/yyyy"); return ( diff --git a/frontend/src/components/CardModel/CardFormation.jsx b/frontend/src/components/CardModel/CardFormation.jsx index 2c76c09..e0a0cb5 100644 --- a/frontend/src/components/CardModel/CardFormation.jsx +++ b/frontend/src/components/CardModel/CardFormation.jsx @@ -13,8 +13,6 @@ function CardFormation({ }) { const dateBeginObject = dateBegin ? new Date(dateBegin) : null; const dateEndObject = dateEnd ? new Date(dateEnd) : null; - - // Formater les dates selon le modèle souhaité const formattedDateBegin = dateBeginObject ? format(dateBeginObject, "dd/MM/yyyy") : "Date début invalide"; diff --git a/frontend/src/components/Headers/MenuBurger.jsx b/frontend/src/components/Headers/MenuBurger.jsx deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/src/components/Headers/menu-burger.css b/frontend/src/components/Headers/menu-burger.css deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/src/contexts/LogContext.jsx b/frontend/src/contexts/LogContext.jsx index aea55ac..a54e13b 100644 --- a/frontend/src/contexts/LogContext.jsx +++ b/frontend/src/contexts/LogContext.jsx @@ -37,7 +37,7 @@ function LogContextProvider({ children }) { globalContext.setUser(result.data); globalContext.setIsAdmin(result.data.is_admin); globalContext.setMsgContent( - `Content de vous revoir ${globalContext.user.firstname} ${globalContext.user.lastname}! Connexion effectuée avec` + `Content de vous revoir ${result.data.firstname} ${result.data.lastname}! Connexion effectuée avec` ); globalContext.setSuccesMsg(true); setTimeout(() => { diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index 233f94a..93ff992 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -30,7 +30,6 @@ import "mdb-react-ui-kit/dist/css/mdb.min.css"; import currentUserProfileLoader from "./loaders/current-user-profil.loader"; const apiService = new ApiService(); -// const navigate = useNavigate(); const router = createBrowserRouter([ { diff --git a/frontend/src/pages/Connexion/SignIn.jsx b/frontend/src/pages/Connexion/SignIn.jsx index a44a976..99fdf7d 100644 --- a/frontend/src/pages/Connexion/SignIn.jsx +++ b/frontend/src/pages/Connexion/SignIn.jsx @@ -282,7 +282,7 @@ function SignIn() {

Vous avez déjà un compte ? - Connectez-vous + Connectez-vous

diff --git a/frontend/src/pages/Experience/AddExperience.jsx b/frontend/src/pages/Experience/AddExperience.jsx index 027171a..7eea933 100644 --- a/frontend/src/pages/Experience/AddExperience.jsx +++ b/frontend/src/pages/Experience/AddExperience.jsx @@ -1,7 +1,6 @@ import { useState, useEffect } from "react"; import { v4 as uuid } from "uuid"; import "./add-experience.css"; -// import ButtonMaxi from "../../components/Boutons/ButtonMaxi"; import Input from "../../components/Inputs/Input"; import Select from "../../components/Inputs/Select"; import CheckboxCondition from "../../components/Inputs/CheckboxCondition"; @@ -48,7 +47,6 @@ function AddExperience() { } else if (addXp.isWorking === false && addXp.dateBegin === "") { addXp.dateBegin = "1970-01-01"; - // Affichage d'un message d'erreur globalContext.setErrorMsg(true); globalContext.setMsgContent("Veuillez renseigner les dates"); setTimeout(() => { @@ -71,14 +69,6 @@ function AddExperience() { ); const cvId = data.id; - // const personne = { - // prenom: "Marie", - // nom: "Delaire", - // }; - // personne.prenom = "Mariiiiiiie"; - // console.log(personne); - - // peut etre que ca fait un bug, chépa tro addXp.cvId = cvId; await globalContext.apiService.post( diff --git a/frontend/src/pages/Formation/AddFormation.jsx b/frontend/src/pages/Formation/AddFormation.jsx index 96442d2..833ce3d 100644 --- a/frontend/src/pages/Formation/AddFormation.jsx +++ b/frontend/src/pages/Formation/AddFormation.jsx @@ -60,15 +60,6 @@ function AddFormation() { }/cvs` ); const cvId = data.id; - - // const personne = { - // prenom: "Marie", - // nom: "Delaire", - // }; - // personne.prenom = "Mariiiiiiie"; - // console.log(personne); - - // peut etre que ca fait un bug, chépa tro addCourse.cvId = cvId; await globalContext.apiService.post( diff --git a/frontend/src/pages/HomeOffer/Home.jsx b/frontend/src/pages/HomeOffer/Home.jsx index 07b56c9..1f20bd9 100644 --- a/frontend/src/pages/HomeOffer/Home.jsx +++ b/frontend/src/pages/HomeOffer/Home.jsx @@ -1,11 +1,9 @@ import React, { useState, useEffect } from "react"; -// import CardOffre from "../../components/CardModel/CardOffre"; import HeaderLongResearch from "../../components/Headers/HeaderLongResearch"; import { useGlobalContext } from "../../contexts/GlobalContext"; import "./Home.css"; import CardOffre from "../../components/CardModel/CardOffre"; import { useUserContext } from "../../contexts/UserContext"; -// import axios from "axios"; function Home() { const { goToOffer } = useGlobalContext(); diff --git a/frontend/src/pages/Offer/EditOffer.jsx b/frontend/src/pages/Offer/EditOffer.jsx index d54ed6f..638a191 100644 --- a/frontend/src/pages/Offer/EditOffer.jsx +++ b/frontend/src/pages/Offer/EditOffer.jsx @@ -66,9 +66,6 @@ function AddOffer() { }; updateOffer(); - - // console.log(addOffer); - globalContext.setMsgContent("L'offre à été ajouté avec"); globalContext.setSuccesMsg(true); setTimeout(() => { diff --git a/frontend/src/pages/Offer/ReadOffer.jsx b/frontend/src/pages/Offer/ReadOffer.jsx index 2b12bec..43f1002 100644 --- a/frontend/src/pages/Offer/ReadOffer.jsx +++ b/frontend/src/pages/Offer/ReadOffer.jsx @@ -1,9 +1,7 @@ import React, { useState, useEffect } from "react"; import { useParams } from "react-router-dom"; -// import axios from "axios"; import HeaderCourt from "../../components/Headers/HeaderCourt"; import ButtonMaxi from "../../components/Boutons/ButtonMaxi"; -// Import du style. import "./read-offer.css"; function ReadOffer() { From 1e800e1034f759927d8587b06238db234a6bec4f Mon Sep 17 00:00:00 2001 From: cassiopeelaurie Date: Wed, 24 Jan 2024 20:02:57 +0100 Subject: [PATCH 9/9] user skills checked in edit profile done --- backend/src/models/UserManager.js | 7 +- .../Competence Switch/CompetenceSwitch.jsx | 2 +- frontend/src/main.jsx | 3 +- .../pages/ProfileUser/UserProfileModel.jsx | 70 ++++++++++--------- 4 files changed, 43 insertions(+), 39 deletions(-) diff --git a/backend/src/models/UserManager.js b/backend/src/models/UserManager.js index 26e7169..fb8315f 100644 --- a/backend/src/models/UserManager.js +++ b/backend/src/models/UserManager.js @@ -96,9 +96,10 @@ class UserManager extends AbstractManager { } getProfile(id) { - return this.database.query(`SELECT * FROM ${this.table} WHERE id = ?`, [ - id, - ]); + return this.database.query( + `SELECT * FROM user LEFT JOIN user_competence ON user.id = user_competence.user_id WHERE user.id = ?;`, + [id] + ); } addAvatar(userId, avatarId) { diff --git a/frontend/src/components/Competence Switch/CompetenceSwitch.jsx b/frontend/src/components/Competence Switch/CompetenceSwitch.jsx index 85cadd6..bdde786 100644 --- a/frontend/src/components/Competence Switch/CompetenceSwitch.jsx +++ b/frontend/src/components/Competence Switch/CompetenceSwitch.jsx @@ -20,7 +20,7 @@ function CompetenceSwitch({ type="checkbox" id={fieldName} name={fieldName} - value={valueInput[fieldName]} + checked={valueInput[fieldName]} onChange={handleChange} /> diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index 488858b..c18fb8c 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -7,6 +7,7 @@ import ReadOffer from "./pages/Offer/ReadOffer"; import SignIn from "./pages/Connexion/SignIn"; import LogIn from "./pages/Connexion/LogIn"; import History from "./pages/Historique/History"; +import currentUserProfileLoader from "./loaders/current-user-profil.loader"; import Favoris from "./pages/Favoris/Favoris"; import UserProfileModel from "./pages/ProfileUser/UserProfileModel"; import AddExperience from "./pages/Experience/AddExperience"; @@ -27,10 +28,8 @@ import ApiService from "./services/api.service"; // Import Styles. import "@fortawesome/fontawesome-free/css/all.min.css"; import "mdb-react-ui-kit/dist/css/mdb.min.css"; -import currentUserProfileLoader from "./loaders/current-user-profil.loader"; const apiService = new ApiService(); -// const navigate = useNavigate(); const router = createBrowserRouter([ { diff --git a/frontend/src/pages/ProfileUser/UserProfileModel.jsx b/frontend/src/pages/ProfileUser/UserProfileModel.jsx index d01ef4a..95175ee 100644 --- a/frontend/src/pages/ProfileUser/UserProfileModel.jsx +++ b/frontend/src/pages/ProfileUser/UserProfileModel.jsx @@ -13,6 +13,7 @@ import SuccesMsg from "../../components/Alertes Messages/SuccesMsg"; import CardFormation from "../../components/CardModel/CardFormation"; import CardExperience from "../../components/CardModel/CardExperience"; import AddDetailsCV from "../../components/Add Something/AddSomething"; +// import { useSignContext } from "../../contexts/SignContext"; function UserProfileModel() { const { handleAddCv } = useUserContext(); @@ -28,11 +29,13 @@ function UserProfileModel() { } = useGlobalContext(); const navigate = useNavigate(); const [getSkills, setGetSkills] = useState([]); - + // const { skills, setSkills } = useSignContext(); const [getProfile, setGetProfile] = useState({}); const { experiences, courses } = useLoaderData(); + // const [userCompetences, setUserCompetences] = useState({}); const handleExperienceDelete = async (id) => { + // eslint-disable-next-line no-alert if (!window.confirm("Voulez-vous vraiment supprimer cette expérience ?")) { return; } @@ -57,6 +60,7 @@ function UserProfileModel() { }; const handleCourseDelete = async (id) => { + // eslint-disable-next-line no-alert if (!window.confirm("Voulez-vous vraiment supprimer cette formation ?")) { return; } @@ -92,17 +96,17 @@ function UserProfileModel() { } }; - const getSkillsProfile = async () => { - try { - const response = await apiService.get( - `${import.meta.env.VITE_BACKEND_URL}/api/users/me` - ); - setGetSkills(response.data); - } catch (err) { - console.error(err); - } - }; - getSkillsProfile(); + // const getSkillsProfile = async () => { + // try { + // const response = await apiService.get( + // `${import.meta.env.VITE_BACKEND_URL}/api/users/me` + // ); + // setGetSkills(response.data); + // } catch (err) { + // console.error(err); + // } + // }; + // getSkillsProfile(); getUserProfile(); }, []); @@ -119,7 +123,6 @@ function UserProfileModel() { console.error("Error updating skills:", error); } }; - return window.location.pathname === "/edit-profile" || window.location.pathname === "/edit-profile" ? (
@@ -171,81 +174,82 @@ function UserProfileModel() { - handleCheckboxChanged(getSkills, "html", event) + handleCheckboxChanged(getProfile, "html", event) } /> + - handleCheckboxChanged(getSkills, "css", event) + handleCheckboxChanged(getProfile, "css", event) } /> - handleCheckboxChanged(getSkills, "javascript", event) + handleCheckboxChanged(getProfile, "javascript", event) } /> - handleCheckboxChanged(getSkills, "angular", event) + handleCheckboxChanged(getProfile, "angular", event) } /> - handleCheckboxChanged(getSkills, "react", event) + handleCheckboxChanged(getProfile, "react", event) } /> - handleCheckboxChanged(getSkills, "php", event) + handleCheckboxChanged(getProfile, "php", event) } /> - handleCheckboxChanged(getSkills, "symphony", event) + handleCheckboxChanged(getProfile, "symphony", event) } /> - handleCheckboxChanged(getSkills, "git", event) + handleCheckboxChanged(getProfile, "git", event) } /> - handleCheckboxChanged(getSkills, "github", event) + handleCheckboxChanged(getProfile, "github", event) } /> - handleCheckboxChanged(getSkills, "trello", event) + handleCheckboxChanged(getProfile, "trello", event) } />