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 OrderHistory from '../components/OrderHistory.vue'
|
||||||
import MerchantStore from '../components/MerchantStore.vue'
|
import MerchantStore from '../components/MerchantStore.vue'
|
||||||
import MarketSettings from '../components/MarketSettings.vue'
|
import MarketSettings from '../components/MarketSettings.vue'
|
||||||
|
import { auth } from '@/composables/useAuthService'
|
||||||
|
|
||||||
// const auth = useAuth()
|
|
||||||
const marketStore = useMarketStore()
|
const marketStore = useMarketStore()
|
||||||
|
|
||||||
// Local state
|
// Local state
|
||||||
const activeTab = ref('overview')
|
const activeTab = ref('overview')
|
||||||
|
|
||||||
// Computed properties for tab badges
|
// Computed properties for tab badges
|
||||||
const orderCount = computed(() => Object.keys(marketStore.orders).length)
|
const orderCount = computed(() => {
|
||||||
const pendingOrders = computed(() =>
|
// Count orders where current user is the buyer
|
||||||
Object.values(marketStore.orders).filter(o => o.status === 'pending').length
|
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(() =>
|
// const pendingPayments = computed(() =>
|
||||||
// Object.values(marketStore.orders).filter(o => o.paymentStatus === 'pending').length
|
// Object.values(marketStore.orders).filter(o => o.paymentStatus === 'pending').length
|
||||||
// )
|
// )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue