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:
parent
c064b0b40d
commit
e5db949aae
6 changed files with 69 additions and 21 deletions
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue