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
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue