Refactor wallet balance handling and integrate PaymentService for centralized management

- Replaced direct wallet balance computation in Navbar and WalletPage with a centralized totalBalance property from PaymentService, improving code maintainability.
- Updated CreateProductDialog, CreateStoreDialog, and MerchantStore components to utilize PaymentService for retrieving wallet admin and invoice keys, enhancing consistency across the application.
- These changes streamline wallet management and improve the overall architecture of the wallet module.
This commit is contained in:
padreug 2025-09-17 20:23:46 +02:00
parent c064b0b40d
commit e5db949aae
6 changed files with 69 additions and 21 deletions

View file

@ -353,6 +353,7 @@ import StoreCard from './StoreCard.vue'
const router = useRouter()
const marketStore = useMarketStore()
const nostrmarketAPI = injectService(SERVICE_TOKENS.NOSTRMARKET_API) as NostrmarketAPI
const paymentService = injectService(SERVICE_TOKENS.PAYMENT_SERVICE) as any
const toast = useToast()
// Local state
@ -473,8 +474,15 @@ const loadStallsList = async () => {
}
isLoadingStalls.value = true
const inkey = paymentService.getPreferredWalletInvoiceKey()
if (!inkey) {
console.error('No wallet invoice key available')
return
}
try {
const stalls = await nostrmarketAPI.getStalls(currentUser.wallets[0].inkey)
const stalls = await nostrmarketAPI.getStalls(inkey)
userStalls.value = stalls || []
// If there are stalls but no active one selected, select the first
@ -496,9 +504,16 @@ const loadStallProducts = async () => {
if (!currentUser?.wallets?.length) return
isLoadingProducts.value = true
const inkey = paymentService.getPreferredWalletInvoiceKey()
if (!inkey) {
console.error('No wallet invoice key available')
return
}
try {
const products = await nostrmarketAPI.getProducts(
currentUser.wallets[0].inkey,
inkey,
activeStall.value.id!
)
stallProducts.value = products || []