feat: Listen-Dialog mit Mengen/Einheiten, Mitai ohne Kochrezepte
Deploy Development / deploy (push) Successful in 1m7s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 22s

Roh-Kombinationen statt Rezept-Sprache; Zutaten suchen, EL/TL/Prise auf Gramm. Gekochte Gerichte und Ausbeute bleiben Tandoor.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-09-12 18:23:01 +02:00
1 parent a7e5511039
commit fa542e0fb9
17 files changed
+776 -203

No files matched your search

+6 -16
View File
@@ -1,7 +1,6 @@
import { useEffect, useRef, useState } from 'react'
import { api } from '../utils/api'
import FoodNutrientFields, { foodCreatePayload } from './FoodNutrientFields'
import { RecipeForm } from './FoodRecipeEditor'
const COUNT_UNITS = new Set(['stück', 'scheibe', 'portion', 'becher', 'tasse'])
const UNIT_LABEL = {
@@ -26,7 +25,7 @@ function detectUnit(...texts) {
return null
}
export default function FoodSearchModal({ title, initialQuery, quantityHint, allowRecipe, learned, onSelect, onCreateRecipe, onClose }) {
export default function FoodSearchModal({ title, initialQuery, quantityHint, allowRecipe, onSelect, onWantRecipe, onClose }) {
const [q, setQ] = useState(initialQuery || '')
const [hits, setHits] = useState([])
const [loading, setLoading] = useState(false)
@@ -210,30 +209,21 @@ export default function FoodSearchModal({ title, initialQuery, quantityHint, all
{!showCreate ? (
<button type="button" className="btn btn-secondary btn-full" onClick={() => {
setShowCreate(true)
setCreateKind(allowRecipe && onCreateRecipe ? null : 'food')
setCreateKind(allowRecipe && onWantRecipe ? null : 'food')
setManual((s) => ({ ...s, name_de: s.name_de || q || initialQuery || '' }))
}}>
{allowRecipe && onCreateRecipe ? 'Lebensmittel oder Rezept anlegen' : 'Eigenes Lebensmittel anlegen'}
{allowRecipe && onWantRecipe ? 'Lebensmittel oder Liste anlegen' : 'Eigenes Lebensmittel anlegen'}
</button>
) : !createKind ? (
<div>
<p style={{ fontSize: 13, fontWeight: 600, marginBottom: 8 }}>Was möchtest du anlegen?</p>
<p style={{ fontSize: 12, color: 'var(--text2)', margin: '0 0 8px' }}>Lebensmittel = ein Katalogeintrag. Rezept = mehrere Zutaten; offene Zutaten erscheinen danach in der Liste.</p>
<p style={{ fontSize: 12, color: 'var(--text2)', margin: '0 0 8px' }}>Lebensmittel = ein Katalogeintrag. Liste = Roh-Kombination (z. B. Müsli) mit Zutatensuche.</p>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
<button type="button" className="btn btn-primary" onClick={() => setCreateKind('food')}>Lebensmittel</button>
<button type="button" className="btn btn-secondary" onClick={() => setCreateKind('recipe')}>Rezept</button>
<button type="button" className="btn btn-secondary" onClick={onWantRecipe}>Liste</button>
<button type="button" className="btn btn-secondary" onClick={() => { setShowCreate(false); setCreateKind(null) }}>Zurück</button>
</div>
</div>
) : createKind === 'recipe' ? (
<RecipeForm
defaultName={manual.name_de || q || initialQuery || ''}
learned={learned}
disabled={creating}
submitLabel="Rezept anlegen und zuordnen"
onCancel={() => setCreateKind(null)}
onSave={onCreateRecipe}
/>
) : (
<div>
<p style={{ fontSize: 13, fontWeight: 600, marginBottom: 8 }}>Eigener Eintrag</p>
@@ -253,7 +243,7 @@ export default function FoodSearchModal({ title, initialQuery, quantityHint, all
setServingG={setServingG}
/>
<div style={{ display: 'flex', gap: 8, marginTop: 10 }}>
{allowRecipe && onCreateRecipe && (
{allowRecipe && onWantRecipe && (
<button type="button" className="btn btn-secondary" disabled={creating} onClick={() => setCreateKind(null)}>Zurück</button>
)}
<button