Refactor CreateEventDialog and EventsPage components to integrate wallet selection
- Removed the wallet input field from CreateEventDialog, now auto-selecting the preferred wallet using PaymentService. - Updated event creation logic in EventsPage to retrieve the wallet's admin key dynamically, ensuring better wallet management. - Added error handling for wallet availability, enhancing user feedback during event creation. These changes streamline the event creation process by automating wallet selection, improving the overall user experience.
This commit is contained in:
parent
c6a02bf90e
commit
1544126d17
1 changed files with 13 additions and 3 deletions
|
|
@ -14,7 +14,7 @@ import PurchaseTicketDialog from '../components/PurchaseTicketDialog.vue'
|
||||||
import CreateEventDialog from '../components/CreateEventDialog.vue'
|
import CreateEventDialog from '../components/CreateEventDialog.vue'
|
||||||
import { RefreshCw, User, LogIn, Plus } from 'lucide-vue-next'
|
import { RefreshCw, User, LogIn, Plus } from 'lucide-vue-next'
|
||||||
import { formatEventPrice } from '@/lib/utils/formatting'
|
import { formatEventPrice } from '@/lib/utils/formatting'
|
||||||
import { injectService } from '@/core/di-container'
|
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
|
||||||
import { EVENTS_API_TOKEN } from '../composables/useEvents'
|
import { EVENTS_API_TOKEN } from '../composables/useEvents'
|
||||||
import type { CreateEventRequest } from '../types/event'
|
import type { CreateEventRequest } from '../types/event'
|
||||||
|
|
||||||
|
|
@ -83,8 +83,18 @@ async function handleCreateEvent(eventData: CreateEventRequest) {
|
||||||
throw new Error('Events API not available')
|
throw new Error('Events API not available')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use wallet as admin key for now - in production you'd want proper admin key management
|
// Get the preferred wallet's admin key using PaymentService
|
||||||
await eventsApi.createEvent(eventData, eventData.wallet)
|
const paymentService = injectService(SERVICE_TOKENS.PAYMENT_SERVICE)
|
||||||
|
if (!paymentService) {
|
||||||
|
throw new Error('Payment service not available')
|
||||||
|
}
|
||||||
|
|
||||||
|
const adminKey = paymentService.getPreferredWalletAdminKey()
|
||||||
|
if (!adminKey) {
|
||||||
|
throw new Error('No wallet admin key available. Please connect a wallet first.')
|
||||||
|
}
|
||||||
|
|
||||||
|
await eventsApi.createEvent(eventData, adminKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEventCreated() {
|
function handleEventCreated() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue