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
|
|
@ -59,6 +59,15 @@ export class PaymentService extends BaseService {
|
|||
return this.authService?.user?.value?.wallets || []
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total balance across all user wallets in millisatoshis
|
||||
*/
|
||||
get totalBalance(): number {
|
||||
return this.userWallets.reduce((total: number, wallet: any) => {
|
||||
return total + (wallet.balance_msat || 0)
|
||||
}, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has any wallet with balance
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue