refactor: use single POST /events endpoint with invoice key

Remove proposeEvent(), consolidate to createEvent() with invoice key.
Backend determines approval status based on user role and settings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-04-27 18:24:36 +02:00
commit 31efc50fad
3 changed files with 9 additions and 23 deletions

View file

@ -134,24 +134,11 @@ export class TicketApiService {
} }
/** /**
* Create a new ticketed event in LNbits (admin). * Create a new event. Uses invoice key (any user).
* Backend determines approval status based on user role and settings.
*/ */
async createEvent(eventData: CreateEventRequest, adminKey: string): Promise<TicketedEvent> { async createEvent(eventData: CreateEventRequest, invoiceKey: string): Promise<TicketedEvent> {
return this.request('/events/api/v1/events', { return this.request('/events/api/v1/events', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': adminKey,
},
body: JSON.stringify(eventData),
})
}
/**
* Propose a new event for admin approval (any user with invoice key).
*/
async proposeEvent(eventData: CreateEventRequest, invoiceKey: string): Promise<TicketedEvent> {
return this.request('/events/api/v1/events/propose', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View file

@ -66,7 +66,7 @@ async function handleCreateEvent(eventData: CreateEventRequest) {
if (!invoiceKey) { if (!invoiceKey) {
throw new Error('No wallet available. Please log in first.') throw new Error('No wallet available. Please log in first.')
} }
await ticketApi.proposeEvent(eventData, invoiceKey) await ticketApi.createEvent(eventData, invoiceKey)
} }
</script> </script>

View file

@ -49,14 +49,13 @@ function handlePurchaseClick(event: {
async function handleCreateEvent(eventData: CreateEventRequest) { async function handleCreateEvent(eventData: CreateEventRequest) {
const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService
const paymentService = injectService(SERVICE_TOKENS.PAYMENT_SERVICE) as any const { currentUser } = useAuth()
const invoiceKey = currentUser.value?.wallets?.[0]?.inkey
const adminKey = paymentService?.getPreferredWalletAdminKey?.() if (!invoiceKey) {
if (!adminKey) { throw new Error('No wallet available. Please log in first.')
throw new Error('No wallet admin key available. Please connect a wallet first.')
} }
await ticketApi.createEvent(eventData, adminKey) await ticketApi.createEvent(eventData, invoiceKey)
} }
function handleEventCreated() { function handleEventCreated() {