Files
peakskills/lib/data-loader.ts
Julien Froidefond ab9c35c276 Add score color logic and evaluation migration
- Introduced `getScoreColors` function to dynamically set badge colors based on skill scores for better visual feedback.
- Updated HomePage to display skill evaluation percentages with corresponding colors.
- Implemented `migrateEvaluation` function to ensure existing evaluations are updated with new skill categories, enhancing data integrity.
- Refactored data loading in `loadSkillCategories` and `loadTeams` to fetch from API endpoints, improving flexibility and maintainability.
2025-08-20 16:50:30 +02:00

28 lines
740 B
TypeScript

import { SkillCategory, Team } from "./types";
export async function loadSkillCategories(): Promise<SkillCategory[]> {
try {
const response = await fetch("/api/skills");
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error("Failed to load skill categories:", error);
return [];
}
}
export async function loadTeams(): Promise<Team[]> {
try {
const response = await fetch("/api/teams");
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error("Failed to load teams:", error);
return [];
}
}