diff --git a/apps/api/src/routes/scans.ts b/apps/api/src/routes/scans.ts index 90897aa..a69ef88 100644 --- a/apps/api/src/routes/scans.ts +++ b/apps/api/src/routes/scans.ts @@ -151,11 +151,13 @@ export async function scanRoutes(app: FastifyInstance) { id: schema.inventoryItems.id, canonicalIngredientId: schema.inventoryItems.canonicalIngredientId, displayName: schema.inventoryItems.displayName, + storageLocationId: schema.inventoryItems.storageLocationId, }) .from(schema.inventoryItems) .where( and( eq(schema.inventoryItems.householdId, householdId), + isNull(schema.inventoryItems.depletedAt), gt(schema.inventoryItems.quantity, 0), ), ); @@ -175,11 +177,14 @@ export async function scanRoutes(app: FastifyInstance) { // Matcha på katalog-id ELLER normaliserat namn — Vision skriver sällan // exakt samma namn två gånger ("Mjölk" vs "mjölk" vs "Mjölk 1L"). const wantNorm = normalizeItemName(item.displayName); + // Slå bara ihop inom SAMMA förvaringsplats – "Mjölk" i kylen och "Mjölk" + // i frysen är olika varor och ska inte slås ihop till en rad. const dupe = activeItems.find( (r) => - (item.canonicalIngredientId != null && + r.storageLocationId === locationId && + ((item.canonicalIngredientId != null && r.canonicalIngredientId === item.canonicalIngredientId) || - r.norm === wantNorm, + r.norm === wantNorm), ); if (dupe) { await app.db @@ -230,6 +235,7 @@ export async function scanRoutes(app: FastifyInstance) { id: inv!.id, canonicalIngredientId: item.canonicalIngredientId ?? null, displayName: item.displayName, + storageLocationId: locationId, norm: wantNorm, }); diff --git a/apps/mobile/src/app/kitchen.tsx b/apps/mobile/src/app/kitchen.tsx index 67a37c2..6da4904 100644 --- a/apps/mobile/src/app/kitchen.tsx +++ b/apps/mobile/src/app/kitchen.tsx @@ -1,5 +1,5 @@ import { useMemo, useState } from "react"; -import { Alert, View } from "react-native"; +import { Alert, Pressable, View } from "react-native"; import { useLocalSearchParams } from "expo-router"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { api } from "@/lib/api"; @@ -193,12 +193,22 @@ export default function KitchenScreen() { onPress={() => toggle(item.id)} style={isSel ? { borderColor: colors.primary, backgroundColor: colors.primarySoft } : undefined} > - + {isSel ? "☑ " : "☐ "} {item.displayName} · {formatQuantity(item.quantity, item.unit)} - {item.expiry.pastBestBefore && ⚠︎ bäst före} + + {item.expiry.pastBestBefore && ⚠︎ bäst före} + confirmDelete([item.id], locLabel(item.locationType))} + hitSlop={8} + > + + {t("common.remove")} + + + );