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

@ -232,6 +232,7 @@ const emit = defineEmits<{
// Services
const nostrmarketAPI = injectService(SERVICE_TOKENS.NOSTRMARKET_API) as NostrmarketAPI
const paymentService = injectService(SERVICE_TOKENS.PAYMENT_SERVICE) as any
const toast = useToast()
// Local state
@ -336,8 +337,13 @@ const updateProduct = async (formData: any) => {
}
}
const adminKey = paymentService.getPreferredWalletAdminKey()
if (!adminKey) {
throw new Error('No wallet admin key available')
}
const updatedProduct = await nostrmarketAPI.updateProduct(
currentUser.wallets[0].adminkey,
adminKey,
props.product.id,
productData
)
@ -398,8 +404,13 @@ const createProduct = async (formData: any) => {
}
}
const adminKey = paymentService.getPreferredWalletAdminKey()
if (!adminKey) {
throw new Error('No wallet admin key available')
}
const newProduct = await nostrmarketAPI.createProduct(
currentUser.wallets[0].adminkey,
adminKey,
productData
)