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

Front profile #100

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
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
2 changes: 1 addition & 1 deletion 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,7 +28,6 @@ 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();

Expand Down
63 changes: 26 additions & 37 deletions frontend/src/pages/ProfileUser/UserProfileModel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ 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();

const globalContext = useGlobalContext();
const navigate = useNavigate();
const [getSkills, setGetSkills] = useState([]);

// const { skills, setSkills } = useSignContext();
const [getProfile, setGetProfile] = useState({});

// const [userCompetences, setUserCompetences] = useState({});
const { user, apiService } = useGlobalContext();

const [experiences, setExperiences] = useState([]);
const [courses, setCourses] = useState([]);
// const { experiences, courses } = useLoaderData();

const handleExperienceDelete = async (id) => {
// eslint-disable-next-line no-alert
if (!window.confirm("Voulez-vous vraiment supprimer cette expérience ?")) {
return;
}
Expand All @@ -54,6 +55,7 @@ function UserProfileModel() {
};

const handleCourseDelete = async (id) => {
// eslint-disable-next-line no-alert
if (!window.confirm("Voulez-vous vraiment supprimer cette formation ?")) {
return;
}
Expand Down Expand Up @@ -91,17 +93,6 @@ function UserProfileModel() {
}
};

const getSkillsProfile = async () => {
try {
const response = await globalContext.apiService.get(
`${import.meta.env.VITE_BACKEND_URL}/api/users/me`
);
setGetSkills(response.data);
} catch (err) {
console.error(err);
}
};

const fetchExperiences = async () => {
const experienceData = await apiService.get(
`${import.meta.env.VITE_BACKEND_URL}/api/experiences/by-cv-id/${cvId}`
Expand All @@ -126,8 +117,6 @@ function UserProfileModel() {
fetchExperiences();
fetchCourses();
};

getSkillsProfile();
getUserProfile();
fetchCvId();
}, []);
Expand All @@ -145,7 +134,6 @@ function UserProfileModel() {
console.error("Error updating skills:", error);
}
};

return window.location.pathname === "/edit-profile" ||
window.location.pathname === "/edit-profile" ? (
<div id="user-profile-model">
Expand Down Expand Up @@ -207,81 +195,82 @@ function UserProfileModel() {
<CompetenceSwitch
textCompetence="HTML"
fieldName="html"
valueInput={getSkills}
valueInput={getProfile}
handleChange={(event) =>
handleCheckboxChanged(getSkills, "html", event)
handleCheckboxChanged(getProfile, "html", event)
}
/>

<CompetenceSwitch
textCompetence="CSS"
valueInput={getSkills}
valueInput={getProfile}
fieldName="css"
handleChange={(event) =>
handleCheckboxChanged(getSkills, "css", event)
handleCheckboxChanged(getProfile, "css", event)
}
/>
<CompetenceSwitch
textCompetence="JAVASCRIPT"
fieldName="javascript"
valueInput={getSkills}
valueInput={getProfile}
handleChange={(event) =>
handleCheckboxChanged(getSkills, "javascript", event)
handleCheckboxChanged(getProfile, "javascript", event)
}
/>
<CompetenceSwitch
textCompetence="ANGULAR"
fieldName="angular"
valueInput={getSkills}
valueInput={getProfile}
handleChange={(event) =>
handleCheckboxChanged(getSkills, "angular", event)
handleCheckboxChanged(getProfile, "angular", event)
}
/>
<CompetenceSwitch
textCompetence="REACT.JS"
fieldName="react"
valueInput={getSkills}
valueInput={getProfile}
handleChange={(event) =>
handleCheckboxChanged(getSkills, "react", event)
handleCheckboxChanged(getProfile, "react", event)
}
/>
<CompetenceSwitch
textCompetence="PHP"
fieldName="php"
valueInput={getSkills}
valueInput={getProfile}
handleChange={(event) =>
handleCheckboxChanged(getSkills, "php", event)
handleCheckboxChanged(getProfile, "php", event)
}
/>
<CompetenceSwitch
textCompetence="SYMPHONY"
fieldName="symphony"
valueInput={getSkills}
valueInput={getProfile}
handleChange={(event) =>
handleCheckboxChanged(getSkills, "symphony", event)
handleCheckboxChanged(getProfile, "symphony", event)
}
/>
<CompetenceSwitch
textCompetence="GIT"
fieldName="git"
valueInput={getSkills}
valueInput={getProfile}
handleChange={(event) =>
handleCheckboxChanged(getSkills, "git", event)
handleCheckboxChanged(getProfile, "git", event)
}
/>
<CompetenceSwitch
textCompetence="GITHUB"
fieldName="github"
valueInput={getSkills}
valueInput={getProfile}
handleChange={(event) =>
handleCheckboxChanged(getSkills, "github", event)
handleCheckboxChanged(getProfile, "github", event)
}
/>
<CompetenceSwitch
textCompetence="TRELLO"
fieldName="trello"
valueInput={getSkills}
valueInput={getProfile}
handleChange={(event) =>
handleCheckboxChanged(getSkills, "trello", event)
handleCheckboxChanged(getProfile, "trello", event)
}
/>
</div>
Expand Down
Loading