Add mentor and learning status updates to skill evaluation
- Introduced `updateSkillMentorStatus` and `updateSkillLearningStatus` functions to manage mentor and learning preferences for skills. - Updated `SkillEvaluationCard` to include buttons for toggling mentor and learning statuses with corresponding icons. - Enhanced `SkillEvaluationGrid` and `SkillEvaluation` components to pass new status update handlers. - Modified `SkillEvaluation` type to accommodate new properties for mentor and learning status.
This commit is contained in:
@@ -135,6 +135,68 @@ export function useEvaluation() {
|
||||
saveUserEvaluation(newEvaluation);
|
||||
};
|
||||
|
||||
const updateSkillMentorStatus = (
|
||||
category: string,
|
||||
skillId: string,
|
||||
canMentor: boolean
|
||||
) => {
|
||||
if (!userEvaluation) return;
|
||||
|
||||
const updatedEvaluations = userEvaluation.evaluations.map((catEval) => {
|
||||
if (catEval.category === category) {
|
||||
const updatedSkills = catEval.skills.map((skill) =>
|
||||
skill.skillId === skillId ? { ...skill, canMentor } : skill
|
||||
);
|
||||
|
||||
return {
|
||||
...catEval,
|
||||
skills: updatedSkills,
|
||||
};
|
||||
}
|
||||
return catEval;
|
||||
});
|
||||
|
||||
const newEvaluation: UserEvaluation = {
|
||||
...userEvaluation,
|
||||
evaluations: updatedEvaluations,
|
||||
lastUpdated: new Date().toISOString(),
|
||||
};
|
||||
|
||||
setUserEvaluation(newEvaluation);
|
||||
saveUserEvaluation(newEvaluation);
|
||||
};
|
||||
|
||||
const updateSkillLearningStatus = (
|
||||
category: string,
|
||||
skillId: string,
|
||||
wantsToLearn: boolean
|
||||
) => {
|
||||
if (!userEvaluation) return;
|
||||
|
||||
const updatedEvaluations = userEvaluation.evaluations.map((catEval) => {
|
||||
if (catEval.category === category) {
|
||||
const updatedSkills = catEval.skills.map((skill) =>
|
||||
skill.skillId === skillId ? { ...skill, wantsToLearn } : skill
|
||||
);
|
||||
|
||||
return {
|
||||
...catEval,
|
||||
skills: updatedSkills,
|
||||
};
|
||||
}
|
||||
return catEval;
|
||||
});
|
||||
|
||||
const newEvaluation: UserEvaluation = {
|
||||
...userEvaluation,
|
||||
evaluations: updatedEvaluations,
|
||||
lastUpdated: new Date().toISOString(),
|
||||
};
|
||||
|
||||
setUserEvaluation(newEvaluation);
|
||||
saveUserEvaluation(newEvaluation);
|
||||
};
|
||||
|
||||
const addSkillToEvaluation = (category: string, skillId: string) => {
|
||||
if (!userEvaluation) return;
|
||||
|
||||
@@ -206,6 +268,8 @@ export function useEvaluation() {
|
||||
loading,
|
||||
updateProfile,
|
||||
updateSkillLevel,
|
||||
updateSkillMentorStatus,
|
||||
updateSkillLearningStatus,
|
||||
addSkillToEvaluation,
|
||||
removeSkillFromEvaluation,
|
||||
initializeEmptyEvaluation,
|
||||
|
||||
Reference in New Issue
Block a user