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:
parent
8e34f2c74e
commit
f4dbf9b340
1 changed files with 20 additions and 5 deletions
|
|
@ -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
|
||||
// )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue