diff --git a/assets/js/app.js b/assets/js/app.js index f862a0e..72517d4 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -14989,6 +14989,194 @@ async function loadRecipeArchive() { container.innerHTML = html; } +// ===== RECIPE LIBRARY (recettes manuelles, ex: cocktails) ===== + +let _recipeLibraryCache = []; + +async function loadRecipeLibrary() { + const container = document.getElementById('recipe-library-list'); + if (!container) return; + container.innerHTML = `
Chargement…
`; + try { + const result = await api('recipe_library_list', {}, 'GET'); + if (!result.success) { + container.innerHTML = `Erreur de chargement.
`; + return; + } + _recipeLibraryCache = result.recipes; + renderRecipeLibraryList(result.recipes); + } catch (e) { + container.innerHTML = `Erreur de chargement.
`; + } +} + +function renderRecipeLibraryList(recipes) { + const container = document.getElementById('recipe-library-list'); + if (!container) return; + if (!recipes || recipes.length === 0) { + container.innerHTML = `Aucune recette pour l'instant.
`; + return; + } + container.innerHTML = recipes.map(entry => { + const r = entry.recipe; + const favBadge = entry.is_favorite ? `★` : ''; + const ingCount = (r.ingredients || []).length; + return ` +