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
This commit is contained in:
parent
e7b02f24e7
commit
2bbb715ebb
1 changed files with 9 additions and 2 deletions
|
|
@ -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<string, GroupedProduct> = {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue