Files
sbsports/src/composables/useHelpers.js
alexandrump 78c5ed52ac feat: initial sbsports deployment setup
Add Coolify/Woodpecker CI config, .gitignore, and deployment scripts.
2026-04-22 01:01:42 +02:00

95 lines
2.5 KiB
JavaScript

// Pure utility functions shared across all views
export const gradeWeights = {
Excellent: 4,
"Très bien": 3,
Bien: 2,
"Assez bien": 1,
Redouble: 0,
};
export function calcIMC(weight, height) {
if (!weight || !height) return 0;
const h = height / 100;
return parseFloat((weight / (h * h)).toFixed(1));
}
export function getIMCInterpretation(imc) {
if (!imc || imc <= 0) return "-";
if (imc < 16) return "Maigreur sévère";
if (imc < 17) return "Maigreur modérée";
if (imc < 18.5) return "Maigreur légère";
if (imc < 25) return "Corpulence normale";
if (imc < 30) return "Surpoids";
if (imc < 35) return "Obésité modérée (I)";
if (imc < 40) return "Obésité sévère (II)";
return "Obésité morbide (III)";
}
export function getIMCBgClass(imc) {
if (!imc || imc <= 0) return "bg-gray-300";
if (imc >= 18.5 && imc < 25) return "bg-green-500";
if (imc < 18.5) return "bg-sky-400";
if (imc < 30) return "bg-amber-500";
return "bg-red-500";
}
export function getAnxietyLabel(s) {
if (s <= 4) return "Minime";
if (s <= 9) return "Légère";
if (s <= 14) return "Modérée";
return "Sévère";
}
export function getAnxietyColor(s) {
if (s <= 4) return "bg-green-50 text-green-700 border-green-200";
if (s <= 9) return "bg-yellow-50 text-yellow-700 border-yellow-200";
if (s <= 14) return "bg-orange-50 text-orange-700 border-orange-200";
return "bg-red-50 text-red-700 border-red-200";
}
export function getLifestyleBg(l) {
return (
{
Inactif: "bg-red-500",
Sédentaire: "bg-orange-500",
Actif: "bg-blue-500",
"Très actif": "bg-green-500",
}[l] || "bg-gray-400"
);
}
export function getGradeStyle(g) {
return (
{
Redouble: "bg-red-50 text-red-600 border-red-200",
"Assez bien": "bg-sky-50 text-sky-600 border-sky-200",
Bien: "bg-blue-50 text-blue-600 border-blue-200",
"Très bien": "bg-indigo-50 text-indigo-600 border-indigo-200",
Excellent: "bg-green-50 text-green-600 border-green-200",
"Non noté": "bg-gray-50 text-gray-400 border-gray-100",
}[g] || "bg-gray-50"
);
}
export function getGradeBgClass(g) {
return (
{
Excellent: "bg-green-500",
"Très bien": "bg-indigo-600",
Bien: "bg-blue-600",
"Assez bien": "bg-sky-500",
Redouble: "bg-red-500",
"Non noté": "bg-gray-300",
}[g] || "bg-gray-400"
);
}
export function formatDate(d) {
return new Date(d).toLocaleDateString("fr-FR", {
day: "numeric",
month: "short",
year: "numeric",
});
}