Enhance PaymentService and useTicketPurchase composable for improved wallet handling

- Introduced asynchronous methods in PaymentService for retrieving user wallets and checking wallet balances, allowing for dual authentication detection.
- Updated getUserWalletsAsync, hasWalletWithBalanceAsync, and getWalletWithBalanceAsync methods to streamline wallet access and balance checks.
- Refactored useTicketPurchase composable to load user wallets asynchronously on component mount, improving user experience during ticket purchases.
- Enhanced error handling and logging for wallet loading and payment processes.

These changes improve the reliability and responsiveness of wallet interactions within the payment flow.
This commit is contained in:
padreug 2025-09-07 00:19:43 +02:00
parent 5a899d1501
commit 5633aa154b
3 changed files with 123 additions and 16 deletions

View file

@ -1,6 +1,6 @@
<!-- eslint-disable vue/multi-word-component-names -->
<script setup lang="ts">
import { onUnmounted } from 'vue'
import { onUnmounted, watch } from 'vue'
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
@ -44,7 +44,8 @@ const {
cleanup,
ticketQRCode,
purchasedTicketId,
showTicketQR
showTicketQR,
loadWallets
} = useTicketPurchase()
async function handlePurchase() {
@ -62,6 +63,13 @@ function handleClose() {
resetPaymentState()
}
// Reload wallets when dialog opens
watch(() => props.isOpen, async (newVal) => {
if (newVal && isAuthenticated.value) {
await loadWallets()
}
})
// Cleanup on unmount
onUnmounted(() => {
cleanup()