Merge upstream v1.6.8 into the aio fork
Brings in ticket waves (per-wave price/currency/stock/fiat), the paginated ticket endpoint, the organiser ticket-image template, and the SatsPay on-chain surface. Refs #33. Resolutions that were not mechanical, and why: - set_ticket_paid debits the wave named on the ticket, keeping upstream's `> 0` guards; ours decremented unconditionally and could go negative. The purchase and free-ticket paths now stamp ticket_wave_id / ticket_wave_title, without which every sale would debit the primary wave. - Pricing moved onto the selected wave (basket_totals takes it as a required argument, the promo-validate endpoint resolves the same wave through the shared _resolve_ticket_wave). event.price_per_ticket is a roll-up of the PRIMARY wave since sync_event_ticket_waves, so pricing off the event quoted and charged the first wave's price to buyers who picked a later one. Regression test added. - Kept npub support in two places upstream removed it: the purchase endpoint's normalize_public_key path and the notification dispatcher. Upstream's replacement rejects with "Only NIP-05 Nostr identifiers are supported", which is false for this fork. The purchase-side rejection had merged in outside any conflict marker. - _ticket_image_url existed on both sides as two unrelated features. Ours (always-attached rendered QR card) is now _ticket_card_url; upstream's (organiser template, opt-in per wave) keeps the name. Both are wired into the mail, and the /qr/{ticket_id} endpoint — also duplicated on both sides, on the same route — is merged into one handler rather than registered twice, where the second copy would have been unreachable. - models._parse_date now accepts a full ISO datetime. Upstream's date-only strptime raised ValueError on any event whose closing_date carries a time, which create_event produces by defaulting it from event_end_date — it would have 500'd the purchase path, the public event gate and the promo preview. Reproduced before fixing. - Dropped upstream's inline make_qr_png (we import a superset from .qr) and its duplicate paymentMethodOptions in display.js, which re-derived payment options from per-method booleans and offered an on-chain option the backend rejects; the submit gate now matches the template's condition. - Restored imports the merge silently dropped with upstream's npub removal (normalize_public_key, normalize_private_key, DEFAULT_NOSTR_RELAYS). Event create/update stays ours: upstream's combined endpoint would have replaced the approval workflow and the explicit field allowlist that keeps `status` out of the request body. mypy error set is unchanged from HEAD; ruff, black and the 97 tests pass.
This commit is contained in:
commit
ae5affa44f
14 changed files with 2228 additions and 275 deletions
|
|
@ -4,7 +4,10 @@ window.PageEvents = {
|
|||
return {
|
||||
events: [],
|
||||
tickets: [],
|
||||
allPaidTickets: [],
|
||||
resendingTicketEmails: [],
|
||||
isUploadingTicketTemplate: false,
|
||||
ticketImageUploadTarget: null,
|
||||
currencies: [],
|
||||
pendingEvents: [],
|
||||
allUserEvents: [],
|
||||
|
|
@ -25,7 +28,12 @@ window.PageEvents = {
|
|||
label: 'Owner',
|
||||
field: 'wallet_user_id'
|
||||
},
|
||||
{name: 'id', align: 'left', label: 'ID', field: 'id'},
|
||||
{
|
||||
name: 'id',
|
||||
align: 'left',
|
||||
label: 'ID',
|
||||
field: row => this.shortenId(row.id)
|
||||
},
|
||||
{name: 'name', align: 'left', label: 'Name', field: 'name'},
|
||||
{
|
||||
name: 'event_start_date',
|
||||
|
|
@ -39,12 +47,6 @@ window.PageEvents = {
|
|||
label: 'End date',
|
||||
field: 'event_end_date'
|
||||
},
|
||||
{
|
||||
name: 'closing_date',
|
||||
align: 'left',
|
||||
label: 'Ticket close',
|
||||
field: 'closing_date'
|
||||
},
|
||||
{
|
||||
name: 'canceled',
|
||||
align: 'left',
|
||||
|
|
@ -129,8 +131,14 @@ window.PageEvents = {
|
|||
}
|
||||
},
|
||||
ticketsTable: {
|
||||
loading: false,
|
||||
columns: [
|
||||
{name: 'event', align: 'left', label: 'Event', field: 'event'},
|
||||
{
|
||||
name: 'event',
|
||||
align: 'left',
|
||||
label: 'Event',
|
||||
field: row => this.shortenId(row.event)
|
||||
},
|
||||
{name: 'name', align: 'left', label: 'Name', field: 'name'},
|
||||
{name: 'email', align: 'left', label: 'Email', field: 'email'},
|
||||
{
|
||||
|
|
@ -152,6 +160,12 @@ window.PageEvents = {
|
|||
label: 'Registered',
|
||||
field: 'registered'
|
||||
},
|
||||
{
|
||||
name: 'nostr',
|
||||
align: 'left',
|
||||
label: 'Nostr',
|
||||
field: row => row.extra?.nostr_identifier || ''
|
||||
},
|
||||
{
|
||||
name: 'promo_code',
|
||||
align: 'left',
|
||||
|
|
@ -161,7 +175,11 @@ window.PageEvents = {
|
|||
{name: 'id', align: 'left', label: 'ID', field: 'id'}
|
||||
],
|
||||
pagination: {
|
||||
rowsPerPage: 10
|
||||
sortBy: 'time',
|
||||
descending: true,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
rowsNumber: 10
|
||||
}
|
||||
},
|
||||
// Rails an organizer can enable per event. Mirrors the webapp's
|
||||
|
|
@ -218,12 +236,44 @@ window.PageEvents = {
|
|||
categories: [],
|
||||
extra: {
|
||||
payment_methods: ['lightning'],
|
||||
ticket_waves: [],
|
||||
promo_codes: [],
|
||||
notification_subject: '',
|
||||
notification_body: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
ticketWaveDialog: {
|
||||
show: false,
|
||||
eventId: null,
|
||||
wallet: null,
|
||||
editingWaveId: null,
|
||||
data: {
|
||||
id: null,
|
||||
title: '',
|
||||
opening_date: '',
|
||||
closing_date: '',
|
||||
currency: 'sats',
|
||||
use_ticket_image: false,
|
||||
ticket_image_id: null,
|
||||
allow_fiat: false,
|
||||
fiat_currency: 'GBP',
|
||||
amount_tickets: 0,
|
||||
price_per_ticket: 0
|
||||
}
|
||||
},
|
||||
promoCodesDialog: {
|
||||
show: false,
|
||||
data: {
|
||||
id: null,
|
||||
wallet: null,
|
||||
name: '',
|
||||
extra: {
|
||||
promo_codes: []
|
||||
}
|
||||
}
|
||||
},
|
||||
onchainWallets: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -248,19 +298,196 @@ window.PageEvents = {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
shortenId(value) {
|
||||
if (!value) return ''
|
||||
return value.length > 4 ? `${value.slice(0, 4)}...` : value
|
||||
},
|
||||
async loadOnchainWallets() {
|
||||
const wallet = _.findWhere(this.g.user.wallets, {
|
||||
id: this.formDialog.data.wallet
|
||||
})
|
||||
if (!wallet) return
|
||||
try {
|
||||
const {data} = await LNbits.api.request(
|
||||
'GET',
|
||||
'/events/api/v1/events/onchain/status',
|
||||
wallet.adminkey
|
||||
)
|
||||
this.onchainWallets = data.available ? data.wallets || [] : []
|
||||
} catch {
|
||||
this.onchainWallets = []
|
||||
}
|
||||
},
|
||||
async confirmOnchainTicket(ticket) {
|
||||
const wallet = _.findWhere(this.g.user.wallets, {id: ticket.wallet})
|
||||
if (!wallet) return
|
||||
try {
|
||||
await LNbits.api.request(
|
||||
'PUT',
|
||||
`/events/api/v1/tickets/${ticket.id}/onchain-confirm`,
|
||||
wallet.adminkey
|
||||
)
|
||||
Quasar.Notify.create({
|
||||
type: 'positive',
|
||||
message: 'Onchain payment confirmed.',
|
||||
icon: null
|
||||
})
|
||||
await this.getTickets()
|
||||
await this.getAllTickets()
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
},
|
||||
primaryTicketWave(data = this.formDialog.data) {
|
||||
if (!data.extra) data.extra = {}
|
||||
if (!data.extra.ticket_waves || data.extra.ticket_waves.length === 0) {
|
||||
data.extra.ticket_waves = [
|
||||
{
|
||||
id: 'primary',
|
||||
title: 'Primary wave',
|
||||
opening_date: data.closing_date || '',
|
||||
closing_date: data.closing_date || '',
|
||||
currency: data.currency || 'sats',
|
||||
use_ticket_image: false,
|
||||
ticket_image_id: null,
|
||||
allow_fiat: Boolean(data.allow_fiat),
|
||||
fiat_currency: data.fiat_currency || 'GBP',
|
||||
amount_tickets: data.amount_tickets || 0,
|
||||
price_per_ticket: data.price_per_ticket || 0
|
||||
}
|
||||
]
|
||||
}
|
||||
return data.extra.ticket_waves[0]
|
||||
},
|
||||
syncPrimaryWaveFromForm(data = this.formDialog.data) {
|
||||
const primaryWave = this.primaryTicketWave(data)
|
||||
primaryWave.title = primaryWave.title || 'Primary wave'
|
||||
primaryWave.opening_date = primaryWave.opening_date || ''
|
||||
primaryWave.closing_date = data.closing_date || ''
|
||||
primaryWave.currency = data.currency || 'sats'
|
||||
primaryWave.use_ticket_image = Boolean(primaryWave.use_ticket_image)
|
||||
primaryWave.ticket_image_id = primaryWave.ticket_image_id || null
|
||||
primaryWave.allow_fiat = Boolean(data.allow_fiat)
|
||||
primaryWave.fiat_currency = data.fiat_currency || 'GBP'
|
||||
primaryWave.amount_tickets = Number(data.amount_tickets || 0)
|
||||
primaryWave.price_per_ticket = Number(data.price_per_ticket || 0)
|
||||
return primaryWave
|
||||
},
|
||||
hydrateEventForm(data) {
|
||||
const formData = {
|
||||
...data,
|
||||
extra: {
|
||||
...(data.extra || {}),
|
||||
ticket_waves: [...((data.extra && data.extra.ticket_waves) || [])]
|
||||
}
|
||||
}
|
||||
const primaryWave = this.primaryTicketWave(formData)
|
||||
formData.currency = primaryWave.currency || formData.currency || 'sats'
|
||||
formData.allow_fiat = Boolean(primaryWave.allow_fiat)
|
||||
formData.fiat_currency = primaryWave.fiat_currency || 'GBP'
|
||||
formData.amount_tickets = primaryWave.amount_tickets
|
||||
formData.price_per_ticket = primaryWave.price_per_ticket
|
||||
formData.closing_date =
|
||||
primaryWave.closing_date || formData.closing_date || ''
|
||||
return formData
|
||||
},
|
||||
isFiatCurrency(currency) {
|
||||
return !['sat', 'sats'].includes((currency || '').toLowerCase())
|
||||
},
|
||||
getTickets() {
|
||||
LNbits.api
|
||||
.request(
|
||||
normalizePromoCodes(promoCodes = []) {
|
||||
return promoCodes
|
||||
.filter(code => code.code?.trim() !== '')
|
||||
.map(code => ({
|
||||
...code,
|
||||
code: code.code.trim().toUpperCase(),
|
||||
// fork-only: blank / 0 = unlimited; used_count is derived server-side
|
||||
max_uses: code.max_uses ? Number(code.max_uses) : null
|
||||
}))
|
||||
},
|
||||
templateDownloadUrl() {
|
||||
return '/events/static/image/ticket.jpg'
|
||||
},
|
||||
async uploadAssetFile(file) {
|
||||
const form = new FormData()
|
||||
form.append('file', file)
|
||||
form.append('public_asset', 'true')
|
||||
const {data} = await LNbits.api.request(
|
||||
'POST',
|
||||
'/api/v1/assets?public_asset=true',
|
||||
null,
|
||||
form
|
||||
)
|
||||
return data.id
|
||||
},
|
||||
triggerTicketImageUpload(target) {
|
||||
this.ticketImageUploadTarget = target
|
||||
this.$refs.ticketImageUpload.value = null
|
||||
this.$refs.ticketImageUpload.click()
|
||||
},
|
||||
async handleTicketImageSelected(event) {
|
||||
const file = event.target.files?.[0]
|
||||
if (!file || !this.ticketImageUploadTarget) return
|
||||
|
||||
this.isUploadingTicketTemplate = true
|
||||
try {
|
||||
const assetId = await this.uploadAssetFile(file)
|
||||
if (this.ticketImageUploadTarget === 'primary') {
|
||||
const wave = this.primaryTicketWave()
|
||||
wave.use_ticket_image = true
|
||||
wave.ticket_image_id = assetId
|
||||
} else if (this.ticketImageUploadTarget === 'dialog') {
|
||||
this.ticketWaveDialog.data.use_ticket_image = true
|
||||
this.ticketWaveDialog.data.ticket_image_id = assetId
|
||||
}
|
||||
Quasar.Notify.create({
|
||||
type: 'positive',
|
||||
message: 'Ticket template uploaded.',
|
||||
icon: null
|
||||
})
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
} finally {
|
||||
this.isUploadingTicketTemplate = false
|
||||
this.ticketImageUploadTarget = null
|
||||
}
|
||||
},
|
||||
soldTicketsForWave(eventId, waveId) {
|
||||
return this.allPaidTickets.filter(
|
||||
ticket =>
|
||||
ticket.event === eventId &&
|
||||
ticket.paid &&
|
||||
(ticket.extra?.ticket_wave_id === waveId ||
|
||||
(!ticket.extra?.ticket_wave_id && waveId === 'primary'))
|
||||
).length
|
||||
},
|
||||
async getAllTickets() {
|
||||
try {
|
||||
const {data} = await LNbits.api.request(
|
||||
'GET',
|
||||
'/events/api/v1/tickets?all_wallets=true',
|
||||
this.g.user.wallets[0].adminkey
|
||||
)
|
||||
.then(response => {
|
||||
this.tickets = response.data.filter(e => e.paid)
|
||||
})
|
||||
this.allPaidTickets = data.filter(ticket => ticket.paid)
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
},
|
||||
async getTickets(props) {
|
||||
try {
|
||||
this.ticketsTable.loading = true
|
||||
const params = LNbits.utils.prepareFilterQuery(this.ticketsTable, props)
|
||||
const {data} = await LNbits.api.request(
|
||||
'GET',
|
||||
`/events/api/v1/tickets/paginated?all_wallets=true&${params}`,
|
||||
this.g.user.wallets[0].adminkey
|
||||
)
|
||||
this.tickets = data.data
|
||||
this.ticketsTable.pagination.rowsNumber = data.total
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
} finally {
|
||||
this.ticketsTable.loading = false
|
||||
}
|
||||
},
|
||||
deleteTicket(ticketId) {
|
||||
const tickets = _.findWhere(this.tickets, {id: ticketId})
|
||||
|
|
@ -275,10 +502,9 @@ window.PageEvents = {
|
|||
'/events/api/v1/tickets/' + ticketId,
|
||||
wallet.adminkey
|
||||
)
|
||||
.then(response => {
|
||||
this.tickets = _.reject(this.tickets, function (obj) {
|
||||
return obj.id == ticketId
|
||||
})
|
||||
.then(async () => {
|
||||
await this.getTickets()
|
||||
await this.getAllTickets()
|
||||
})
|
||||
.catch(LNbits.utils.notifyApiError)
|
||||
})
|
||||
|
|
@ -296,14 +522,30 @@ window.PageEvents = {
|
|||
wallet.adminkey
|
||||
)
|
||||
.then(response => {
|
||||
const result = response.data
|
||||
this.tickets = this.tickets.map(obj =>
|
||||
obj.id === ticket.id ? response.data : obj
|
||||
obj.id === ticket.id ? result.ticket : obj
|
||||
)
|
||||
Quasar.Notify.create({
|
||||
type: 'positive',
|
||||
message: 'Ticket email resent.',
|
||||
icon: null
|
||||
})
|
||||
|
||||
if (result.email?.attempted) {
|
||||
Quasar.Notify.create({
|
||||
type: result.email.sent ? 'positive' : 'negative',
|
||||
message: result.email.sent
|
||||
? 'Ticket email resent.'
|
||||
: `Ticket email failed: ${result.email.error || 'Unknown error.'}`,
|
||||
icon: null
|
||||
})
|
||||
}
|
||||
|
||||
if (result.nostr?.attempted) {
|
||||
Quasar.Notify.create({
|
||||
type: result.nostr.sent ? 'positive' : 'negative',
|
||||
message: result.nostr.sent
|
||||
? 'Ticket Nostr DM resent.'
|
||||
: `Ticket Nostr DM failed: ${result.nostr.error || 'Unknown error.'}`,
|
||||
icon: null
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(LNbits.utils.notifyApiError)
|
||||
.finally(() => {
|
||||
|
|
@ -313,7 +555,7 @@ window.PageEvents = {
|
|||
})
|
||||
},
|
||||
exportticketsCSV() {
|
||||
LNbits.utils.exportCSV(this.ticketsTable.columns, this.tickets)
|
||||
LNbits.utils.exportCSV(this.ticketsTable.columns, this.allPaidTickets)
|
||||
},
|
||||
getEvents() {
|
||||
LNbits.api
|
||||
|
|
@ -520,16 +762,14 @@ window.PageEvents = {
|
|||
data.location = (data.location || '').trim() || null
|
||||
data.categories = data.categories || []
|
||||
data.closing_date = data.closing_date || null
|
||||
|
||||
// Fold the form's day+time pairs first, then let upstream's helper
|
||||
// mirror the form fields onto the primary wave — order matters, the
|
||||
// sync reads closing_date/currency/amount_tickets off `data`.
|
||||
this.syncPrimaryWaveFromForm(data)
|
||||
if (data.extra?.promo_codes) {
|
||||
data.extra.promo_codes = data.extra.promo_codes
|
||||
.filter(code => code.code?.trim() !== '')
|
||||
.map(code => ({
|
||||
...code,
|
||||
code: code.code.trim().toUpperCase(),
|
||||
// blank / 0 = unlimited; used_count is derived server-side
|
||||
max_uses: code.max_uses ? Number(code.max_uses) : null
|
||||
}))
|
||||
data.extra.promo_codes = this.normalizePromoCodes(
|
||||
data.extra.promo_codes
|
||||
)
|
||||
}
|
||||
const methods = data.extra?.payment_methods || []
|
||||
if (methods.length === 0) {
|
||||
|
|
@ -549,6 +789,7 @@ window.PageEvents = {
|
|||
} else if (!data.allow_fiat) {
|
||||
data.fiat_currency = 'GBP'
|
||||
}
|
||||
this.syncPrimaryWaveFromForm(data)
|
||||
|
||||
if (data.id) {
|
||||
this.updateEvent(wallet, data)
|
||||
|
|
@ -561,10 +802,14 @@ window.PageEvents = {
|
|||
if (data && data.id) {
|
||||
const start = this.splitDateTime(data.event_start_date)
|
||||
const end = this.splitDateTime(data.event_end_date)
|
||||
// Seed from upstream's hydrator (it materialises ticket_waves and
|
||||
// mirrors the primary wave onto the flat form fields), then layer
|
||||
// our fork-only fields on top.
|
||||
const hydrated = this.hydrateEventForm(data)
|
||||
this.formDialog.data = {
|
||||
...data,
|
||||
...hydrated,
|
||||
extra: {
|
||||
...(data.extra || {}),
|
||||
...(hydrated.extra || {}),
|
||||
// Events created before extra.payment_methods existed carry an
|
||||
// empty list; show the rails the backend actually accepts for
|
||||
// them (Lightning always, fiat when allow_fiat).
|
||||
|
|
@ -596,6 +841,25 @@ window.PageEvents = {
|
|||
min_tickets: 1,
|
||||
email_notifications: false,
|
||||
nostr_notifications: false,
|
||||
onchain_enabled: false,
|
||||
onchain_wallet_id: null,
|
||||
onchain_zeroconf: false,
|
||||
onchain_fasttrack: false,
|
||||
ticket_waves: [
|
||||
{
|
||||
id: 'primary',
|
||||
title: 'Primary wave',
|
||||
opening_date: '',
|
||||
closing_date: '',
|
||||
currency: 'sats',
|
||||
use_ticket_image: false,
|
||||
ticket_image_id: null,
|
||||
allow_fiat: false,
|
||||
fiat_currency: 'GBP',
|
||||
amount_tickets: 0,
|
||||
price_per_ticket: 0
|
||||
}
|
||||
],
|
||||
promo_codes: [],
|
||||
notification_subject: '',
|
||||
notification_body: ''
|
||||
|
|
@ -603,6 +867,12 @@ window.PageEvents = {
|
|||
}
|
||||
}
|
||||
this.formDialog.show = true
|
||||
if (
|
||||
this.formDialog.data.wallet &&
|
||||
this.formDialog.data.extra?.onchain_enabled
|
||||
) {
|
||||
this.loadOnchainWallets()
|
||||
}
|
||||
},
|
||||
resetEventDialog() {
|
||||
this.formDialog.show = false
|
||||
|
|
@ -614,8 +884,27 @@ window.PageEvents = {
|
|||
categories: [],
|
||||
extra: {
|
||||
payment_methods: ['lightning'],
|
||||
conditional: false,
|
||||
min_tickets: 1,
|
||||
email_notifications: false,
|
||||
nostr_notifications: false,
|
||||
onchain_enabled: false,
|
||||
onchain_wallet_id: null,
|
||||
ticket_waves: [
|
||||
{
|
||||
id: 'primary',
|
||||
title: 'Primary wave',
|
||||
opening_date: '',
|
||||
closing_date: '',
|
||||
currency: 'sats',
|
||||
use_ticket_image: false,
|
||||
ticket_image_id: null,
|
||||
allow_fiat: false,
|
||||
fiat_currency: 'GBP',
|
||||
amount_tickets: 0,
|
||||
price_per_ticket: 0
|
||||
}
|
||||
],
|
||||
promo_codes: [],
|
||||
notification_subject: '',
|
||||
notification_body: ''
|
||||
|
|
@ -636,6 +925,179 @@ window.PageEvents = {
|
|||
const link = _.findWhere(this.events, {id: formId})
|
||||
this.openEventDialog(link)
|
||||
},
|
||||
openTicketWaveDialog(event, wave = null) {
|
||||
const primaryWave = (event.extra?.ticket_waves || [])[0] || {}
|
||||
const isEditing = Boolean(wave)
|
||||
this.ticketWaveDialog = {
|
||||
show: true,
|
||||
eventId: event.id,
|
||||
wallet: event.wallet,
|
||||
editingWaveId: wave?.id || null,
|
||||
data: {
|
||||
id: wave?.id || null,
|
||||
title: wave?.title || '',
|
||||
opening_date: wave?.opening_date || '',
|
||||
closing_date: wave?.closing_date || '',
|
||||
currency:
|
||||
wave?.currency || primaryWave.currency || event.currency || 'sats',
|
||||
use_ticket_image: Boolean(wave?.use_ticket_image),
|
||||
ticket_image_id: wave?.ticket_image_id || null,
|
||||
allow_fiat: isEditing
|
||||
? Boolean(wave?.allow_fiat)
|
||||
: Boolean(primaryWave.allow_fiat ?? event.allow_fiat),
|
||||
fiat_currency:
|
||||
wave?.fiat_currency ||
|
||||
primaryWave.fiat_currency ||
|
||||
event.fiat_currency ||
|
||||
'GBP',
|
||||
amount_tickets: wave?.amount_tickets || 0,
|
||||
price_per_ticket:
|
||||
wave?.price_per_ticket ||
|
||||
primaryWave.price_per_ticket ||
|
||||
event.price_per_ticket ||
|
||||
0
|
||||
}
|
||||
}
|
||||
},
|
||||
resetTicketWaveDialog() {
|
||||
this.ticketWaveDialog = {
|
||||
show: false,
|
||||
eventId: null,
|
||||
wallet: null,
|
||||
editingWaveId: null,
|
||||
data: {
|
||||
id: null,
|
||||
title: '',
|
||||
opening_date: '',
|
||||
closing_date: '',
|
||||
currency: 'sats',
|
||||
use_ticket_image: false,
|
||||
ticket_image_id: null,
|
||||
allow_fiat: false,
|
||||
fiat_currency: 'GBP',
|
||||
amount_tickets: 0,
|
||||
price_per_ticket: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
saveTicketWave() {
|
||||
const event = _.findWhere(this.events, {
|
||||
id: this.ticketWaveDialog.eventId
|
||||
})
|
||||
const wallet = _.findWhere(this.g.user.wallets, {
|
||||
id: this.ticketWaveDialog.wallet
|
||||
})
|
||||
if (!event || !wallet) return
|
||||
|
||||
const payload = {
|
||||
...event,
|
||||
extra: {
|
||||
...event.extra,
|
||||
ticket_waves: (event.extra?.ticket_waves || []).map(existingWave =>
|
||||
existingWave.id === this.ticketWaveDialog.editingWaveId
|
||||
? {...this.ticketWaveDialog.data}
|
||||
: existingWave
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.ticketWaveDialog.editingWaveId) {
|
||||
payload.extra.ticket_waves.push({...this.ticketWaveDialog.data})
|
||||
}
|
||||
|
||||
if (payload.extra?.promo_codes) {
|
||||
payload.extra.promo_codes = this.normalizePromoCodes(
|
||||
payload.extra.promo_codes
|
||||
)
|
||||
}
|
||||
|
||||
LNbits.api
|
||||
.request(
|
||||
'PUT',
|
||||
'/events/api/v1/events/' + payload.id,
|
||||
wallet.adminkey,
|
||||
payload
|
||||
)
|
||||
.then(response => {
|
||||
this.events = this.events.map(item =>
|
||||
item.id === payload.id ? response.data : item
|
||||
)
|
||||
Quasar.Notify.create({
|
||||
type: 'positive',
|
||||
message: this.ticketWaveDialog.editingWaveId
|
||||
? 'Ticket wave updated.'
|
||||
: 'Ticket wave added.',
|
||||
icon: null
|
||||
})
|
||||
this.resetTicketWaveDialog()
|
||||
})
|
||||
.catch(LNbits.utils.notifyApiError)
|
||||
},
|
||||
openPromoCodesDialog(event) {
|
||||
this.promoCodesDialog.data = {
|
||||
...event,
|
||||
extra: {
|
||||
...event.extra,
|
||||
promo_codes: [...(event.extra?.promo_codes || [])]
|
||||
}
|
||||
}
|
||||
this.promoCodesDialog.show = true
|
||||
},
|
||||
resetPromoCodesDialog() {
|
||||
this.promoCodesDialog.show = false
|
||||
this.promoCodesDialog.data = {
|
||||
id: null,
|
||||
wallet: null,
|
||||
name: '',
|
||||
extra: {
|
||||
promo_codes: []
|
||||
}
|
||||
}
|
||||
},
|
||||
addPromoCodeToDialog() {
|
||||
this.promoCodesDialog.data.extra.promo_codes.push({
|
||||
code: '',
|
||||
discount_percent: 0,
|
||||
active: true,
|
||||
// fork-only: null = unlimited uses
|
||||
max_uses: null
|
||||
})
|
||||
},
|
||||
savePromoCodes() {
|
||||
const data = this.promoCodesDialog.data
|
||||
const wallet = _.findWhere(this.g.user.wallets, {
|
||||
id: data.wallet
|
||||
})
|
||||
if (!wallet) return
|
||||
|
||||
const payload = {
|
||||
...data,
|
||||
extra: {
|
||||
...data.extra,
|
||||
promo_codes: this.normalizePromoCodes(data.extra?.promo_codes || [])
|
||||
}
|
||||
}
|
||||
|
||||
LNbits.api
|
||||
.request(
|
||||
'PUT',
|
||||
'/events/api/v1/events/' + data.id,
|
||||
wallet.adminkey,
|
||||
payload
|
||||
)
|
||||
.then(response => {
|
||||
this.events = this.events.map(event =>
|
||||
event.id === data.id ? response.data : event
|
||||
)
|
||||
Quasar.Notify.create({
|
||||
type: 'positive',
|
||||
message: 'Promo codes updated.',
|
||||
icon: null
|
||||
})
|
||||
this.resetPromoCodesDialog()
|
||||
})
|
||||
.catch(LNbits.utils.notifyApiError)
|
||||
},
|
||||
updateEvent(wallet, data) {
|
||||
LNbits.api
|
||||
.request(
|
||||
|
|
@ -702,6 +1164,7 @@ window.PageEvents = {
|
|||
async created() {
|
||||
if (this.g.user.wallets.length) {
|
||||
this.getTickets()
|
||||
this.getAllTickets()
|
||||
this.getEvents()
|
||||
this.getSettings()
|
||||
this.getPendingEvents()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue