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:
Julien Froidefond
2025-08-21 11:46:29 +02:00
parent 75c3b2c983
commit 5cb2bad992
3 changed files with 270 additions and 1 deletions

View File

@@ -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,
};
}