Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #101

Merged
merged 59 commits into from
Jan 25, 2024
Merged

Dev #101

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5142201
added add Avatar + skill manager et controller
cassiopeelaurie Jan 16, 2024
90733b8
Fix user ID in API endpoint
Hepsox Jan 21, 2024
35ec101
Merge branch 'dev' of github.com:WildCodeSchool/2023-09-JS-BDX-P3-La_…
Hepsox Jan 22, 2024
1706f9a
deleted phot backend
cassiopeelaurie Jan 22, 2024
b4a4a49
map formation et xp ok ans main path routes ok
FredD27 Jan 22, 2024
7a3f693
Merge pull request #85 from WildCodeSchool/course_cvid
Hepsox Jan 22, 2024
dce1ab4
Merge branch 'dev' of github.com:WildCodeSchool/2023-09-JS-BDX-P3-La_…
Hepsox Jan 22, 2024
81f270a
skills added user_competence + display front skills in userProfile
cassiopeelaurie Jan 22, 2024
4e9e49a
disabled alert Global Context lint
cassiopeelaurie Jan 22, 2024
92415a3
Merge branch 'dev' into front_profile
cassiopeelaurie Jan 22, 2024
65213f0
Merge branch 'dev' of github.com:WildCodeSchool/2023-09-JS-BDX-P3-La_…
cassiopeelaurie Jan 22, 2024
2775934
Merge branch 'front_profile' of github.com:WildCodeSchool/2023-09-JS-…
cassiopeelaurie Jan 22, 2024
ae7e0b0
try front skills
cassiopeelaurie Jan 23, 2024
d10d9f1
pushed the work not finished.
Nassitch Jan 23, 2024
73bfdea
deleted skill controller + arranged userControllers
cassiopeelaurie Jan 23, 2024
340f277
Add date-fns dependency and enable dateStrings in database connection
Hepsox Jan 23, 2024
dd7798d
css and some front routes
FredD27 Jan 23, 2024
3ebc796
Merge pull request #88 from WildCodeSchool/cardXp
FredD27 Jan 23, 2024
743b534
Merge branch 'dev' of github.com:WildCodeSchool/2023-09-JS-BDX-P3-La_…
FredD27 Jan 23, 2024
80f09e0
Merge pull request #89 from WildCodeSchool/course_cvid
Hepsox Jan 23, 2024
b6cc899
Merge branch 'dev' of github.com:WildCodeSchool/2023-09-JS-BDX-P3-La_…
cassiopeelaurie Jan 23, 2024
d31ea60
Merge pull request #90 from WildCodeSchool/front_profile
Hepsox Jan 23, 2024
c31de61
Add responsive styles to App.css and update Navbar.jsx and navBar.css
Hepsox Jan 23, 2024
3748345
Merge branch 'dev' of github.com:WildCodeSchool/2023-09-JS-BDX-P3-La_…
Hepsox Jan 23, 2024
103d38b
Update NavBar and UserProfileModel styles
Hepsox Jan 23, 2024
af9f3ea
Update CSS and navigation logic
Hepsox Jan 23, 2024
dabe430
Merge pull request #91 from WildCodeSchool/cardXp
cassiopeelaurie Jan 24, 2024
b87dda8
add update user back
FredD27 Jan 24, 2024
8493b8f
Merge branch 'dev' of github.com:WildCodeSchool/2023-09-JS-BDX-P3-La_…
FredD27 Jan 24, 2024
c7887bc
Merge pull request #92 from WildCodeSchool/course_cvid
Hepsox Jan 24, 2024
a453a10
Pushing before merging.
Nassitch Jan 24, 2024
4cbeaf0
merged.
Nassitch Jan 24, 2024
1e2a59a
Merge pull request #93 from WildCodeSchool/user_list_dashboard
Hepsox Jan 24, 2024
49c9ddd
Update API endpoints
Hepsox Jan 24, 2024
f6e655d
Refactor userControllers and add currentUserProfileLoader
Hepsox Jan 24, 2024
d9385dd
refacto globalContext
Hepsox Jan 24, 2024
b2bb4c5
refacto Global context page AddExprerience
Hepsox Jan 24, 2024
5721dc1
Refactor AddFormation component to use globalContext
Hepsox Jan 24, 2024
fb4c576
Refactor AddOffer component and use globalContext
Hepsox Jan 24, 2024
06e3d25
Refactor AddOffer component and use globalContext
Hepsox Jan 24, 2024
d28249a
Refactor UserProfileModel and use globalContext
Hepsox Jan 24, 2024
8e31688
Merge pull request #94 from WildCodeSchool/refectoContext
FredD27 Jan 24, 2024
b171c1f
refacto controllers try/catch
FredD27 Jan 24, 2024
f8ac333
Merge pull request #95 from WildCodeSchool/course_cvid
Hepsox Jan 24, 2024
1d13332
Update user profile and experience/formation forms
Hepsox Jan 24, 2024
a094f90
Merge pull request #96 from WildCodeSchool/bug
Hepsox Jan 24, 2024
7bbf28e
Remove commented code and update submit button text
Hepsox Jan 24, 2024
ebf7210
Merge pull request #97 from WildCodeSchool/bug
Hepsox Jan 24, 2024
a3c269f
Remove unused component and update checkbox label
Hepsox Jan 24, 2024
b05dc98
Merge pull request #98 from WildCodeSchool/bug
Hepsox Jan 24, 2024
d5310e6
Refactor user profile model and card formation components
Hepsox Jan 24, 2024
e11501f
Remove commented out code in main.jsx
Hepsox Jan 24, 2024
83014f9
Message d'erreur si identifiants incorrects + refactor logContext
Hepsox Jan 24, 2024
38ea028
Update CSS and button text
Hepsox Jan 24, 2024
c147a5f
Refactor code and remove commented out lines
Hepsox Jan 24, 2024
1e800e1
user skills checked in edit profile done
cassiopeelaurie Jan 24, 2024
bdc9daf
Merge pull request #99 from WildCodeSchool/bug
cassiopeelaurie Jan 24, 2024
65ce1d8
pull dev
cassiopeelaurie Jan 24, 2024
630b653
Merge pull request #100 from WildCodeSchool/front_profile
cassiopeelaurie Jan 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/database/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const client = mysql.createPool({
user: DB_USER,
password: DB_PASSWORD,
database: DB_NAME,
dateStrings: true,
});

