feat: initial commit – Mitai Jinkendo v9a
This commit is contained in:
commit
89b6c0b072
51 files changed
+9458
No files matched your search
@@ -0,0 +1,133 @@
|
||||
// Lightweight Markdown renderer – handles the subset used by the AI:
|
||||
// ## Headings, **bold**, bullet lists, numbered lists, line breaks
|
||||
|
||||
export default function Markdown({ text }) {
|
||||
if (!text) return null
|
||||
|
||||
const lines = text.split('\n')
|
||||
const elements = []
|
||||
let i = 0
|
||||
|
||||
const parseLine = (line) => {
|
||||
// Parse inline **bold** and *italic*
|
||||
const parts = []
|
||||
let remaining = line
|
||||
let key = 0
|
||||
while (remaining.length > 0) {
|
||||
const boldMatch = remaining.match(/^(.*?)\*\*(.*?)\*\*(.*)$/)
|
||||
if (boldMatch) {
|
||||
if (boldMatch[1]) parts.push(<span key={key++}>{boldMatch[1]}</span>)
|
||||
parts.push(<strong key={key++}>{boldMatch[2]}</strong>)
|
||||
remaining = boldMatch[3]
|
||||
continue
|
||||
}
|
||||
const italicMatch = remaining.match(/^(.*?)\*(.*?)\*(.*)$/)
|
||||
if (italicMatch) {
|
||||
if (italicMatch[1]) parts.push(<span key={key++}>{italicMatch[1]}</span>)
|
||||
parts.push(<em key={key++}>{italicMatch[2]}</em>)
|
||||
remaining = italicMatch[3]
|
||||
continue
|
||||
}
|
||||
parts.push(<span key={key++}>{remaining}</span>)
|
||||
break
|
||||
}
|
||||
return parts.length === 1 && typeof parts[0].props?.children === 'string'
|
||||
? parts[0].props.children
|
||||
: parts
|
||||
}
|
||||
|
||||
while (i < lines.length) {
|
||||
const line = lines[i]
|
||||
|
||||
// Skip empty lines (add spacing)
|
||||
if (line.trim() === '') {
|
||||
elements.push(<div key={i} style={{ height: 8 }} />)
|
||||
i++; continue
|
||||
}
|
||||
|
||||
// H1
|
||||
if (line.startsWith('# ')) {
|
||||
elements.push(
|
||||
<h1 key={i} style={{ fontSize: 18, fontWeight: 700, margin: '16px 0 8px', color: 'var(--text1)' }}>
|
||||
{parseLine(line.slice(2))}
|
||||
</h1>
|
||||
)
|
||||
i++; continue
|
||||
}
|
||||
|
||||
// H2
|
||||
if (line.startsWith('## ')) {
|
||||
elements.push(
|
||||
<h2 key={i} style={{ fontSize: 15, fontWeight: 700, margin: '14px 0 6px', color: 'var(--text1)',
|
||||
display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
{parseLine(line.slice(3))}
|
||||
</h2>
|
||||
)
|
||||
i++; continue
|
||||
}
|
||||
|
||||
// H3
|
||||
if (line.startsWith('### ')) {
|
||||
elements.push(
|
||||
<h3 key={i} style={{ fontSize: 14, fontWeight: 600, margin: '10px 0 4px', color: 'var(--text1)' }}>
|
||||
{parseLine(line.slice(4))}
|
||||
</h3>
|
||||
)
|
||||
i++; continue
|
||||
}
|
||||
|
||||
// Unordered list item
|
||||
if (line.match(/^[-*] /)) {
|
||||
const listItems = []
|
||||
while (i < lines.length && lines[i].match(/^[-*] /)) {
|
||||
listItems.push(
|
||||
<li key={i} style={{ fontSize: 13, lineHeight: 1.65, color: 'var(--text2)', marginBottom: 4 }}>
|
||||
{parseLine(lines[i].slice(2))}
|
||||
</li>
|
||||
)
|
||||
i++
|
||||
}
|
||||
elements.push(
|
||||
<ul key={`ul-${i}`} style={{ paddingLeft: 20, margin: '6px 0' }}>
|
||||
{listItems}
|
||||
</ul>
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
// Numbered list item
|
||||
if (line.match(/^\d+\. /)) {
|
||||
const listItems = []
|
||||
while (i < lines.length && lines[i].match(/^\d+\. /)) {
|
||||
listItems.push(
|
||||
<li key={i} style={{ fontSize: 13, lineHeight: 1.65, color: 'var(--text2)', marginBottom: 4 }}>
|
||||
{parseLine(lines[i].replace(/^\d+\. /, ''))}
|
||||
</li>
|
||||
)
|
||||
i++
|
||||
}
|
||||
elements.push(
|
||||
<ol key={`ol-${i}`} style={{ paddingLeft: 20, margin: '6px 0' }}>
|
||||
{listItems}
|
||||
</ol>
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
// Horizontal rule
|
||||
if (line.match(/^---+$/)) {
|
||||
elements.push(<hr key={i} style={{ border: 'none', borderTop: '1px solid var(--border)', margin: '12px 0' }} />)
|
||||
i++; continue
|
||||
}
|
||||
|
||||
// Normal paragraph
|
||||
elements.push(
|
||||
<p key={i} style={{ fontSize: 13, lineHeight: 1.7, color: 'var(--text2)', margin: '4px 0' }}>
|
||||
{parseLine(line)}
|
||||
</p>
|
||||
)
|
||||
i++
|
||||
}
|
||||
|
||||
return <div>{elements}</div>
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { getToken } from '../context/AuthContext'
|
||||
|
||||
let _profileId = null
|
||||
export function setProfileId(id) { _profileId = id }
|
||||
|
||||
const BASE = '/api'
|
||||
|
||||
function hdrs(extra={}) {
|
||||
const h = {...extra}
|
||||
if (_profileId) h['X-Profile-Id'] = _profileId
|
||||
const token = getToken()
|
||||
if (token) h['X-Auth-Token'] = token
|
||||
return h
|
||||
}
|
||||
|
||||
async function req(path, opts={}) {
|
||||
const res = await fetch(BASE+path, {...opts, headers:hdrs(opts.headers||{})})
|
||||
if (!res.ok) { const err=await res.text(); throw new Error(err) }
|
||||
return res.json()
|
||||
}
|
||||
const json=(d)=>({method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(d)})
|
||||
const jput=(d)=>({method:'PUT', headers:{'Content-Type':'application/json'},body:JSON.stringify(d)})
|
||||
|
||||
export const api = {
|
||||
// Profiles
|
||||
listProfiles: () => req('/profiles'),
|
||||
createProfile: (d) => req('/profiles', json(d)),
|
||||
updateProfile: (id,d) => req(`/profiles/${id}`, jput(d)),
|
||||
deleteProfile: (id) => req(`/profiles/${id}`, {method:'DELETE'}),
|
||||
getProfile: () => req('/profile'),
|
||||
updateActiveProfile:(d)=> req('/profile', jput(d)),
|
||||
|
||||
// Weight
|
||||
listWeight: (l=365) => req(`/weight?limit=${l}`),
|
||||
upsertWeight: (date,weight,note='') => req('/weight',json({date,weight,note})),
|
||||
updateWeight: (id,date,weight,note='') => req(`/weight/${id}`,jput({date,weight,note})),
|
||||
deleteWeight: (id) => req(`/weight/${id}`,{method:'DELETE'}),
|
||||
weightStats: () => req('/weight/stats'),
|
||||
|
||||
// Circumferences
|
||||
listCirc: (l=100) => req(`/circumferences?limit=${l}`),
|
||||
upsertCirc: (d) => req('/circumferences',json(d)),
|
||||
updateCirc: (id,d) => req(`/circumferences/${id}`,jput(d)),
|
||||
deleteCirc: (id) => req(`/circumferences/${id}`,{method:'DELETE'}),
|
||||
|
||||
// Caliper
|
||||
listCaliper: (l=100) => req(`/caliper?limit=${l}`),
|
||||
upsertCaliper: (d) => req('/caliper',json(d)),
|
||||
updateCaliper: (id,d) => req(`/caliper/${id}`,jput(d)),
|
||||
deleteCaliper: (id) => req(`/caliper/${id}`,{method:'DELETE'}),
|
||||
|
||||
// Activity
|
||||
listActivity: (l=200)=> req(`/activity?limit=${l}`),
|
||||
createActivity: (d) => req('/activity',json(d)),
|
||||
updateActivity: (id,d) => req(`/activity/${id}`,jput(d)),
|
||||
deleteActivity: (id) => req(`/activity/${id}`,{method:'DELETE'}),
|
||||
activityStats: () => req('/activity/stats'),
|
||||
importActivityCsv: async(file)=>{
|
||||
const fd=new FormData();fd.append('file',file)
|
||||
const r=await fetch(`${BASE}/activity/import-csv`,{method:'POST',body:fd,headers:hdrs()})
|
||||
const d=await r.json();if(!r.ok)throw new Error(d.detail||JSON.stringify(d));return d
|
||||
},
|
||||
|
||||
// Photos
|
||||
uploadPhoto: (file,date='')=>{
|
||||
const fd=new FormData();fd.append('file',file);fd.append('date',date)
|
||||
return fetch(`${BASE}/photos`,{method:'POST',body:fd,headers:hdrs()}).then(r=>r.json())
|
||||
},
|
||||
listPhotos: () => req('/photos'),
|
||||
photoUrl: (pid) => `${BASE}/photos/${pid}`,
|
||||
|
||||
// Nutrition
|
||||
importCsv: async(file)=>{
|
||||
const fd=new FormData();fd.append('file',file)
|
||||
const r=await fetch(`${BASE}/nutrition/import-csv`,{method:'POST',body:fd,headers:hdrs()})
|
||||
const d=await r.json();if(!r.ok)throw new Error(d.detail||JSON.stringify(d));return d
|
||||
},
|
||||
listNutrition: (l=365) => req(`/nutrition?limit=${l}`),
|
||||
nutritionCorrelations: () => req('/nutrition/correlations'),
|
||||
nutritionWeekly: (w=16) => req(`/nutrition/weekly?weeks=${w}`),
|
||||
|
||||
// Stats & AI
|
||||
getStats: () => req('/stats'),
|
||||
insightTrend: () => req('/insights/trend',{method:'POST'}),
|
||||
insightPipeline: () => req('/insights/pipeline',{method:'POST'}),
|
||||
listInsights: () => req('/insights'),
|
||||
latestInsights: () => req('/insights/latest'),
|
||||
exportZip: () => window.open(`${BASE}/export/zip`),
|
||||
exportJson: () => window.open(`${BASE}/export/json`),
|
||||
exportCsv: () => window.open(`${BASE}/export/csv`),
|
||||
|
||||
// Admin
|
||||
adminListProfiles: () => req('/admin/profiles'),
|
||||
adminCreateProfile: (d) => req('/admin/profiles',json(d)),
|
||||
adminDeleteProfile: (id) => req(`/admin/profiles/${id}`,{method:'DELETE'}),
|
||||
adminSetPermissions: (id,d) => req(`/admin/profiles/${id}/permissions`,jput(d)),
|
||||
changePin: (pin) => req('/auth/pin',json({pin})),
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
export function calcBodyFat(method, skinfolds, sex, age) {
|
||||
const vals = Object.values(skinfolds).filter(v => v > 0)
|
||||
if (!vals.length) return null
|
||||
const siri = (D) => Math.max(3, Math.min(60, (495 / D) - 450))
|
||||
if (method === 'jackson3') {
|
||||
const { chest=0, abdomen=0, suprailiac=0, triceps=0, thigh=0 } = skinfolds
|
||||
const s = sex === 'm' ? chest+abdomen+thigh : triceps+suprailiac+thigh
|
||||
if (s === 0) return null
|
||||
const D = sex === 'm'
|
||||
? 1.10938 - 0.0008267*s + 0.0000016*s*s - 0.0002574*age
|
||||
: 1.0994921 - 0.0009929*s + 0.0000023*s*s - 0.0001392*age
|
||||
return siri(D)
|
||||
}
|
||||
if (method === 'jackson7') {
|
||||
const { chest=0, axilla=0, triceps=0, subscap=0, suprailiac=0, abdomen=0, thigh=0 } = skinfolds
|
||||
const s = chest+axilla+triceps+subscap+suprailiac+abdomen+thigh
|
||||
if (s === 0) return null
|
||||
const D = sex === 'm'
|
||||
? 1.112 - 0.00043499*s + 0.00000055*s*s - 0.00028826*age
|
||||
: 1.097 - 0.00046971*s + 0.00000056*s*s - 0.00012828*age
|
||||
return siri(D)
|
||||
}
|
||||
if (method === 'durnin') {
|
||||
const { biceps=0, triceps=0, subscap=0, suprailiac=0 } = skinfolds
|
||||
const s = biceps+triceps+subscap+suprailiac
|
||||
if (s === 0) return null
|
||||
const logS = Math.log10(s)
|
||||
const tbl = sex === 'm' ? [
|
||||
[20,1.1620,0.0630],[30,1.1631,0.0632],[40,1.1422,0.0544],[50,1.1620,0.0700],[99,1.1715,0.0779]
|
||||
] : [
|
||||
[20,1.1549,0.0678],[30,1.1599,0.0717],[40,1.1423,0.0632],[50,1.1333,0.0612],[99,1.1339,0.0645]
|
||||
]
|
||||
const [, c, m] = tbl.find(([maxAge]) => age < maxAge) || tbl[tbl.length-1]
|
||||
return siri(c - m * logS)
|
||||
}
|
||||
if (method === 'parrillo') {
|
||||
const sum = Object.values(skinfolds).reduce((a,b) => a+(b||0), 0)
|
||||
return Math.max(3, Math.min(50, (sum * 27) / 1000))
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export const METHOD_POINTS = {
|
||||
jackson3: { m: ['chest','abdomen','thigh'], f: ['triceps','suprailiac','thigh'] },
|
||||
jackson7: { m: ['chest','axilla','triceps','subscap','suprailiac','abdomen','thigh'],
|
||||
f: ['chest','axilla','triceps','subscap','suprailiac','abdomen','thigh'] },
|
||||
durnin: { m: ['biceps','triceps','subscap','suprailiac'], f: ['biceps','triceps','subscap','suprailiac'] },
|
||||
parrillo: { m: ['chest','axilla','triceps','subscap','suprailiac','abdomen','thigh','calf_med','lowerback'],
|
||||
f: ['chest','axilla','triceps','subscap','suprailiac','abdomen','thigh','calf_med','lowerback'] },
|
||||
}
|
||||
|
||||
export const BF_CATEGORIES = {
|
||||
m: [
|
||||
{max:6, label:'Essenziell', color:'#378ADD', desc:'Unter diesem Wert sind lebenswichtige Fette betroffen.'},
|
||||
{max:14, label:'Athletisch', color:'#1D9E75', desc:'Typisch für Leistungssportler – sehr definiert.'},
|
||||
{max:18, label:'Fit', color:'#639922', desc:'Gute Fitness, gesunder Bereich für aktive Menschen.'},
|
||||
{max:25, label:'Durchschnitt', color:'#EF9F27', desc:'Normaler Bereich für die allgemeine Bevölkerung.'},
|
||||
{max:100,label:'Übergewicht', color:'#D85A30', desc:'Erhöhtes Gesundheitsrisiko, Reduktion empfohlen.'},
|
||||
],
|
||||
f: [
|
||||
{max:14, label:'Essenziell', color:'#378ADD', desc:'Unter diesem Wert sind lebenswichtige Fette betroffen.'},
|
||||
{max:21, label:'Athletisch', color:'#1D9E75', desc:'Typisch für Leistungssportlerinnen – sehr definiert.'},
|
||||
{max:25, label:'Fit', color:'#639922', desc:'Gute Fitness, gesunder Bereich für aktive Frauen.'},
|
||||
{max:32, label:'Durchschnitt', color:'#EF9F27', desc:'Normaler Bereich für die allgemeine Bevölkerung.'},
|
||||
{max:100,label:'Übergewicht', color:'#D85A30', desc:'Erhöhtes Gesundheitsrisiko, Reduktion empfohlen.'},
|
||||
],
|
||||
}
|
||||
|
||||
export function getBfCategory(pct, sex) {
|
||||
return BF_CATEGORIES[sex]?.find(c => pct <= c.max) || BF_CATEGORIES[sex]?.at(-1)
|
||||
}
|
||||
|
||||
export function calcDerived(m, height) {
|
||||
const out = {}
|
||||
if (m.c_waist && m.c_hip) out.whr = Math.round(m.c_waist / m.c_hip * 100) / 100
|
||||
if (m.c_waist && height) out.whtr = Math.round(m.c_waist / height * 100) / 100
|
||||
if (m.lean_mass && height) out.ffmi = Math.round(m.lean_mass / ((height/100)**2) * 10) / 10
|
||||
return out
|
||||
}
|
||||
|
||||
export function getRuleBasedAssessment(current, previous, profile) {
|
||||
const sex = profile?.sex || 'm'
|
||||
const height = profile?.height || 178
|
||||
const findings = []
|
||||
|
||||
if (current.body_fat_pct) {
|
||||
const cat = getBfCategory(current.body_fat_pct, sex)
|
||||
findings.push({
|
||||
type: ['Athletisch','Fit'].includes(cat.label) ? 'good' : cat.label === 'Durchschnitt' ? 'info' : cat.label === 'Essenziell' ? 'warn' : 'bad',
|
||||
icon: '🔥', text: `Körperfett: ${current.body_fat_pct}% – ${cat.label}`, detail: cat.desc
|
||||
})
|
||||
if (previous?.body_fat_pct) {
|
||||
const delta = Math.round((current.body_fat_pct - previous.body_fat_pct) * 10) / 10
|
||||
if (Math.abs(delta) >= 0.5) findings.push({
|
||||
type: delta < 0 ? 'good' : 'warn', icon: delta < 0 ? '📉' : '📈',
|
||||
text: `Körperfett ${delta > 0?'+':''}${delta}% seit letzter Messung`,
|
||||
detail: delta < 0 ? 'Positive Entwicklung – weiter so!' : 'Leichter Anstieg – Ernährung und Training überprüfen.'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (current.lean_mass && previous?.lean_mass) {
|
||||
const delta = Math.round((current.lean_mass - previous.lean_mass) * 10) / 10
|
||||
if (Math.abs(delta) >= 0.3) findings.push({
|
||||
type: delta > 0 ? 'good' : 'warn', icon: delta > 0 ? '💪' : '⚠️',
|
||||
text: `Magermasse ${delta > 0?'+':''}${delta} kg`,
|
||||
detail: delta > 0 ? 'Muskelaufbau detektiert – Training zeigt Wirkung.' : 'Rückgang der Magermasse – auf ausreichend Protein und Krafttraining achten.'
|
||||
})
|
||||
}
|
||||
|
||||
if (current.lean_mass && height) {
|
||||
const ffmi = Math.round(current.lean_mass / ((height/100)**2) * 10) / 10
|
||||
const limit = sex === 'm' ? 25 : 22
|
||||
findings.push({
|
||||
type: ffmi >= 20 && ffmi <= limit ? 'good' : ffmi < 17 ? 'info' : 'warn',
|
||||
icon: '📐', text: `FFMI: ${ffmi}`,
|
||||
detail: ffmi < 17 ? 'Unterdurchschnittliche Muskelmasse – Krafttraining empfohlen.'
|
||||
: ffmi < 20 ? 'Durchschnittliche Muskelmasse.'
|
||||
: ffmi < 23 ? 'Gute Muskelmasse – gut trainierter Körper.'
|
||||
: ffmi <= limit ? 'Sehr hohe Muskelmasse – Leistungssportler-Niveau.'
|
||||
: `Sehr hoher FFMI – bei Werten über ${limit} kritisch hinterfragen.`
|
||||
})
|
||||
}
|
||||
|
||||
if (current.c_waist && current.c_hip) {
|
||||
const whr = Math.round(current.c_waist / current.c_hip * 100) / 100
|
||||
const limit = sex === 'm' ? 0.90 : 0.85
|
||||
findings.push({
|
||||
type: whr < limit ? 'good' : whr < limit+0.05 ? 'warn' : 'bad',
|
||||
icon: '⚖️', text: `Waist-Hip-Ratio: ${whr} (Ziel: <${limit})`,
|
||||
detail: whr < limit ? 'Gesunde Fettverteilung – kein erhöhtes kardiovaskuläres Risiko.'
|
||||
: whr < limit+0.05 ? 'Grenzwertiger Bereich – Taillenumfang reduzieren empfohlen.'
|
||||
: 'Erhöhtes kardiovaskuläres Risiko durch abdominelle Fettverteilung.'
|
||||
})
|
||||
}
|
||||
|
||||
if (current.c_waist && height) {
|
||||
const whtr = Math.round(current.c_waist / height * 100) / 100
|
||||
findings.push({
|
||||
type: whtr < 0.50 ? 'good' : whtr < 0.60 ? 'warn' : 'bad',
|
||||
icon: '📏', text: `Waist-to-Height-Ratio: ${whtr} (Ziel: <0,50)`,
|
||||
detail: whtr < 0.50 ? 'Optimales Verhältnis – Taille halb so groß wie Körpergröße.'
|
||||
: whtr < 0.60 ? 'Leicht erhöhtes Risiko – Taillenumfang sollte reduziert werden.'
|
||||
: 'Deutlich erhöhtes Gesundheitsrisiko – ärztliche Beratung empfohlen.'
|
||||
})
|
||||
}
|
||||
|
||||
if (current.c_waist) {
|
||||
const limit = sex === 'm' ? 94 : 80
|
||||
const limitHigh = sex === 'm' ? 102 : 88
|
||||
if (current.c_waist > limit) findings.push({
|
||||
type: current.c_waist > limitHigh ? 'bad' : 'warn',
|
||||
icon: '🔴', text: `Taillenumfang ${current.c_waist} cm (WHO-Grenzwert: ${limit} cm)`,
|
||||
detail: current.c_waist > limitHigh
|
||||
? `Stark erhöhtes Risiko (WHO: über ${limitHigh} cm = hohes Risiko).`
|
||||
: `Leicht erhöhtes metabolisches Risiko laut WHO-Kriterien.`
|
||||
})
|
||||
if (previous?.c_waist) {
|
||||
const delta = Math.round((current.c_waist - previous.c_waist) * 10) / 10
|
||||
if (Math.abs(delta) >= 1) findings.push({
|
||||
type: delta < 0 ? 'good' : 'warn', icon: delta < 0 ? '✅' : '📊',
|
||||
text: `Taille ${delta > 0?'+':''}${delta} cm seit letzter Messung`,
|
||||
detail: delta < 0 ? 'Taillenumfang nimmt ab – gute Entwicklung!' : 'Taille ist gewachsen – Ernährung überprüfen.'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (current.weight && previous?.weight) {
|
||||
const delta = Math.round((current.weight - previous.weight) * 10) / 10
|
||||
if (Math.abs(delta) >= 0.3) findings.push({
|
||||
type: 'info', icon: '⚖️',
|
||||
text: `Gewicht ${delta > 0?'+':''}${delta} kg seit letzter Messung`,
|
||||
detail: 'Kombination mit Körperfett-Verlauf beachten – Gewicht allein ist wenig aussagekräftig.'
|
||||
})
|
||||
}
|
||||
|
||||
const goods = findings.filter(f => f.type === 'good').length
|
||||
const bads = findings.filter(f => f.type === 'bad').length
|
||||
const warns = findings.filter(f => f.type === 'warn').length
|
||||
let summary, summaryType
|
||||
if (findings.length === 0) {
|
||||
summary = 'Zu wenig Daten. Bitte Umfänge und Körperfett ergänzen.'; summaryType = 'info'
|
||||
} else if (bads >= 2) {
|
||||
summary = 'Mehrere Werte im kritischen Bereich – gezielte Maßnahmen empfohlen.'; summaryType = 'bad'
|
||||
} else if (bads === 1 || warns >= 2) {
|
||||
summary = 'Einige Werte außerhalb des optimalen Bereichs – Verbesserungspotenzial vorhanden.'; summaryType = 'warn'
|
||||
} else if (goods >= 2) {
|
||||
summary = 'Gute Körperzusammensetzung – weiter so!'; summaryType = 'good'
|
||||
} else {
|
||||
summary = 'Werte im normalen Bereich – regelmäßig weiter messen.'; summaryType = 'info'
|
||||
}
|
||||
return { findings, summary, summaryType }
|
||||
}
|
||||
|
||||
export const CIRCUMFERENCE_GUIDE = [
|
||||
{ id:'c_neck', name:'Hals', color:'#1D9E75',
|
||||
where:'Direkt unterhalb des Adamsapfels, schmalste Stelle des Halses',
|
||||
posture:'Gerade stehen, Kopf neutral, nicht nach vorne beugen',
|
||||
how:'Waagerecht, 1 Finger Luft zwischen Band und Hals',
|
||||
tip:'Morgens nüchtern messen für konsistente Werte' },
|
||||
{ id:'c_chest', name:'Brust', color:'#378ADD',
|
||||
where:'Breiteste Stelle des Brustkorbs, über den Brustmuskeln (Männer) bzw. vollsten Stelle der Brust (Frauen)',
|
||||
posture:'Aufrecht, Arme locker seitlich – am Ende normaler Ausatmung messen',
|
||||
how:'Waagerecht, parallel zum Boden, fest aber nicht einschneidend',
|
||||
tip:'Nicht einatmen beim Messen – Werte ändern sich um bis zu 5 cm!' },
|
||||
{ id:'c_waist', name:'Taille', color:'#EF9F27',
|
||||
where:'Schmalste Stelle des Rumpfes – meist 2–3 cm oberhalb des Bauchnabels',
|
||||
posture:'Aufrecht, Bauch entspannen, Arme locker hängen lassen',
|
||||
how:'Waagerecht, eng aber nicht zusammenpressend',
|
||||
tip:'Beim seitlichen Beugen wird die schmalste Stelle gut sichtbar' },
|
||||
{ id:'c_belly', name:'Bauch', color:'#D85A30',
|
||||
where:'Exakt auf Höhe des Bauchnabels',
|
||||
posture:'Stehend, Bauch vollständig entspannen – nicht einziehen!',
|
||||
how:'Waagerecht, ohne Druck',
|
||||
tip:'Wichtigster Einzelwert für viszerales Fett und Gesundheitsrisiko' },
|
||||
{ id:'c_hip', name:'Hüfte', color:'#D4537E',
|
||||
where:'Breiteste Stelle des Gesäßes, ca. 15–20 cm unterhalb des Bauchnabels',
|
||||
posture:'Aufrecht, Füße zusammen, Gewicht gleichmäßig',
|
||||
how:'Über die breiteste Stelle des Gesäßes, waagerecht',
|
||||
tip:'Für WHR: Taille ÷ Hüfte (Ziel: <0,85 Frauen / <0,90 Männer)' },
|
||||
{ id:'c_thigh', name:'Oberschenkel', color:'#7F77DD',
|
||||
where:'Dickste Stelle des Oberschenkels, 5 cm unterhalb des Schritts',
|
||||
posture:'Aufrecht, Gewicht gleichmäßig – nicht auf ein Bein verlagern!',
|
||||
how:'Waagerecht, immer rechte Seite, gleicher Abstand vom Schritt',
|
||||
tip:'Mit Lineal vorher markieren für reproduzierbare Werte' },
|
||||
{ id:'c_calf', name:'Wade', color:'#639922',
|
||||
where:'Dickste Stelle der Wade, Mitte zwischen Knöchel und Kniebeuge',
|
||||
posture:'Aufrecht, Gewicht gleichmäßig verteilt',
|
||||
how:'Waagerecht, Muskel entspannt',
|
||||
tip:'Morgens messen – abends schwellen Beine durch Wassereinlagerungen an' },
|
||||
{ id:'c_arm', name:'Oberarm', color:'#1D9E75',
|
||||
where:'Dickste Stelle, Mitte zwischen Schultergelenk und Ellenbogen',
|
||||
posture:'Arm locker hängen lassen und entspannen',
|
||||
how:'Waagerecht, senkrecht zur Längsachse',
|
||||
tip:'Immer denselben Arm (rechts); auch angespannt messen und notieren' },
|
||||
]
|
||||
|
||||
export const CALIPER_GUIDE = {
|
||||
chest: { name:'Brust', color:'#378ADD',
|
||||
where:'Diagonale Falte, halb zwischen Achselhöhle und Brustwarze (Männer); 1/3 des Abstands (Frauen)',
|
||||
posture:'Aufrecht, Arm leicht angehoben', how:'Diagonale Falte (45°)',
|
||||
tip:'Liegt medial der Achselfalte – nicht zu weit nach außen greifen' },
|
||||
axilla: { name:'Achsel', color:'#D4537E',
|
||||
where:'Mittlere Achsellinie, auf Höhe des Xiphoids (Brustbeinansatz)',
|
||||
posture:'Arm leicht nach vorne', how:'Vertikale Falte',
|
||||
tip:'Schwieriger Punkt – Helfer sinnvoll' },
|
||||
triceps: { name:'Trizeps', color:'#EF9F27',
|
||||
where:'Rückseite Oberarm, Mitte zwischen Schultergelenk und Ellenbogen',
|
||||
posture:'Arm hängt entspannt seitlich', how:'Vertikale Falte, parallel zur Längsachse',
|
||||
tip:'Wichtigster Punkt in Frauen-Formeln – Arm vollständig entspannen' },
|
||||
subscap: { name:'Schulterblatt', color:'#7F77DD',
|
||||
where:'1–2 cm unterhalb der unteren Schulterblatt-Ecke',
|
||||
posture:'Arm hängt locker, leicht nach hinten', how:'Diagonale Falte (45°) entlang natürlicher Hautlinien',
|
||||
tip:'Arm nach hinten halten lassen für besseren Zugang' },
|
||||
suprailiac: { name:'Hüftkamm', color:'#D85A30',
|
||||
where:'Direkt oberhalb des Hüftkamms (Crista iliaca), vordere Achsellinie',
|
||||
posture:'Aufrecht, Arme leicht angehoben', how:'Diagonale Falte (45° nach innen-unten)',
|
||||
tip:'Liegt ÜBER dem Hüftknochen – nicht mit Bauch-Punkt verwechseln' },
|
||||
abdomen: { name:'Bauch', color:'#D85A30',
|
||||
where:'2 cm rechts neben dem Bauchnabel',
|
||||
posture:'Stehend, Bauch entspannen', how:'Horizontale Falte',
|
||||
tip:'Bauch vollständig entspannen – nicht einziehen!' },
|
||||
thigh: { name:'Oberschenkel', color:'#1D9E75',
|
||||
where:'Vorderseite, Mitte zwischen Leiste und Kniescheibe',
|
||||
posture:'Gewicht auf linkes Bein verlagern (rechter Muskel entspannt)', how:'Vertikale Falte',
|
||||
tip:'Gewicht aufs andere Bein – Muskel muss entspannt sein' },
|
||||
calf_med: { name:'Wade (medial)', color:'#639922',
|
||||
where:'Innenseite der Wade, dickste Stelle',
|
||||
posture:'Sitzend, Fuß flach, Knie 90°', how:'Vertikale Falte',
|
||||
tip:'Bein vollständig entspannen' },
|
||||
biceps: { name:'Bizeps', color:'#1D9E75',
|
||||
where:'Vorderseite Oberarm, Mitte zwischen Schultergelenk und Ellenbogen',
|
||||
posture:'Arm hängt entspannt', how:'Vertikale Falte',
|
||||
tip:'Nur Durnin-Methode' },
|
||||
lowerback: { name:'Lendenwirbel', color:'#888780',
|
||||
where:'Über Lendenwirbelsäule, 2 cm seitlich der Mittellinie auf Höhe L4',
|
||||
posture:'Leicht nach vorne gebeugt', how:'Horizontale Falte',
|
||||
tip:'Helfer bitten – schwer allein erreichbar' },
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
// Umfang-Messpunkte
|
||||
export const CIRCUMFERENCE_POINTS = [
|
||||
{
|
||||
id: 'c_neck', label: 'Hals', color: '#1D9E75',
|
||||
where: 'Direkt unterhalb des Adamsapfels, an der schmalsten Stelle des Halses',
|
||||
posture: 'Gerade stehen, Kopf in neutraler Position, nicht nach vorne beugen',
|
||||
how: 'Waagerecht anlegen, 1 Finger Luft zwischen Maßband und Hals',
|
||||
tip: 'Wichtig für Hemd- und Kragengrößen – morgens nüchtern messen'
|
||||
},
|
||||
{
|
||||
id: 'c_chest', label: 'Brust', color: '#378ADD',
|
||||
where: 'An der breitesten Stelle des Brustkorbs, über den Brustmuskeln / Brustwarzen (Männer) bzw. der vollsten Stelle der Brust (Frauen)',
|
||||
posture: 'Aufrecht stehen, Arme locker an den Seiten – messen am Ende einer normalen Ausatmung',
|
||||
how: 'Waagerecht, parallel zum Boden, fest aber nicht einschneidend',
|
||||
tip: 'Nicht einatmen beim Messen! Werte verändern sich um bis zu 5 cm durch einen Atemzug'
|
||||
},
|
||||
{
|
||||
id: 'c_waist', label: 'Taille', color: '#EF9F27',
|
||||
where: 'An der natürlich schmalsten Stelle des Rumpfes – meist 2–3 cm oberhalb des Bauchnabels',
|
||||
posture: 'Aufrecht stehen, Bauch entspannen, Arme locker hängen lassen',
|
||||
how: 'Waagerecht, eng aber nicht zusammenpressend',
|
||||
tip: 'Morgens nüchtern messen – nicht nach dem Essen!'
|
||||
},
|
||||
{
|
||||
id: 'c_belly', label: 'Bauch', color: '#D85A30',
|
||||
where: 'Exakt auf Höhe des Bauchnabels – auch wenn dies nicht die schmalste Stelle ist',
|
||||
posture: 'Aufrecht stehen, Bauch vollständig entspannen – keinesfalls einziehen!',
|
||||
how: 'Waagerecht, ohne Druck – weder spannen noch locker lassen',
|
||||
tip: 'Wichtigster Indikator für viszerales Fett und Gesundheitsrisiko'
|
||||
},
|
||||
{
|
||||
id: 'c_hip', label: 'Hüfte', color: '#D4537E',
|
||||
where: 'An der breitesten Stelle des Gesäßes, ca. 15–20 cm unterhalb des Bauchnabels',
|
||||
posture: 'Aufrecht stehen, Füße zusammen, Gewicht gleichmäßig verteilt',
|
||||
how: 'Über die breiteste Stelle des Gesäßes führen, waagerecht halten',
|
||||
tip: 'Waist-Hip-Ratio: Taille ÷ Hüfte (Ziel: <0,85 Frauen / <0,90 Männer)'
|
||||
},
|
||||
{
|
||||
id: 'c_thigh', label: 'Oberschenkel', color: '#7F77DD',
|
||||
where: 'An der dicksten Stelle des Oberschenkels, direkt unterhalb der Gesäßfalte – ca. 5 cm unterhalb des Schritts',
|
||||
posture: 'Aufrecht stehen, Gewicht gleichmäßig auf beide Beine verteilt',
|
||||
how: 'Waagerecht anlegen, immer denselben Abstand vom Schritt nehmen',
|
||||
tip: 'Gewicht auf das andere Bein verlagern damit der Muskel entspannt ist'
|
||||
},
|
||||
{
|
||||
id: 'c_calf', label: 'Wade', color: '#639922',
|
||||
where: 'An der dicksten Stelle der Wade, ca. in der Mitte zwischen Knöchel und Kniebeuge',
|
||||
posture: 'Aufrecht stehen, Gewicht gleichmäßig verteilt, nicht auf Zehenspitzen',
|
||||
how: 'Waagerecht anlegen, Muskel entspannt',
|
||||
tip: 'Morgens messen – gegen Abend schwellen Beine durch Wassereinlagerungen an'
|
||||
},
|
||||
{
|
||||
id: 'c_arm', label: 'Oberarm', color: '#1D9E75',
|
||||
where: 'An der dicksten Stelle des Oberarms – Mitte zwischen Schultergelenk und Ellenbogen',
|
||||
posture: 'Arm locker hängen lassen und entspannen',
|
||||
how: 'Waagerecht anlegen, senkrecht zur Längsachse des Arms',
|
||||
tip: 'Immer denselben Arm messen (meist rechts) – beide Werte notieren (entspannt & angespannt)'
|
||||
},
|
||||
]
|
||||
|
||||
// Caliper-Methoden und Messpunkte
|
||||
export const CALIPER_POINTS = {
|
||||
chest: { label: 'Brust', color: '#378ADD',
|
||||
where: 'Diagonale Falte, halb zwischen Achselhöhle und Brustwarze (Männer); 1/3 des Abstands (Frauen)',
|
||||
posture: 'Aufrecht stehen, Arm leicht angehoben',
|
||||
how: 'Diagonale Falte (45°), parallel zur Hautlinie greifen',
|
||||
tip: 'Liegt medial der Achselfalte – häufig in Männer-Formeln' },
|
||||
axilla: { label: 'Achsel', color: '#D4537E',
|
||||
where: 'Mittlere Achsellinie, auf Höhe des Xiphoids (Brustbein-Ansatz)',
|
||||
posture: 'Arm leicht nach vorne, Rumpf gerade',
|
||||
how: 'Vertikale Falte',
|
||||
tip: 'Schwieriger Punkt – Helfer sinnvoll' },
|
||||
triceps: { label: 'Trizeps', color: '#EF9F27',
|
||||
where: 'Rückseite des Oberarms, Mitte zwischen Schultergelenk und Ellenbogen',
|
||||
posture: 'Arm hängt entspannt seitlich am Körper',
|
||||
how: 'Vertikale Falte, parallel zur Längsachse des Arms',
|
||||
tip: 'Arm muss vollständig entspannt sein – wichtigster Punkt in Frauen-Formeln' },
|
||||
subscap: { label: 'Schulterblatt', color: '#7F77DD',
|
||||
where: '1–2 cm unterhalb der unteren Schulterblatt-Ecke, schräg nach außen',
|
||||
posture: 'Arm hängt locker, leicht nach hinten',
|
||||
how: 'Diagonale Falte (45°) in Richtung der natürlichen Hautlinien',
|
||||
tip: 'Arm nach hinten halten lassen für besseren Zugang' },
|
||||
suprailiac: { label: 'Hüftkamm', color: '#D85A30',
|
||||
where: 'Direkt oberhalb des Hüftkamms (Crista iliaca), vordere Achsellinie',
|
||||
posture: 'Aufrecht, Arme leicht angehoben',
|
||||
how: 'Diagonale Falte (45° nach innen-unten), entlang der Hüftkammlinie',
|
||||
tip: 'Nicht mit dem Bauch-Punkt verwechseln – liegt ÜBER dem Hüftknochen' },
|
||||
abdomen: { label: 'Bauch', color: '#D85A30',
|
||||
where: '2 cm rechts neben dem Bauchnabel',
|
||||
posture: 'Stehend, Bauch entspannen',
|
||||
how: 'Horizontale Falte, Hautspannung vermeiden',
|
||||
tip: 'Bauch vollständig entspannen – nicht einziehen!' },
|
||||
thigh: { label: 'Oberschenkel', color: '#1D9E75',
|
||||
where: 'Vorderseite des Oberschenkels, Mitte zwischen Leiste und Kniescheibe',
|
||||
posture: 'Sitzend oder stehend; Gewicht auf linkes Bein (rechter Muskel entspannt)',
|
||||
how: 'Vertikale Falte, parallel zur Längsachse des Beins',
|
||||
tip: 'Gewicht auf das andere Bein verlagern damit der Muskel entspannt ist' },
|
||||
calf_med: { label: 'Wade (medial)', color: '#639922',
|
||||
where: 'Innenseite der Wade, an der dicksten Stelle (maximaler Umfang)',
|
||||
posture: 'Sitzend, Fuß flach auf dem Boden, Knie 90°',
|
||||
how: 'Vertikale Falte',
|
||||
tip: 'Bein muss komplett entspannt sein' },
|
||||
biceps: { label: 'Bizeps', color: '#1D9E75',
|
||||
where: 'Vorderseite des Oberarms, Mitte zwischen Schultergelenk und Ellenbogen',
|
||||
posture: 'Arm hängt entspannt',
|
||||
how: 'Vertikale Falte',
|
||||
tip: 'Nur in Durnin-Methode; Arm vollständig entspannen' },
|
||||
lowerback: { label: 'Lendenwirbel', color: '#888780',
|
||||
where: 'Über der Lendenwirbelsäule, 2 cm seitlich der Mittellinie auf Höhe L4',
|
||||
posture: 'Leicht nach vorne gebeugt, Muskeln entspannen',
|
||||
how: 'Horizontale Falte',
|
||||
tip: 'Schwieriger Punkt – einen Helfer bitten' },
|
||||
}
|
||||
|
||||
export const CALIPER_METHODS = {
|
||||
jackson3: { label: 'Jackson/Pollock 3', points_m: ['chest','abdomen','thigh'], points_f: ['triceps','suprailiac','thigh'] },
|
||||
jackson7: { label: 'Jackson/Pollock 7', points_m: ['chest','axilla','triceps','subscap','suprailiac','abdomen','thigh'], points_f: ['chest','axilla','triceps','subscap','suprailiac','abdomen','thigh'] },
|
||||
durnin: { label: 'Durnin/Womersley 4', points_m: ['biceps','triceps','subscap','suprailiac'], points_f: ['biceps','triceps','subscap','suprailiac'] },
|
||||
parrillo: { label: 'Parrillo 9', points_m: ['chest','axilla','triceps','subscap','suprailiac','abdomen','thigh','calf_med','lowerback'], points_f: ['chest','axilla','triceps','subscap','suprailiac','abdomen','thigh','calf_med','lowerback'] },
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
import { getBfCategory, calcDerived } from './calc.js'
|
||||
|
||||
export function getInterpretation(measurement, profile, prevMeasurement = null) {
|
||||
const results = []
|
||||
const sex = profile?.sex || 'm'
|
||||
const height = profile?.height || 178
|
||||
const age = profile?.dob
|
||||
? Math.floor((Date.now() - new Date(profile.dob)) / (365.25 * 24 * 3600 * 1000))
|
||||
: 30
|
||||
|
||||
const m = measurement
|
||||
// lean_mass and body_fat_pct come from caliper_log
|
||||
const derived = calcDerived(m, height)
|
||||
|
||||
// ── Körperfett ─────────────────────────────────────────────────────────────
|
||||
if (m.body_fat_pct) {
|
||||
const cat = getBfCategory(m.body_fat_pct, sex)
|
||||
const ranges = sex === 'm'
|
||||
? { essential: 6, athletic: 14, fit: 18, avg: 25 }
|
||||
: { essential: 14, athletic: 21, fit: 25, avg: 32 }
|
||||
|
||||
let msg = '', detail = ''
|
||||
if (m.body_fat_pct <= ranges.essential) {
|
||||
msg = 'Sehr niedriger Körperfettanteil'; detail = 'Essenzielle Fettwerte – nur für Leistungssportler geeignet, auf Dauer nicht empfehlenswert.'
|
||||
} else if (m.body_fat_pct <= ranges.athletic) {
|
||||
msg = 'Athletischer Körperfettanteil'; detail = 'Ausgezeichnet. Typisch für aktive Sportler mit hohem Trainingsvolumen.'
|
||||
} else if (m.body_fat_pct <= ranges.fit) {
|
||||
msg = 'Guter Körperfettanteil'; detail = 'Sehr gute Fitness-Kategorie. Gesund und gut in Form.'
|
||||
} else if (m.body_fat_pct <= ranges.avg) {
|
||||
msg = 'Durchschnittlicher Körperfettanteil'; detail = 'Im normalen Bereich. Verbesserung durch Kombination aus Kraft- und Ausdauertraining möglich.'
|
||||
} else {
|
||||
msg = 'Erhöhter Körperfettanteil'; detail = 'Über dem empfohlenen Bereich. Ernährungsumstellung und regelmäßiges Training empfohlen.'
|
||||
}
|
||||
|
||||
results.push({
|
||||
category: 'Körperfett',
|
||||
icon: '🫧',
|
||||
status: m.body_fat_pct <= ranges.fit ? 'good' : m.body_fat_pct <= ranges.avg ? 'warn' : 'bad',
|
||||
title: msg,
|
||||
detail,
|
||||
value: `${m.body_fat_pct}%`,
|
||||
badge: cat?.label,
|
||||
color: cat?.color,
|
||||
})
|
||||
}
|
||||
|
||||
// ── Waist-Hip-Ratio ────────────────────────────────────────────────────────
|
||||
if (derived.whr) {
|
||||
const limit = sex === 'm' ? 0.90 : 0.85
|
||||
const limitHigh = sex === 'm' ? 1.0 : 0.95
|
||||
let status, title, detail
|
||||
if (derived.whr < limit) {
|
||||
status = 'good'; title = 'Günstige Fettverteilung'
|
||||
detail = `Dein WHR von ${derived.whr} liegt unter dem Grenzwert (${limit}). Birnenförmige Fettverteilung – metabolisch günstig.`
|
||||
} else if (derived.whr < limitHigh) {
|
||||
status = 'warn'; title = 'Grenzwertiger WHR'
|
||||
detail = `Dein WHR von ${derived.whr} liegt leicht über dem Zielwert (${limit}). Apfelförmige Tendenz – Bauchfett reduzieren empfohlen.`
|
||||
} else {
|
||||
status = 'bad'; title = 'Erhöhtes Risiko durch Fettverteilung'
|
||||
detail = `WHR von ${derived.whr} deutlich über dem Grenzwert. Erhöhtes kardiovaskuläres Risiko durch viszerales Fett.`
|
||||
}
|
||||
results.push({ category: 'Fettverteilung', icon: '📐', status, title, detail, value: derived.whr.toString() })
|
||||
}
|
||||
|
||||
// ── Waist-to-Height ────────────────────────────────────────────────────────
|
||||
if (derived.whtr) {
|
||||
let status, title, detail
|
||||
if (derived.whtr < 0.40) {
|
||||
status = 'warn'; title = 'Sehr schlanke Taille'
|
||||
detail = `WHtR ${derived.whtr} – möglicherweise zu wenig Körpermasse.`
|
||||
} else if (derived.whtr < 0.50) {
|
||||
status = 'good'; title = 'Optimale Taillen-Größen-Relation'
|
||||
detail = `WHtR ${derived.whtr} – im optimalen Bereich. Geringstes kardiovaskuläres Risiko.`
|
||||
} else if (derived.whtr < 0.60) {
|
||||
status = 'warn'; title = 'Leicht erhöhter WHtR'
|
||||
detail = `WHtR ${derived.whtr} – Ziel ist unter 0,50. Moderat erhöhtes Risiko.`
|
||||
} else {
|
||||
status = 'bad'; title = 'Stark erhöhter WHtR'
|
||||
detail = `WHtR ${derived.whtr} – deutlich erhöhtes Risiko. Taille sollte weniger als die Hälfte der Körpergröße betragen.`
|
||||
}
|
||||
results.push({ category: 'Taille/Größe', icon: '📏', status, title, detail, value: derived.whtr.toString() })
|
||||
}
|
||||
|
||||
// ── FFMI ───────────────────────────────────────────────────────────────────
|
||||
if (derived.ffmi) {
|
||||
const naturalLimit = sex === 'm' ? 25 : 22
|
||||
let status, title, detail
|
||||
if (derived.ffmi < (sex === 'm' ? 18 : 15)) {
|
||||
status = 'warn'; title = 'Unterdurchschnittliche Muskelmasse'
|
||||
detail = `FFMI ${derived.ffmi} – Krafttraining kann die Muskelmasse und den Grundumsatz deutlich verbessern.`
|
||||
} else if (derived.ffmi < (sex === 'm' ? 22 : 19)) {
|
||||
status = 'good'; title = 'Durchschnittliche Muskelmasse'
|
||||
detail = `FFMI ${derived.ffmi} – gute Basis. Mit regelmäßigem Krafttraining weiter ausbaubar.`
|
||||
} else if (derived.ffmi <= naturalLimit) {
|
||||
status = 'good'; title = 'Überdurchschnittliche Muskelmasse'
|
||||
detail = `FFMI ${derived.ffmi} – sehr gut. Oberes natürliches Spektrum für Kraftsportler.`
|
||||
} else {
|
||||
status = 'warn'; title = 'Außergewöhnlich hohe Muskelmasse'
|
||||
detail = `FFMI ${derived.ffmi} – oberhalb der natürlichen Grenze (~${naturalLimit}). Selten ohne unterstützende Mittel erreichbar.`
|
||||
}
|
||||
results.push({ category: 'Muskelmasse', icon: '💪', status, title, detail, value: derived.ffmi.toString() })
|
||||
}
|
||||
|
||||
// ── BMI (aus Gewicht + Größe) ──────────────────────────────────────────────
|
||||
if (m.weight && height) {
|
||||
const bmi = Math.round(m.weight / ((height / 100) ** 2) * 10) / 10
|
||||
let status, title, detail
|
||||
if (bmi < 18.5) {
|
||||
status = 'warn'; title = 'Untergewicht (BMI)'
|
||||
detail = `BMI ${bmi} – unter 18,5. Auf ausreichende Kalorienzufuhr und Nährstoffversorgung achten.`
|
||||
} else if (bmi < 25) {
|
||||
status = 'good'; title = 'Normalgewicht (BMI)'
|
||||
detail = `BMI ${bmi} – im optimalen Bereich (18,5–24,9).`
|
||||
} else if (bmi < 30) {
|
||||
status = 'warn'; title = 'Übergewicht (BMI)'
|
||||
detail = `BMI ${bmi} – leichtes Übergewicht. BMI allein ist wenig aussagekräftig bei Muskelmasse – Körperfett-% beachten.`
|
||||
} else {
|
||||
status = 'bad'; title = 'Adipositas (BMI)'
|
||||
detail = `BMI ${bmi} – deutliches Übergewicht. Ärztliche Beratung empfohlen.`
|
||||
}
|
||||
results.push({ category: 'BMI', icon: '⚖️', status, title, detail, value: bmi.toString() })
|
||||
}
|
||||
|
||||
// ── Vergleich zur letzten Messung ──────────────────────────────────────────
|
||||
if (prevMeasurement) {
|
||||
const changes = []
|
||||
const p = prevMeasurement
|
||||
const days = Math.round((new Date(m.date) - new Date(p.date)) / (1000 * 60 * 60 * 24))
|
||||
|
||||
if (m.body_fat_pct && p.body_fat_pct) {
|
||||
const diff = Math.round((m.body_fat_pct - p.body_fat_pct) * 10) / 10
|
||||
if (Math.abs(diff) >= 0.3) changes.push({ label: 'Körperfett', diff, unit: '%', invert: true })
|
||||
}
|
||||
if (m.weight && p.weight) {
|
||||
const diff = Math.round((m.weight - p.weight) * 10) / 10
|
||||
if (Math.abs(diff) >= 0.2) changes.push({ label: 'Gewicht', diff, unit: 'kg', invert: true })
|
||||
}
|
||||
if (m.lean_mass && p.lean_mass) {
|
||||
const diff = Math.round((m.lean_mass - p.lean_mass) * 10) / 10
|
||||
if (Math.abs(diff) >= 0.2) changes.push({ label: 'Magermasse', diff, unit: 'kg', invert: false })
|
||||
}
|
||||
if (m.c_waist && p.c_waist) {
|
||||
const diff = Math.round((m.c_waist - p.c_waist) * 10) / 10
|
||||
if (Math.abs(diff) >= 0.5) changes.push({ label: 'Taille', diff, unit: 'cm', invert: true })
|
||||
}
|
||||
if (m.c_belly && p.c_belly) {
|
||||
const diff = Math.round((m.c_belly - p.c_belly) * 10) / 10
|
||||
if (Math.abs(diff) >= 0.5) changes.push({ label: 'Bauch', diff, unit: 'cm', invert: true })
|
||||
}
|
||||
|
||||
if (changes.length > 0) {
|
||||
const positiveChanges = changes.filter(c => c.invert ? c.diff < 0 : c.diff > 0)
|
||||
const negativeChanges = changes.filter(c => c.invert ? c.diff > 0 : c.diff < 0)
|
||||
const detail = changes.map(c => {
|
||||
const sign = c.diff > 0 ? '+' : ''
|
||||
const good = c.invert ? c.diff < 0 : c.diff > 0
|
||||
return `${c.label}: ${sign}${c.diff} ${c.unit} ${good ? '✓' : '↑'}`
|
||||
}).join(' · ')
|
||||
|
||||
results.push({
|
||||
category: `Seit letzter Messung (${days} Tage)`,
|
||||
icon: '📊',
|
||||
status: positiveChanges.length >= negativeChanges.length ? 'good' : 'warn',
|
||||
title: positiveChanges.length > negativeChanges.length
|
||||
? 'Positive Entwicklung seit letzter Messung'
|
||||
: negativeChanges.length > positiveChanges.length
|
||||
? 'Verschlechterung seit letzter Messung'
|
||||
: 'Gemischte Entwicklung seit letzter Messung',
|
||||
detail,
|
||||
value: `${days}d`,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
export function getStatusColor(status) {
|
||||
return status === 'good' ? '#1D9E75' : status === 'warn' ? '#EF9F27' : '#D85A30'
|
||||
}
|
||||
|
||||
export function getStatusBg(status) {
|
||||
return status === 'good' ? '#E1F5EE' : status === 'warn' ? '#FAEEDA' : '#FCEBEB'
|
||||
}
|
||||
Reference in new issue
Block a user