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

@ -28,13 +28,8 @@ const isGeneratingQR = ref(false)
const transactions = computed(() => walletService?.transactions?.value || [])
const isLoading = computed(() => walletService?.isLoading?.value || false)
const error = computed(() => walletService?.error?.value)
const currentUser = computed(() => authService?.currentUser?.value)
const totalBalance = computed(() => {
if (!currentUser.value?.wallets) return 0
return currentUser.value.wallets.reduce((total: number, wallet: any) => {
return total + (wallet.balance_msat || 0)
}, 0)
})
// Use PaymentService for centralized balance calculation
const totalBalance = computed(() => paymentService?.totalBalance || 0)
const payLinks = computed(() => walletService?.payLinks?.value || [])
const firstPayLink = computed(() => payLinks.value[0] || null)