feat: UI fixes, ticket waves, ticket image (#52)
* email input fixes * promo code ui fix * ticket waves * works, but horrible slop * slightly cleaner * filter most recent * make * pyright
This commit is contained in:
parent
4bf867eef0
commit
777c107c63
12 changed files with 1557 additions and 302 deletions
|
|
@ -13,6 +13,7 @@ window.PageEventsDisplay = {
|
|||
email: '',
|
||||
refund: '',
|
||||
nostr_identifier: '',
|
||||
ticket_wave_id: null,
|
||||
payment_method: 'lightning'
|
||||
}
|
||||
},
|
||||
|
|
@ -40,16 +41,37 @@ window.PageEventsDisplay = {
|
|||
formatDescription() {
|
||||
return LNbits.utils.convertMarkdown(this.event?.info || '')
|
||||
},
|
||||
activeTicketWaves() {
|
||||
const today = new Date().toISOString().slice(0, 10)
|
||||
return (this.event?.extra?.ticket_waves || []).filter(
|
||||
wave =>
|
||||
wave.amount_tickets > 0 &&
|
||||
wave.opening_date <= today &&
|
||||
wave.closing_date >= today
|
||||
)
|
||||
},
|
||||
selectedTicketWave() {
|
||||
return (
|
||||
this.activeTicketWaves.find(
|
||||
wave => wave.id === this.formDialog.data.ticket_wave_id
|
||||
) ||
|
||||
this.activeTicketWaves[0] ||
|
||||
null
|
||||
)
|
||||
},
|
||||
showTicketWaveSelector() {
|
||||
return this.activeTicketWaves.length > 1
|
||||
},
|
||||
allowFiatCheckout() {
|
||||
return Boolean(this.event?.allow_fiat)
|
||||
return Boolean(this.selectedTicketWave?.allow_fiat)
|
||||
},
|
||||
fiatCheckoutLabel() {
|
||||
if (!this.allowFiatCheckout) return 'Fiat'
|
||||
const unit = ['sat', 'sats'].includes(
|
||||
(this.event?.currency || '').toLowerCase()
|
||||
(this.selectedTicketWave?.currency || '').toLowerCase()
|
||||
)
|
||||
? this.event?.fiat_currency
|
||||
: this.event?.currency
|
||||
? this.selectedTicketWave?.fiat_currency
|
||||
: this.selectedTicketWave?.currency
|
||||
return `Fiat (${(unit || 'GBP').toUpperCase()})`
|
||||
},
|
||||
allowEmailNotifications() {
|
||||
|
|
@ -66,6 +88,16 @@ window.PageEventsDisplay = {
|
|||
'GET',
|
||||
`/events/api/v1/events/${this.eventId}`
|
||||
)
|
||||
const activeWaves = (data.extra?.ticket_waves || []).filter(wave => {
|
||||
const today = new Date().toISOString().slice(0, 10)
|
||||
return (
|
||||
wave.amount_tickets > 0 &&
|
||||
wave.opening_date <= today &&
|
||||
wave.closing_date >= today
|
||||
)
|
||||
})
|
||||
this.formDialog.data.ticket_wave_id =
|
||||
activeWaves.length === 1 ? activeWaves[0].id : null
|
||||
return data
|
||||
} catch (error) {
|
||||
this.eventErrorLabel = 'Event unavailable.'
|
||||
|
|
@ -78,6 +110,10 @@ window.PageEventsDisplay = {
|
|||
this.formDialog.data.email = ''
|
||||
this.formDialog.data.refund = ''
|
||||
this.formDialog.data.nostr_identifier = ''
|
||||
this.formDialog.data.ticket_wave_id =
|
||||
this.activeTicketWaves.length === 1
|
||||
? this.activeTicketWaves[0].id
|
||||
: null
|
||||
this.formDialog.data.payment_method = 'lightning'
|
||||
},
|
||||
|
||||
|
|
@ -112,6 +148,10 @@ window.PageEventsDisplay = {
|
|||
this.formDialog.data.email = ''
|
||||
this.formDialog.data.refund = ''
|
||||
this.formDialog.data.nostr_identifier = ''
|
||||
this.formDialog.data.ticket_wave_id =
|
||||
this.activeTicketWaves.length === 1
|
||||
? this.activeTicketWaves[0].id
|
||||
: null
|
||||
this.formDialog.data.payment_method = 'lightning'
|
||||
Quasar.Notify.create({
|
||||
type: 'positive',
|
||||
|
|
@ -141,10 +181,13 @@ window.PageEventsDisplay = {
|
|||
{
|
||||
name: this.formDialog.data.name,
|
||||
email: this.formDialog.data.email,
|
||||
ticket_wave_id: this.formDialog.data.ticket_wave_id || null,
|
||||
promo_code: this.formDialog.data.promo_code || null,
|
||||
refund_address: this.formDialog.data.refund || null,
|
||||
nostr_identifier: this.formDialog.data.nostr_identifier || null,
|
||||
payment_method: this.formDialog.data.payment_method
|
||||
payment_method: this.allowFiatCheckout
|
||||
? this.formDialog.data.payment_method
|
||||
: 'lightning'
|
||||
}
|
||||
)
|
||||
const isFiat = Boolean(data.is_fiat)
|
||||
|
|
@ -178,7 +221,7 @@ window.PageEventsDisplay = {
|
|||
|
||||
const url = new URL(window.location)
|
||||
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:'
|
||||
url.pathname = `/api/v1/ws/${paymentHash}`
|
||||
url.pathname = `/events/api/v1/tickets/ws/${paymentHash}`
|
||||
url.search = ''
|
||||
url.hash = ''
|
||||
|
||||
|
|
@ -187,7 +230,7 @@ window.PageEventsDisplay = {
|
|||
|
||||
ws.onmessage = event => {
|
||||
const data = JSON.parse(event.data)
|
||||
if (data.pending === false) {
|
||||
if (data.paid === true) {
|
||||
this.paymentSuccess(paymentHash)
|
||||
ws.close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue