From f4dbf9b340903a3ea4498e454e075944a242b4a3 Mon Sep 17 00:00:00 2001 From: padreug Date: Mon, 8 Sep 2025 12:34:34 +0200 Subject: [PATCH] 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. --- src/modules/market/views/MarketDashboard.vue | 25 ++++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/modules/market/views/MarketDashboard.vue b/src/modules/market/views/MarketDashboard.vue index 4a823c8..f545e7a 100644 --- a/src/modules/market/views/MarketDashboard.vue +++ b/src/modules/market/views/MarketDashboard.vue @@ -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 // )