Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:WildCodeSchool/2023-09-JS-BDX-P3-La_…
Browse files Browse the repository at this point in the history
…Rive_Droite into course_cvid
  • Loading branch information
FredD27 committed Jan 25, 2024
2 parents 7ec14a7 + 630b653 commit 1ba5312
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 153 deletions.
7 changes: 4 additions & 3 deletions backend/src/models/UserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/components/Boutons/ButtonMaxi.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@ ButtonMaxi.propTypes = {
textBtn: PropTypes.string.isRequired,
clickFunc: PropTypes.func.isRequired,
};
// ButtonMaxi.defaultProps = {
// textBtn: "Enregistrer",
// clickFunc: () => {},
// };

export default ButtonMaxi;
1 change: 0 additions & 1 deletion frontend/src/components/CardModel/CardExperience.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/components/CardModel/CardFormation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -42,8 +40,7 @@ function CardFormation({
{formattedDateBegin} au {formattedDateEnd}
</h4>
<h3 className="label-offre ">
{level}
{domaine}
{level} {domaine}
</h3>

<p className="entreprise-champs formation ">{name}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function CompetenceSwitch({
type="checkbox"
id={fieldName}
name={fieldName}
value={valueInput[fieldName]}
checked={valueInput[fieldName]}
onChange={handleChange}
/>
<span className="slider round"> </span>
Expand Down
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion frontend/src/components/Inputs/input-search.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
font-size: 16px;
font-weight: 500;
width: 80%;
margin-top: 10px;
margin-top: 30px;
margin-left: 20px;
}
.background-search input {
Expand Down
39 changes: 17 additions & 22 deletions frontend/src/contexts/LogContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 ${result.data.firstname} ${result.data.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;
Expand Down
32 changes: 1 addition & 31 deletions frontend/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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([
{
Expand Down Expand Up @@ -78,35 +77,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/6/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: (
<SignContextProvider>
<UserProfileModel />
Expand Down
24 changes: 8 additions & 16 deletions frontend/src/pages/Connexion/SignIn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ 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";
import SuccesMsg from "../../components/Alertes Messages/SuccesMsg";
import { useGlobalContext } from "../../contexts/GlobalContext";
Expand Down Expand Up @@ -252,7 +250,6 @@ function SignIn() {
globalContext.handleCheckboxChange(setSkills, "trello")
}
/>
<AddSomething addDetail="Votre CV" />
</div>
</div>
<CheckboxCondition
Expand All @@ -263,15 +260,7 @@ function SignIn() {
globalContext.handleCheckboxChange(setSignIn, "cguAgree")
}
/>
{/* <a href="#">Externatic</a> */}
<CheckboxCondition
textCondition="Je veux créer ou télécharger mon cv maintenant !"
valueInput={signIn}
fieldName="addCvNow"
handleChange={() =>
globalContext.handleCheckboxChange(setSignIn, "addCvNow")
}
/>

<div>
{globalContext.errorMsg && (
<ErrorMsg message={globalContext.msgContent} />
Expand All @@ -280,17 +269,20 @@ function SignIn() {
<SuccesMsg message={globalContext.msgContent} />
)}
</div>
<button type="button" onClick={handleSubmitSignIn}>
soumettre
<button
className="submit-btn-maxi"
type="button"
onClick={handleSubmitSignIn}
>
S'inscrire
</button>
{/* <ButtonMaxi textBtn="S'inscrire" clickFunc={handleSubmitSignIn} /> */}
</form>
</div>
<div className="small-paragraphe-info">
<p>
Vous avez déjà un compte ?
<Link to="/login">
<span>Connectez-vous</span>
<span> Connectez-vous</span>
</Link>
</p>
</div>
Expand Down
16 changes: 3 additions & 13 deletions frontend/src/pages/Experience/AddExperience.jsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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(() => {
Expand All @@ -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(
Expand Down Expand Up @@ -201,10 +191,10 @@ function AddExperience() {
)}
</div>
</div>
<button type="submit">soumettre</button>
<button className="submit-btn-maxi" type="submit">
Ajouter l'expérience
</button>
</form>

{/* <ButtonMaxi textBtn="Ajouter l'expérience" clickFunc={handleAddXp} /> */}
</div>
</>
);
Expand Down
18 changes: 3 additions & 15 deletions frontend/src/pages/Formation/AddFormation.jsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -61,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(
Expand Down Expand Up @@ -166,12 +156,10 @@ function AddFormation() {
<SuccesMsg message={globalContext.msgContent} />
)}
</div>
<button type="submit">soumettre</button>
<button className="submit-btn-maxi" type="submit">
Ajouter la formation
</button>
</form>
<ButtonMaxi
textBtn="Ajouter une formation"
clickFunc={handleAddCourse}
/>
</div>
</div>
);
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/pages/HomeOffer/Home.jsx
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -46,7 +44,11 @@ function Home() {

return (
<div id="home">
<HeaderLongResearch textTitle="Bienvenue sur" textTitle2="nos offres" />
<HeaderLongResearch
textTitle="Cabinet de recrutement informatique
"
textTitle2="Nos offres d'emploi"
/>
<div className="container-page">
<h2>Les offres qui matchent !</h2>
<div className="offer-container">
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/pages/Offer/EditOffer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ function AddOffer() {
};

updateOffer();

// console.log(addOffer);

globalContext.setMsgContent("L'offre à été ajouté avec");
globalContext.setSuccesMsg(true);
setTimeout(() => {
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/pages/Offer/ReadOffer.jsx
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Loading

0 comments on commit 1ba5312

Please sign in to comment.