feat: Eigene und zentrale Lebensmittel bearbeiten, mit Sichtbarkeit im Mapping
Deploy Development / deploy (push) Successful in 1m5s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 24s

Nutzer können persönliche Foods anlegen und ändern; der Admin legt zentrale Einträge für alle an. Suche und Namens-Mapping berücksichtigen persönlich, zentral und BLS.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-09-14 12:47:12 +02:00
1 parent d35087ad84
commit 8b1e1da5d8
30 files changed
+1195 -120

No files matched your search

+146
View File
@@ -0,0 +1,146 @@
import { useEffect, useState } from 'react'
import { api } from '../utils/api'
import FoodNutrientFields, { foodCreatePayload } from './FoodNutrientFields'
function numStr(v) {
if (v == null || v === '') return '0'
const n = Number(v)
return Number.isFinite(n) ? String(n) : '0'
}
export default function FoodEditDialog({ foodId, onClose, onSaved, zIndex, mode }) {
const isCreate = !foodId
const isAdmin = mode === 'admin'
const [name, setName] = useState('')
const [macros, setMacros] = useState({ kcal: '0', protein_g: '0', fat_g: '0', carbs_g: '0' })
const [extras, setExtras] = useState([])
const [servingG, setServingG] = useState('100')
const [editable, setEditable] = useState(false)
const [loading, setLoading] = useState(!isCreate)
const [saving, setSaving] = useState(false)
const [error, setError] = useState(null)
useEffect(() => {
if (isCreate) {
setEditable(true)
setLoading(false)
return
}
let alive = true
api.getBlsFood(foodId).then((d) => {
if (!alive) return
setName(d.name_de || '')
const m = d.macros_per_100g || {}
setMacros({
kcal: numStr(m.kcal),
protein_g: numStr(m.protein_g),
fat_g: numStr(m.fat_g),
carbs_g: numStr(m.carbs_g),
})
setExtras((d.attributes || []).map((row) => ({
attr: row.attr,
value: numStr(row.value),
inputUnit: row.attr?.unit || 'g',
})))
setServingG(numStr(d.serving_g || 100) === '0' ? '100' : numStr(d.serving_g || 100))
setEditable(isAdmin ? d.catalog_kind === 'manual_admin' : Boolean(d.editable))
setLoading(false)
}).catch((e) => {
if (!alive) return
setError(e.message)
setLoading(false)
})
return () => { alive = false }
}, [foodId, isCreate, isAdmin])
const save = async () => {
if (!name.trim()) {
setError('Name fehlt')
return
}
setSaving(true)
setError(null)
try {
const body = foodCreatePayload(name, macros, extras, servingG)
let saved
if (isAdmin) {
saved = isCreate ? await api.adminCreateManualFood(body) : await api.adminUpdateManualFood(foodId, body)
} else {
saved = isCreate ? await api.createUserFood(body) : await api.updateUserFood(foodId, body)
}
onSaved?.(saved)
onClose?.()
} catch (e) {
setError(e.message)
} finally {
setSaving(false)
}
}
return (
<div
style={{
position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.45)',
display: 'flex', alignItems: 'center', justifyContent: 'center', zIndex: zIndex || 23000,
padding: 16,
}}
>
<div
role="dialog"
aria-modal="true"
style={{
width: '100%', maxWidth: 520, maxHeight: 'min(92vh, 800px)',
background: 'var(--surface)', borderRadius: 16,
boxShadow: '0 8px 32px rgba(0,0,0,0.18)',
display: 'flex', flexDirection: 'column',
}}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '14px 16px', borderBottom: '1px solid var(--border)' }}>
<h2 className="card-title" style={{ margin: 0, fontSize: 16 }}>
{isCreate
? (isAdmin ? 'Zentrales Lebensmittel anlegen' : 'Lebensmittel anlegen')
: (isAdmin ? 'Zentrales Lebensmittel bearbeiten' : 'Lebensmittel bearbeiten')}
</h2>
<button type="button" className="btn btn-secondary" disabled={saving} onClick={onClose}>Schließen</button>
</div>
<div style={{ overflowY: 'auto', padding: '12px 16px 16px', flex: 1 }}>
{loading && <p style={{ fontSize: 13 }}>Lade…</p>}
{error && <div style={{ color: 'var(--danger)', fontSize: 13, marginBottom: 10 }}>{error}</div>}
{!loading && !editable && (
<p style={{ fontSize: 13, color: 'var(--text2)' }}>
Offizielle BLS-Einträge sind fest. Nur selbst angelegte{isAdmin ? ' zentrale' : ''} Lebensmittel lassen sich ändern.
</p>
)}
{!loading && editable && (
<>
<label className="form-label">Name</label>
<input
className="form-input"
style={{ width: '100%', textAlign: 'left', marginBottom: 12 }}
value={name}
onChange={(e) => setName(e.target.value)}
/>
<FoodNutrientFields
macros={macros}
setMacros={setMacros}
extras={extras}
setExtras={setExtras}
servingG={servingG}
setServingG={setServingG}
valuesArePer100g={!isCreate}
/>
</>
)}
</div>
{editable && (
<div style={{ display: 'flex', gap: 8, padding: '12px 16px', borderTop: '1px solid var(--border)' }}>
<button type="button" className="btn btn-secondary" disabled={saving} onClick={onClose}>Abbrechen</button>
<button type="button" className="btn btn-primary" style={{ flex: 1 }} disabled={saving || loading} onClick={save}>
{saving ? 'Speichere…' : (isCreate ? 'Anlegen' : 'Speichern')}
</button>
</div>
)}
</div>
</div>
)
}
+13 -3
View File
@@ -45,7 +45,7 @@ export function foodCreatePayload(name, macros, extras, servingG) {
}
}
export default function FoodNutrientFields({ macros, setMacros, extras, setExtras, servingG, setServingG }) {
export default function FoodNutrientFields({ macros, setMacros, extras, setExtras, servingG, setServingG, valuesArePer100g }) {
const [q, setQ] = useState('')
const [hits, setHits] = useState([])
const [quick, setQuick] = useState([])
@@ -124,8 +124,9 @@ export default function FoodNutrientFields({ macros, setMacros, extras, setExtra
return (
<div>
<p style={{ fontSize: 12, color: 'var(--text3)', margin: '0 0 8px' }}>
Etikettwerte so eintragen, wie sie dastehen. Portionsgröße setzen (5 ml Öl ≈ 5 g). Gespeichert wird immer pro 100 g.
Ein Öl/Supplement ist ein Lebensmittel, keine Liste — Listen können keine Listen enthalten.
{valuesArePer100g
? 'Geladen sind die gespeicherten Werte je 100 g. Portion nur ändern, wenn du vom Etikett neu einträgst (sonst 100 lassen).'
: 'Etikettwerte so eintragen, wie sie dastehen. Portionsgröße setzen (5 ml Öl ≈ 5 g). Gespeichert wird immer pro 100 g. Ein Öl/Supplement ist ein Lebensmittel, keine Liste — Listen können keine Listen enthalten.'}
</p>
<label style={{ display: 'block', fontSize: 12, color: 'var(--text2)', marginBottom: 8 }}>
Angabe gilt für{' '}
@@ -241,6 +242,15 @@ export default function FoodNutrientFields({ macros, setMacros, extras, setExtra
) : (
<span style={{ alignSelf: 'center' }}>{target}</span>
)}
<button
type="button"
className="btn btn-secondary"
style={{ padding: '6px 10px' }}
onClick={() => setExtras((list) => list.filter((r) => r.attr.attr_key !== row.attr.attr_key))}
aria-label="Stoff entfernen"
>
×
</button>
</span>
</label>
)
+30 -13
View File
@@ -1,6 +1,8 @@
import { useEffect, useRef, useState } from 'react'
import { api } from '../utils/api'
import FoodSearchModal from './FoodSearchModal'
import FoodEditDialog from './FoodEditDialog'
import { foodVisibilityLabel } from '../utils/foodVisibility'
const FALLBACK_UNITS = [
{ id: 'g', label: 'g', default_g: 1, needs_unit_map: false },
@@ -128,6 +130,7 @@ export default function FoodRecipeDialog({
const [knownNames, setKnownNames] = useState([])
const [suggestions, setSuggestions] = useState({})
const [mapFor, setMapFor] = useState(null)
const [editFoodId, setEditFoodId] = useState(null)
const nameRef = useRef(null)
const qtyRefs = useRef({})
const timer = useRef(null)
@@ -476,21 +479,27 @@ export default function FoodRecipeDialog({
))}
{searching && <p style={{ fontSize: 12, color: 'var(--text2)', padding: '6px 10px' }}>Katalog…</p>}
{userHits.length > 0 && (
<div style={{ padding: '8px 10px 4px', fontSize: 11, color: 'var(--text3)' }}>Eigene Lebensmittel</div>
<div style={{ padding: '8px 10px 4px', fontSize: 11, color: 'var(--text3)' }}>Persönlich und zentral</div>
)}
{userHits.map((h) => (
<button
key={h.id}
type="button"
className="btn btn-secondary btn-full"
style={{ margin: '0 8px 8px', justifyContent: 'flex-start', textAlign: 'left', height: 'auto', padding: '8px 10px' }}
onClick={() => addCatalog(h)}
>
<span>
<strong style={{ display: 'block' }}>{h.name_de}</strong>
<span style={{ fontSize: 12, color: 'var(--text3)' }}>{h.bls_code ? `BLS ${h.bls_code}` : 'manuell'}</span>
</span>
</button>
<div key={h.id} style={{ display: 'flex', gap: 8, margin: '0 8px 8px' }}>
<button
type="button"
className="btn btn-secondary"
style={{ flex: 1, justifyContent: 'flex-start', textAlign: 'left', height: 'auto', padding: '8px 10px' }}
onClick={() => addCatalog(h)}
>
<span>
<strong style={{ display: 'block' }}>{h.name_de}</strong>
<span style={{ fontSize: 12, color: 'var(--text3)' }}>{foodVisibilityLabel(h.catalog_kind, h.visibility)}</span>
</span>
</button>
{h.catalog_kind === 'manual_user' && (
<button type="button" className="btn btn-secondary" style={{ flexShrink: 0 }} onClick={() => setEditFoodId(h.id)}>
Bearbeiten
</button>
)}
</div>
))}
{blsHits.length > 0 && (
<div style={{ padding: '8px 10px 4px', fontSize: 11, color: 'var(--text3)' }}>BLS-Katalog</div>
@@ -623,6 +632,14 @@ export default function FoodRecipeDialog({
onSelect={(food, extras) => assignIngredient(mapFor.source_name_raw, food, extras).catch((e) => setError(e.message))}
/>
)}
{editFoodId && (
<FoodEditDialog
foodId={editFoodId}
zIndex={24000}
onClose={() => setEditFoodId(null)}
onSaved={() => runCatalog(q)}
/>
)}
</div>
)
}
+40 -18
View File
@@ -1,6 +1,8 @@
import { useEffect, useRef, useState } from 'react'
import { api } from '../utils/api'
import FoodNutrientFields, { foodCreatePayload } from './FoodNutrientFields'
import FoodEditDialog from './FoodEditDialog'
import { foodVisibilitySuffix } from '../utils/foodVisibility'
const COUNT_UNITS = new Set(['stück', 'scheibe', 'portion', 'becher', 'tasse'])
const UNIT_LABEL = {
@@ -33,6 +35,7 @@ export default function FoodSearchModal({ title, initialQuery, quantityHint, all
const [creating, setCreating] = useState(false)
const [showCreate, setShowCreate] = useState(false)
const [createKind, setCreateKind] = useState(null)
const [editId, setEditId] = useState(null)
const [manual, setManual] = useState({
name_de: initialQuery || '',
kcal: '', protein_g: '', fat_g: '', carbs_g: '',
@@ -127,6 +130,7 @@ export default function FoodSearchModal({ title, initialQuery, quantityHint, all
const unitLabel = UNIT_LABEL[suggestedUnit] || suggestedUnit
return (
<>
<div
style={{
position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.45)',
@@ -186,24 +190,33 @@ export default function FoodSearchModal({ title, initialQuery, quantityHint, all
{!loading && q.trim().length >= 2 && hits.length === 0 && (
<p style={{ fontSize: 13, color: 'var(--text3)' }}>Kein Treffer im Katalog.</p>
)}
{hits.map((h) => (
<button
key={h.id}
type="button"
className="btn btn-secondary btn-full"
style={{ marginTop: 8, justifyContent: 'flex-start', textAlign: 'left', height: 'auto', padding: '10px 12px' }}
onClick={() => onSelect(h, unitExtras())}
>
<span>
<strong style={{ display: 'block' }}>{h.name_de}</strong>
<span style={{ fontSize: 12, color: 'var(--text3)' }}>
{h.bls_code ? `BLS ${h.bls_code}` : 'ohne Code'}
{h.food_group ? ` · Gruppe ${h.food_group}` : ''}
{h.catalog_kind !== 'official_bls' ? ' · manuell' : ''}
</span>
</span>
</button>
))}
{hits.map((h) => {
const manual = h.catalog_kind && h.catalog_kind !== 'official_bls' && h.catalog_kind !== 'manual_admin'
return (
<div key={h.id} style={{ display: 'flex', gap: 8, marginTop: 8, alignItems: 'stretch' }}>
<button
type="button"
className="btn btn-secondary"
style={{ flex: 1, justifyContent: 'flex-start', textAlign: 'left', height: 'auto', padding: '10px 12px' }}
onClick={() => onSelect(h, unitExtras())}
>
<span>
<strong style={{ display: 'block' }}>{h.name_de}</strong>
<span style={{ fontSize: 12, color: 'var(--text3)' }}>
{h.bls_code ? `BLS ${h.bls_code}` : 'ohne Code'}
{h.food_group ? ` · Gruppe ${h.food_group}` : ''}
{foodVisibilitySuffix(h.catalog_kind, h.visibility)}
</span>
</span>
</button>
{manual && (
<button type="button" className="btn btn-secondary" style={{ flexShrink: 0 }} onClick={() => setEditId(h.id)}>
Bearbeiten
</button>
)}
</div>
)
})}
<div style={{ marginTop: 16, paddingTop: 12, borderTop: '1px solid var(--border)' }}>
{!showCreate ? (
@@ -262,5 +275,14 @@ export default function FoodSearchModal({ title, initialQuery, quantityHint, all
</div>
</div>
</div>
{editId && (
<FoodEditDialog
foodId={editId}
zIndex={(zIndex || 20000) + 2000}
onClose={() => setEditId(null)}
onSaved={() => runSearch(q)}
/>
)}
</>
)
}
+123
View File
@@ -0,0 +1,123 @@
import { useEffect, useMemo, useState } from 'react'
import { api } from '../utils/api'
import FoodEditDialog from './FoodEditDialog'
import { foodVisibilitySuffix } from '../utils/foodVisibility'
function filterByName(list, term) {
if (!term) return list
return list.filter((f) => (f.name_de || '').toLowerCase().includes(term))
}
export default function MyFoodsPanel() {
const [foods, setFoods] = useState([])
const [shared, setShared] = useState([])
const [q, setQ] = useState('')
const [visible, setVisible] = useState(60)
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)
const [notice, setNotice] = useState(null)
const [editId, setEditId] = useState(null)
const [creating, setCreating] = useState(false)
const load = async () => {
try {
const [mine, central] = await Promise.all([
api.listMyFoods(),
api.listSharedFoods().catch(() => []),
])
setFoods(Array.isArray(mine) ? mine : [])
setShared(Array.isArray(central) ? central : [])
setError(null)
} catch (e) {
setError(e.message)
} finally {
setLoading(false)
}
}
useEffect(() => { load() }, [])
const term = q.trim().toLowerCase()
const filteredMine = useMemo(() => filterByName(foods, term), [foods, term])
const filteredShared = useMemo(() => filterByName(shared, term), [shared, term])
const shownMine = filteredMine.slice(0, visible)
const afterSave = (res) => {
load()
const n = res?.rebuild_pending
if (n) setNotice(`Gespeichert. Tageswerte für ${n} Tag${n === 1 ? '' : 'e'} werden nachgerechnet.`)
else setNotice('Lebensmittel gespeichert.')
}
return (
<div className="card section-gap">
<div className="card-title">Lebensmittel</div>
<p style={{ fontSize: 13, color: 'var(--text2)', lineHeight: 1.6, marginBottom: 12 }}>
<strong>Persönlich:</strong> nur für dich. <strong>Zentral:</strong> vom Admin für alle Nutzer.
BLS-Katalog suchst du beim Zuordnen. Ein Öl/Supplement bleibt ein Lebensmittel, keine Liste.
</p>
{error && <div style={{ color: 'var(--danger)', fontSize: 13, marginBottom: 10 }}>{error}</div>}
{notice && <div style={{ fontSize: 13, color: 'var(--accent-dark)', marginBottom: 10 }}>{notice}</div>}
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, marginBottom: 12 }}>
<button type="button" className="btn btn-primary" onClick={() => setCreating(true)}>Persönliches Lebensmittel anlegen</button>
</div>
<input
className="form-input"
style={{ width: '100%', textAlign: 'left', marginBottom: 8 }}
placeholder="Persönliche und zentrale Einträge suchen…"
value={q}
onChange={(e) => { setQ(e.target.value); setVisible(60) }}
/>
<h3 style={{ fontSize: 14, margin: '16px 0 8px' }}>Persönlich ({loading ? '…' : filteredMine.length})</h3>
{!loading && foods.length === 0 && (
<p className="muted">Noch keine eigenen Einträge. Hier anlegen oder beim Zuordnen über „Neu anlegen“.</p>
)}
{!loading && foods.length > 0 && filteredMine.length === 0 && (
<p className="muted">Kein persönlicher Treffer für „{q.trim()}“.</p>
)}
{shownMine.map((f) => (
<div key={f.id} style={{ display: 'flex', justifyContent: 'space-between', gap: 8, padding: '10px 0', borderTop: '1px solid var(--border)', alignItems: 'center' }}>
<div>
<div style={{ fontWeight: 600 }}>{f.name_de}</div>
<div style={{ fontSize: 12, color: 'var(--text3)' }}>nur du</div>
</div>
<button type="button" className="btn btn-secondary" style={{ fontSize: 12 }} onClick={() => setEditId(f.id)}>Bearbeiten</button>
</div>
))}
{visible < filteredMine.length && (
<button type="button" className="btn btn-secondary btn-full" style={{ marginTop: 8 }} onClick={() => setVisible((n) => n + 60)}>
Weitere {Math.min(60, filteredMine.length - visible)} zeigen
</button>
)}
<h3 style={{ fontSize: 14, margin: '20px 0 8px' }}>Zentral für alle ({loading ? '…' : filteredShared.length})</h3>
{!loading && shared.length === 0 && (
<p className="muted">Noch keine zentralen Einträge vom Admin.</p>
)}
{!loading && shared.length > 0 && filteredShared.length === 0 && (
<p className="muted">Kein zentraler Treffer für „{q.trim()}“.</p>
)}
{filteredShared.map((f) => (
<div key={f.id} style={{ padding: '10px 0', borderTop: '1px solid var(--border)' }}>
<div style={{ fontWeight: 600 }}>{f.name_de}</div>
<div style={{ fontSize: 12, color: 'var(--text3)' }}>für alle Nutzer{foodVisibilitySuffix(f.catalog_kind, f.visibility)}</div>
</div>
))}
{(creating || editId) && (
<FoodEditDialog
foodId={creating ? null : editId}
onClose={() => { setCreating(false); setEditId(null) }}
onSaved={(res) => {
setCreating(false)
setEditId(null)
afterSave(res)
}}
/>
)}
</div>
)
}
+30 -6
View File
@@ -3,6 +3,8 @@ import { api } from '../utils/api'
import FoodSearchModal from './FoodSearchModal'
import FoodNutrientFields, { foodCreatePayload } from './FoodNutrientFields'
import FoodRecipeDialog from './FoodRecipeDialog'
import FoodEditDialog from './FoodEditDialog'
import { foodVisibilitySuffix } from '../utils/foodVisibility'
const PERIODS = [
{ days: 14, label: '14 Tage' },
@@ -127,7 +129,7 @@ function InlineCreate({ defaultName, disabled, allowRecipe, onCreateFood, onWant
)
}
export default function NutritionFoodMap({ onChanged, onMapped, onManageLists, onCreatedList }) {
export default function NutritionFoodMap({ onChanged, onMapped, onManageLists, onCreatedList, onOpenMyFoods }) {
const [unmapped, setUnmapped] = useState([])
const [learned, setLearned] = useState([])
const [recipes, setRecipes] = useState([])
@@ -144,6 +146,7 @@ export default function NutritionFoodMap({ onChanged, onMapped, onManageLists, o
const [q, setQ] = useState('')
const [visible, setVisible] = useState(80)
const [showLearned, setShowLearned] = useState(false)
const [editFoodId, setEditFoodId] = useState(null)
const [importing, setImporting] = useState(false)
const [busy, setBusy] = useState(false)
const listRef = useRef(null)
@@ -371,6 +374,7 @@ export default function NutritionFoodMap({ onChanged, onMapped, onManageLists, o
<input ref={listRef} type="file" accept=".csv,text/csv" style={{ display: 'none' }} onChange={(e) => { const f = e.target.files?.[0]; e.target.value = ''; if (f) importLists(f) }} />
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, marginBottom: 8 }}>
<button type="button" className="btn btn-primary" onClick={() => onManageLists?.()}>Listen verwalten</button>
<button type="button" className="btn btn-secondary" onClick={() => onOpenMyFoods?.()}>Meine Lebensmittel</button>
<button type="button" className="btn btn-secondary" disabled={importing} onClick={() => listRef.current?.click()}>
{importing ? 'Importiere Listen…' : 'FDDB-Listen importieren'}
</button>
@@ -448,7 +452,9 @@ export default function NutritionFoodMap({ onChanged, onMapped, onManageLists, o
<div style={{ marginTop: 8, display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' }}>
<span style={{ fontSize: 13 }}>
→ <strong>{best.name_de}</strong>
<span style={{ color: 'var(--text3)' }}>{best.bls_code ? ` · ${best.bls_code}` : ' · manuell'}</span>
<span style={{ color: 'var(--text3)' }}>
{best.bls_code ? ` · ${best.bls_code}` : foodVisibilitySuffix(best.catalog_kind, best.visibility)}
</span>
</span>
<button type="button" className="btn btn-primary" disabled={busyRow} onClick={() => assign(u, best.id, {}, best)}>
Bestätigen
@@ -457,7 +463,7 @@ export default function NutritionFoodMap({ onChanged, onMapped, onManageLists, o
)}
{suggestions.slice(1).map((s) => (
<div key={s.id} style={{ marginTop: 6, display: 'flex', flexWrap: 'wrap', gap: 8, alignItems: 'center' }}>
<span style={{ fontSize: 12, color: 'var(--text2)' }}>oder {s.name_de}{s.bls_code ? ` · ${s.bls_code}` : ''}</span>
<span style={{ fontSize: 12, color: 'var(--text2)' }}>oder {s.name_de}{s.bls_code ? ` · ${s.bls_code}` : foodVisibilitySuffix(s.catalog_kind, s.visibility)}</span>
<button type="button" className="btn btn-secondary" disabled={busyRow} onClick={() => assign(u, s.id, {}, s)}>Übernehmen</button>
</div>
))}
@@ -510,15 +516,20 @@ export default function NutritionFoodMap({ onChanged, onMapped, onManageLists, o
</button>
</h3>
{showLearned && learned.map((m) => (
<div key={m.id} style={{ display: 'flex', justifyContent: 'space-between', gap: 8, padding: '8px 0', borderTop: '1px solid var(--border)' }}>
<div key={m.id} style={{ display: 'flex', justifyContent: 'space-between', gap: 8, padding: '8px 0', borderTop: '1px solid var(--border)', alignItems: 'center' }}>
<div>
<div style={{ fontWeight: 500 }}>{m.source_name_raw}</div>
<div style={{ fontSize: 12, color: 'var(--text3)' }}>
→ {m.food_name_de}{m.bls_code ? ` · ${m.bls_code}` : ''}
{m.catalog_kind !== 'official_bls' ? ' (manuell)' : ''}
{foodVisibilitySuffix(m.catalog_kind, m.visibility)}
</div>
</div>
<button type="button" className="btn btn-secondary" onClick={() => remove(m.id)}>Löschen</button>
<div style={{ display: 'flex', gap: 8, flexShrink: 0 }}>
{m.catalog_kind === 'manual_user' && m.food_id && (
<button type="button" className="btn btn-secondary" onClick={() => setEditFoodId(m.food_id)}>Bearbeiten</button>
)}
<button type="button" className="btn btn-secondary" onClick={() => remove(m.id)}>Löschen</button>
</div>
</div>
))}
@@ -558,6 +569,19 @@ export default function NutritionFoodMap({ onChanged, onMapped, onManageLists, o
{recipeFor && (
<RecipePickModal recipes={recipes} sourceName={recipeFor.source_name_raw} onClose={() => setRecipeFor(null)} onPick={(id) => applyRecipe(recipeFor.source_name_raw, id)} />
)}
{editFoodId && (
<FoodEditDialog
foodId={editFoodId}
onClose={() => setEditFoodId(null)}
onSaved={(res) => {
load()
onChanged?.()
const n = res?.rebuild_pending
if (n) setNotice(`Lebensmittel gespeichert. Tageswerte für ${n} Tag${n === 1 ? '' : 'e'} werden nachgerechnet.`)
else setNotice('Lebensmittel gespeichert.')
}}
/>
)}
</div>
)
}