From 2bbb715ebb77643af50c7e044772231209bd44f7 Mon Sep 17 00:00:00 2001 From: Tiago Yamamoto Date: Tue, 23 Dec 2025 16:29:08 -0300 Subject: [PATCH] fix(marketplace): filter out own store products by 0km distance - For owners/sellers, exclude products at exactly 0km (own pharmacy) - This correctly hides own products without needing company_id in JWT --- marketplace/src/pages/ProductSearch.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/marketplace/src/pages/ProductSearch.tsx b/marketplace/src/pages/ProductSearch.tsx index d1a6217..cadfd3a 100644 --- a/marketplace/src/pages/ProductSearch.tsx +++ b/marketplace/src/pages/ProductSearch.tsx @@ -64,8 +64,15 @@ const ProductSearch = () => { // Filter out products from the logged-in user's pharmacy and group by name const groupedProducts = useMemo(() => { - // Filter out own products - const filteredProducts = products.filter(p => p.seller_id !== user?.id) + // Filter out own products - for owners/sellers, products at 0km are from their own store + const isOwnerOrSeller = user?.role === 'owner' || user?.role === 'seller' + const filteredProducts = products.filter(p => { + // Exclude products at exactly 0km distance for owners (own store) + if (isOwnerOrSeller && p.distance_km === 0) { + return false + } + return true + }) // Group by name (case-insensitive) const groups: Record = {}