feat: add skill creation functionality and reload categories
- Introduced a new button to create skills within the SkillSelector component, allowing users to add missing skills directly. - Implemented a dialog for skill creation, including a form to handle new skill submissions. - Added a reloadSkillCategories function in the useEvaluation hook to refresh skill categories and migrate existing evaluations if necessary. - Enhanced error handling for category reloading to improve robustness.
This commit is contained in:
@@ -129,6 +129,24 @@ export function useEvaluation() {
|
||||
}
|
||||
};
|
||||
|
||||
const reloadSkillCategories = async () => {
|
||||
try {
|
||||
const categories = await loadSkillCategories();
|
||||
setSkillCategories(categories);
|
||||
|
||||
// Si on a une évaluation en cours, la migrer avec les nouvelles catégories
|
||||
if (userEvaluation) {
|
||||
const migratedEvaluation = migrateEvaluation(userEvaluation, categories);
|
||||
if (migratedEvaluation !== userEvaluation) {
|
||||
setUserEvaluation(migratedEvaluation);
|
||||
await saveUserEvaluation(migratedEvaluation);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to reload skill categories:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const updateProfile = async (profile: UserProfile) => {
|
||||
const evaluations =
|
||||
userEvaluation?.evaluations || createEmptyEvaluation(skillCategories);
|
||||
@@ -379,5 +397,6 @@ export function useEvaluation() {
|
||||
removeSkillFromEvaluation,
|
||||
initializeEmptyEvaluation,
|
||||
clearUserProfile,
|
||||
reloadSkillCategories,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user