From e21349511d1144326018cc682095e3a96d4306bd Mon Sep 17 00:00:00 2001 From: Gilles Soulier Date: Sun, 24 May 2026 15:52:44 +0200 Subject: [PATCH] =?UTF-8?q?feat(shopping):=20bouton=20liste=20magique=20+?= =?UTF-8?q?=20modal=20=C3=A9dition=20liste=20avec=20suppression?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/pages/ShoppingPage.tsx | 144 +++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/ShoppingPage.tsx b/frontend/src/pages/ShoppingPage.tsx index 1fb7d16..d1f10b5 100644 --- a/frontend/src/pages/ShoppingPage.tsx +++ b/frontend/src/pages/ShoppingPage.tsx @@ -3,7 +3,7 @@ import { useState, useEffect, useCallback } from 'react' import type { ShoppingList, ShoppingListDetail, ShoppingItem, Store } from '../api/shopping' import { fetchLists, createList, fetchListDetail, updateList, deleteList, - addItem, updateItem, deleteItem, finishShopping, fetchStores, + addItem, updateItem, deleteItem, finishShopping, fetchStores, generateMagicList, } from '../api/shopping' import Modal from '../components/Modal' import ItemRow from '../components/shopping/ItemRow' @@ -44,6 +44,8 @@ export default function ShoppingPage() { const [error, setError] = useState(null) const [showCreateModal, setShowCreateModal] = useState(false) const [showAddItemModal, setShowAddItemModal] = useState(false) + const [showEditListModal, setShowEditListModal] = useState(false) + const [generating, setGenerating] = useState(false) const [newListName, setNewListName] = useState('') const [newListStore, setNewListStore] = useState('') @@ -164,6 +166,33 @@ export default function ShoppingPage() { } } + async function handleGenerateMagicList() { + setGenerating(true) + setError(null) + try { + const newList = await generateMagicList() + void loadLists() + setActiveList(newList) + setView('detail') + } catch { + setError('Erreur lors de la génération') + } finally { + setGenerating(false) + } + } + + async function handleDeleteActiveList() { + if (!activeList) return + try { + await deleteList(activeList.id) + setView('lists') + setActiveList(null) + void loadLists() + } catch { + setError('Erreur lors de la suppression') + } + } + // ── Vue mode magasin ────────────────────────────────────────────────────── if (view === 'store' && activeList) { const unchecked = activeList.items.filter(i => !i.is_checked) @@ -250,6 +279,22 @@ export default function ShoppingPage() { {activeList.checked_count}/{activeList.item_count} cochés + + +
+ + + + )}
) } @@ -338,8 +452,34 @@ export default function ShoppingPage() { // ── Vue liste des listes ─────────────────────────────────────────────────── return (
-
+

Courses

+
{error && (