diff --git a/NEXT_STEPS.md b/NEXT_STEPS.md index aa79c9fb..a6514076 100644 --- a/NEXT_STEPS.md +++ b/NEXT_STEPS.md @@ -19,7 +19,13 @@ Kategorier skrivs in fritt i admin i dag. Det vore bättre med en dropdownlista ### 4. Bild på recept `imageUrl`-kolumnen finns i databasen (migrerad). Backend och frontend saknar stöd för att visa eller ladda upp receptbilder. -### 5. Matplanering +### 5. Filtrering och sortering av receptlistan +Receptlistan visas i dag utan möjlighet att filtrera eller sortera. Lägg till stöd för att filtrera på kategori/tagg och sortera på t.ex. namn eller senast tillagd. Kan implementeras i frontend (klientside) eller som query-parametrar till backend. + +### 6. Layout och presentation av receptlistan +Receptlistan (`app/recipes/RecipeGrid.tsx`) är en enkel lista. Förbättra presentationen med t.ex. ett kortrutnät med bild, kortnamn och eventuellt tillagningstid — liknande ett receptkort i stil med en matblogg. + +### 7. Matplanering Lägg till en enkel veckomenylista: välj ett recept per dag, se en samlad ingredienslista och jämför mot inventariet. Kräver en ny `MealPlan`-modell i Prisma. --- diff --git a/compose.yml b/compose.yml index 98c77e6f..0656faeb 100644 --- a/compose.yml +++ b/compose.yml @@ -55,6 +55,7 @@ services: recipe-db: image: mariadb:11 + container_name: recipe-db restart: unless-stopped environment: MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD} diff --git a/frontend/app/baslager/PantryList.tsx b/frontend/app/baslager/PantryList.tsx index f04b8a12..a64691e1 100644 --- a/frontend/app/baslager/PantryList.tsx +++ b/frontend/app/baslager/PantryList.tsx @@ -8,11 +8,18 @@ type PantryItem = { product: { id: number; name: string; canonicalName: string | null; category: string | null }; }; -type Props = { - items: PantryItem[]; +type InventoryItem = { + productId: number; + quantity: string; + unit: string; }; -export default function PantryList({ items }: Props) { +type Props = { + items: PantryItem[]; + inventoryByProductId: Record; +}; + +export default function PantryList({ items, inventoryByProductId }: Props) { const [isPending, startTransition] = useTransition(); function handleRemove(id: number, name: string) { @@ -54,6 +61,19 @@ export default function PantryList({ items }: Props) {
{grouped[category].map((item) => { const displayName = item.product.canonicalName || item.product.name; + const invItems = inventoryByProductId[item.product.id] || []; + const hasInventory = invItems.length > 0; + + // Summera per enhet för visning + const unitSummary = invItems.reduce>((acc, inv) => { + const u = inv.unit || '?'; + acc[u] = (acc[u] || 0) + parseFloat(inv.quantity || '0'); + return acc; + }, {}); + const inventoryText = Object.entries(unitSummary) + .map(([u, q]) => `${q % 1 === 0 ? q : q.toFixed(1)} ${u}`) + .join(', '); + return (
- {displayName} +
+ + {hasInventory ? '✓' : '○'} + + {displayName} + {hasInventory ? ( + + {inventoryText} + + ) : ( + + Saknas i inventariet + + )} +
)} + + {/* SPARAT */} + {step === 'saved' && ( +
+
+

Receptet sparades!

+

Du skickas strax till receptlistan...

+
+ )} ); }