// Try to get a connection to the database
Expand Down
343 changes: 129 additions & 214 deletions backend/database/database.sql

Large diffs are not rendered by default.

Binary file not shown.
146 changes: 66 additions & 80 deletions backend/src/controllers/courseControllers.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,89 @@
const models = require("../models/index");

const getCourse = (_, res) => {
models.course
.findAll()
.then((rows) => {
res.send(rows);
})
.catch((err) => {
console.error(err);
res.sendStatus(500);
});
const getCourse = async (_, res) => {
try {
const rows = await models.course.findAll();
res.send(rows);
} catch (err) {
console.error(err);
res.sendStatus(500);
}
};

const getCoursesByCvId = (req, res) => {
models.experience
.findAllByCvId(req.params.id)
.then((rows) => {
res.send(rows);
})
.catch((err) => {
console.error(err);
res.sendStatus(500);
});
const getCoursesByCvId = async (req, res) => {
try {
const rows = await models.course.findAllByCvId(req.params.id);
res.send(rows);
} catch (err) {
console.error(err);
res.sendStatus(500);
}
};

const getCourseById = (req, res) => {
const id = parseInt(req.params.id, 10);

models.course
.findId(id)
.then(([item]) => {
if (item[0] != null) {
res.json(item[0]);
} else {
res.sendStatus(404);
}
})
.catch((err) => {
console.error(err);
res.sendStatus(422);
});
const getCourseById = async (req, res) => {
try {
const id = parseInt(req.params.id, 10);
const [item] = await models.course.findId(id);
if (item[0] != null) {
res.json(item[0]);
} else {
res.sendStatus(404);
}
} catch (err) {
console.error(err);
res.sendStatus(422);
}
};

const postCourse = (req, res) => {
models.course
.create(req.body)
.then((rows) => {
res.send({
id: rows.insertId,
domaine: req.body.domaine,
name: req.body.name,
});
})
.catch((err) => {
console.error(err);
res.status(422).send({ error: err.message });
const postCourse = async (req, res) => {
try {
const rows = await models.course.create(req.body);
res.send({
id: rows.insertId,
domaine: req.body.domaine,
name: req.body.name,
});
// res.status(418).send(req.body)
} catch (err) {
console.error(err);
res.status(422).send({ error: err.message });
}
};

const updateCourse = async (req, res) => {
const id = parseInt(req.params.id, 10);
if (!id) {
res.sendStatus(500);
}
// const updateCourse = async (req, res) => {
// try {
// const id = parseInt(req.params.id, 10);
// if (!id) {
// res.sendStatus(500);
// }

models.course
.update(id, req.body)
.then((result) => {
if (result.affectedRows === 0) {
res.sendStatus(500);
}
res.sendStatus(200);
})
.catch((error) => {
console.error(error);
res.status(422).send({ error: error.message });
});
};
// const result = await models.course.update(id, req.body);
// if (result.affectedRows === 0) {
// res.sendStatus(500);
// }
// res.sendStatus(200);
// } catch (error) {
// console.error(error);
// res.status(422).send({ error: error.message });
// }
// };

const deleteCourseById = (req, res) => {
const id = parseInt(req.params.id, 10);
const deleteCourseById = async (req, res) => {
try {
const id = parseInt(req.params.id, 10);

models.course
.deleteId(id)
.then(([result]) => {
res.status(201).send({ message: result });
})
.catch((err) => {
console.error(err);
res.status(422).send({ message: "Course not found." });
});
const [result] = await models.course.deleteId(id);
res.status(201).send({ message: result });
} catch (err) {
console.error(err);
res.status(422).send({ message: "Course not found." });
}
};

module.exports = {
getCourse,
getCourseById,
postCourse,
updateCourse,
// updateCourse,
deleteCourseById,
getCoursesByCvId,
};
25 changes: 11 additions & 14 deletions backend/src/controllers/cvControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const models = require("../models/index");
const getCv = async (req, res) => {
const userId = parseInt(req.params.id, 10);
if (userId !== req.user.id) {
return res.status(403).send({ message: "Invalid user" });
return res.status(403).send({ message: "Invalid user" }); // <=== Ton erreur vient d'ici
}
try {
const [item] = await models.cv.findCvByUserId(userId);
Expand All @@ -25,20 +25,17 @@ const getCv = async (req, res) => {
}
};

const postCv = (req, res) => {
models.cv
.create(req.body)
.then((rows) => {
res.send({
id: rows.insertId,
userId: rows.user_id,
});
})
.catch((err) => {
console.error(err);
res.status(422).send({ error: err.message });
const postCv = async (req, res) => {
try {
const rows = await models.cv.create(req.body);
res.send({
id: rows.insertId,
userId: rows.user_id,
});
// res.status(418).send(req.body)
} catch (err) {
console.error(err);
res.status(422).send({ error: err.message });
}
};

module.exports = { postCv, getCv };
142 changes: 64 additions & 78 deletions backend/src/controllers/experienceControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,102 +5,88 @@ const models = require("../models/index");
// return jwt.sign(data, process.env.APP_SECRET);
// }

const getExperiences = (_, res) => {
models.experience
.findAll()
.then((rows) => {
res.send(rows);
})
.catch((err) => {
console.error(err);
res.sendStatus(500);
});
const getExperiences = async (_, res) => {
try {
const rows = await models.experience.findAll();
res.send(rows);
} catch (err) {
console.error(err);
res.sendStatus(500);
}
};

const getExperiencesByCvId = (req, res) => {
models.experience
.findAllByCvId(req.params.id)
.then((rows) => {
res.send(rows);
})
.catch((err) => {
console.error(err);
res.sendStatus(500);
});
const getExperiencesByCvId = async (req, res) => {
try {
const rows = await models.experience.findAllByCvId(req.params.id);
res.send(rows);
} catch (err) {
console.error(err);
res.sendStatus(500);
}
};

const getExperienceById = (req, res) => {
const id = parseInt(req.params.id, 10);

models.experience
.findId(id)
.then(([item]) => {
if (item[0] != null) {
res.json(item[0]);
} else {
res.sendStatus(404);
}
})
.catch((err) => {
console.error(err);
res.sendStatus(422);
});
const getExperienceById = async (req, res) => {
try {
const id = parseInt(req.params.id, 10);
const [item] = await models.experience.findId(id);
if (item[0] != null) {
res.json(item[0]);
} else {
res.sendStatus(404);
}
} catch (err) {
console.error(err);
res.sendStatus(422);
}
};

const postExperience = (req, res) => {
models.experience
.create(req.body)
.then((rows) => {
res.send({
id: rows.insertId,
});
})
.catch((err) => {
console.error(err);
res.status(422).send({ error: err.message });
const postExperience = async (req, res) => {
try {
const rows = await models.experience.create(req.body);
res.send({
id: rows.insertId,
});
// res.status(418).send(req.body)
} catch (err) {
console.error(err);
res.status(422).send({ error: err.message });
}
};

const updateExperience = async (req, res) => {
const id = parseInt(req.params.id, 10);
if (!id) {
res.sendStatus(500);
}
// const updateExperience = async (req, res) => {
// try {
// const id = parseInt(req.params.id, 10);
// if (!id) {
// res.sendStatus(500);
// }

models.experience
.update(id, req.body)
.then((result) => {
if (result.affectedRows === 0) {
res.sendStatus(500);
}
res.sendStatus(200);
})
.catch((error) => {
console.error(error);
res.status(422).send({ error: error.message });
});
};
// const result = await models.experience.update(id, req.body);
// if (result.affectedRows === 0) {
// res.sendStatus(500);
// }
// res.sendStatus(200);
// } catch (error) {
// console.error(error);
// res.status(422).send({ error: error.message });
// }
// };

const deleteExperienceById = (req, res) => {
const id = parseInt(req.params.id, 10);
const deleteExperienceById = async (req, res) => {
try {
const id = parseInt(req.params.id, 10);

models.experience
.deleteId(id)
.then(([result]) => {
res.status(201).send({ message: result });
})
.catch((err) => {
console.error(err);
res.status(422).send({ message: "Experience not found." });
});
const [result] = await models.experience.deleteId(id);
res.status(201).send({ message: result });
} catch (err) {
console.error(err);
res.status(422).send({ message: "Experience not found." });
}
};

module.exports = {
getExperiences,
getExperienceById,
postExperience,
updateExperience,
// updateExperience,
deleteExperienceById,
getExperiencesByCvId,
};
Loading
Loading