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 user_list_dashboard
  • Loading branch information
Nassitch committed Jan 25, 2024
2 parents 00a7771 + 7df9015 commit 6173b41
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 33 deletions.
13 changes: 4 additions & 9 deletions backend/database/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CREATE TABLE user (
-- address,
-- password
-- )
DROP TABLE IF EXISTS competence;
-- DROP TABLE IF EXISTS competence;

-- DELETE TABLE competence;

Expand Down Expand Up @@ -115,14 +115,9 @@ VALUES (

DROP TABLE IF EXISTS user_competence;
-- Créer la table "user_competence"
CREATE TABLE
user_competence (
user_id INT,
competence_id INT,
PRIMARY KEY (user_id, competence_id),
FOREIGN KEY (user_id) REFERENCES user(id),
FOREIGN KEY (competence_id) REFERENCES competence(id)
);
CREATE TABLE user_competence (
user_id INT, html BOOLEAN, css BOOLEAN, javascript BOOLEAN, angular BOOLEAN, react BOOLEAN, php BOOLEAN, symphony BOOLEAN, git BOOLEAN, github BOOLEAN, trello BOOLEAN, PRIMARY KEY (user_id), FOREIGN KEY (user_id) REFERENCES user (id)
);

CREATE TABLE upload (
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT, url varchar(255) NOT NULL, unique (url), created_at timestamp default CURRENT_TIMESTAMP
Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/userControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const updateUser = async (req, res) => {
res.sendStatus(500);
}
const result = await models.user.update(id, req.body);
if (result.affectedRows === 0) {
if (result.affectedRows.length === 0) {
res.sendStatus(500);
}
res.sendStatus(200);
Expand Down
6 changes: 3 additions & 3 deletions backend/src/models/UserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class UserManager extends AbstractManager {
}

async update(id, user) {
const { firstname, lastname, phone, address, email } = user;
const { firstname, lastname, phone, email, address } = user;

try {
const [result] = await this.database.query(
`UPDATE ${this.table} SET firstname = ?, lastname = ?, phone = ?, address = ?, email = ? WHERE id = ?`,
[firstname, lastname, phone, address, email, id]
`UPDATE ${this.table} SET firstname = ?, lastname = ?, phone = ?, email = ?, address = ? WHERE id = ?`,
[firstname, lastname, phone, email, address, id]
);

return result;
Expand Down
9 changes: 2 additions & 7 deletions backend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@ router.get(
userControllers.getUsers
);
router.get("/users/:id([0-9]+)/cvs", authMiddleware, cvControllers.getCv);
router.get(
"/users/:id([0-9]+)",
authMiddleware,
authAdminMiddleware,
userControllers.getUserById
);
router.get("/users/:id([0-9]+)", authMiddleware, userControllers.getUserById);
router.get("/users/me", authMiddleware, userControllers.getProfile);
router.post("/users", userControllers.postUser);
router.put("/users/edit", authMiddleware, userControllers.updateUser);
router.put("/users/:id([0-9]+)", authMiddleware, userControllers.updateUser);

router.post("/user/skills", userControllers.postSkills);
router.get("/user/skills", userControllers.getSkills);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ function CompetenceSwitch({
}

CompetenceSwitch.propTypes = {
textCompetence: PropTypes.string.isRequired,
textCompetence: PropTypes.string,
fieldName: PropTypes.string.isRequired,
handleChange: PropTypes.func.isRequired,
valueInput: PropTypes.func.isRequired,
valueInput: PropTypes.oneOfType([PropTypes.object]),
};

CompetenceSwitch.defaultProps = {
textCompetence: "La valeur n'est pas définie.",
valueInput: {},
};

export default CompetenceSwitch;
8 changes: 6 additions & 2 deletions frontend/src/components/Headers/HeaderLongUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ function HeaderLongUser({ textTitle, textTitle2 }) {
}

HeaderLongUser.propTypes = {
textTitle: PropTypes.string.isRequired,
textTitle2: PropTypes.string.isRequired,
textTitle: PropTypes.string,
textTitle2: PropTypes.string,
};
HeaderLongUser.defaultProps = {
textTitle: "Titre par défaut",
textTitle2: "Titre 2 par défaut",
};
export default HeaderLongUser;
15 changes: 11 additions & 4 deletions frontend/src/components/Inputs/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ function Input({
}

Input.propTypes = {
titleInput: PropTypes.string.isRequired,
holderText: PropTypes.string.isRequired,
typeInput: PropTypes.string.isRequired,
titleInput: PropTypes.string,
holderText: PropTypes.string,
typeInput: PropTypes.string,
fieldName: PropTypes.string.isRequired,
valueInput: PropTypes.element.isRequired,
valueInput: PropTypes.oneOfType([PropTypes.object]),
handleChange: PropTypes.func.isRequired,
};

Input.defaultProps = {
titleInput: "Nom de l'input",
holderText: "Texte du placeholder",
typeInput: "text",
valueInput: {},
};

export default Input;
11 changes: 8 additions & 3 deletions frontend/src/components/Inputs/TextArea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ function TextArea({
}

TextArea.propTypes = {
titleInput: PropTypes.string.isRequired,
holderText: PropTypes.string.isRequired,
titleInput: PropTypes.string,
holderText: PropTypes.string,
fieldName: PropTypes.string.isRequired,
valueInput: PropTypes.element.isRequired,
valueInput: PropTypes.oneOfType([PropTypes.object]),
handleChange: PropTypes.func.isRequired,
};
TextArea.defaultProps = {
titleInput: "Nom de l'input",
holderText: "Texte du placeholder",
valueInput: {},
};

export default TextArea;
6 changes: 5 additions & 1 deletion frontend/src/pages/Dashboard/Dashboard2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ function Dashboard2({ refAnnonce }) {
}

Dashboard2.propTypes = {
refAnnonce: PropTypes.string.isRequired,
refAnnonce: PropTypes.string,
};

Dashboard2.defaultProps = {
refAnnonce: undefined,
};
export default Dashboard2;
33 changes: 32 additions & 1 deletion frontend/src/pages/ProfileUser/UserProfileModel.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Outlet, useNavigate } from "react-router-dom";
import { useEffect, useState } from "react";
// import PropTypes from "prop-types";
import "./user-profile-model.css";
import Input from "../../components/Inputs/Input";
import HeaderLongUser from "../../components/Headers/HeaderLongUser";
Expand All @@ -17,7 +18,6 @@ import AddDetailsCV from "../../components/Add Something/AddSomething";

function UserProfileModel() {
const { handleAddCv } = useUserContext();

const globalContext = useGlobalContext();
const navigate = useNavigate();
const [getSkills, setGetSkills] = useState([]);
Expand Down Expand Up @@ -330,4 +330,35 @@ function UserProfileModel() {
);
}

// UserProfileModel.propTypes = {
// experiences: PropTypes.arrayOf(
// PropTypes.shape({
// id: PropTypes.number.isRequired,
// company: PropTypes.string.isRequired,
// title: PropTypes.string.isRequired,
// type: PropTypes.string.isRequired,
// city: PropTypes.string.isRequired,
// date_begin: PropTypes.string.isRequired,
// date_end: PropTypes.string.isRequired,
// description: PropTypes.string.isRequired,
// })
// ),
// courses: PropTypes.arrayOf(
// PropTypes.shape({
// id: PropTypes.number.isRequired,
// level: PropTypes.string.isRequired,
// domaine: PropTypes.string.isRequired,
// date_begin: PropTypes.string.isRequired,
// date_end: PropTypes.string.isRequired,
// name: PropTypes.string.isRequired,
// description: PropTypes.string.isRequired,
// })
// ),
// };

// UserProfileModel.defaultProps = {
// experiences: [],
// courses: [],
// };

export default UserProfileModel;

0 comments on commit 6173b41

Please sign in to comment.