Enhance MarketDashboard to filter orders by current user

- Introduce computed properties to count orders based on the current user's public key.
- Update orderCount to reflect only the user's orders as a buyer.
- Update pendingOrders to count only the user's pending orders as a seller.
- Improve user experience by providing personalized order statistics.

These changes ensure that users can easily track their own orders and pending transactions within the MarketDashboard.
This commit is contained in:
padreug 2025-09-08 12:34:34 +02:00
parent 8e34f2c74e
commit f4dbf9b340

View file

@ -73,18 +73,33 @@ import DashboardOverview from '../components/DashboardOverview.vue'
import OrderHistory from '../components/OrderHistory.vue'
import MerchantStore from '../components/MerchantStore.vue'
import MarketSettings from '../components/MarketSettings.vue'
import { auth } from '@/composables/useAuthService'
// const auth = useAuth()
const marketStore = useMarketStore()
// Local state
const activeTab = ref('overview')
// Computed properties for tab badges
const orderCount = computed(() => Object.keys(marketStore.orders).length)
const pendingOrders = computed(() =>
Object.values(marketStore.orders).filter(o => o.status === 'pending').length
)
const orderCount = computed(() => {
// Count orders where current user is the buyer
const currentUserPubkey = auth.currentUser?.value?.pubkey
if (!currentUserPubkey) return 0
return Object.values(marketStore.orders).filter(order =>
order.buyerPubkey === currentUserPubkey
).length
})
const pendingOrders = computed(() => {
// Count pending orders where current user is the seller
const currentUserPubkey = auth.currentUser?.value?.pubkey
if (!currentUserPubkey) return 0
return Object.values(marketStore.orders).filter(order =>
order.sellerPubkey === currentUserPubkey && order.status === 'pending'
).length
})
// const pendingPayments = computed(() =>
// Object.values(marketStore.orders).filter(o => o.paymentStatus === 'pending').length
// )