implement first part of occupied seat counter

This commit is contained in:
2023-08-18 18:13:53 +02:00
parent 4208ad44a2
commit 6051b18796
8 changed files with 44 additions and 23 deletions

View File

@@ -16,10 +16,30 @@ class POSTHandler {
constructor () {
db.getJSONData( 'booked' ).then( dat => {
this.allSelectedSeats = dat;
db.getJSONData( 'events' ).then( dat => {
db.getJSONData( 'seatplan' ).then( locations => {
this.events = dat;
// TODO: Load from event db subtract all occupied seats from the ordered db from it.
this.ticketTotals = {};
for ( let event in this.events ) {
if ( locations[ this.events[ event ][ 'location' ] ] ) {
this.ticketTotals[ event ] = locations[ this.events[ event ][ 'location' ] ][ 'save' ][ 'seatInfo' ][ 'count' ];
} else {
this.ticketTotals[ event ] = this.events[ event ][ 'maxTickets' ];
}
}
console.log( this.ticketTotals );
// for ( let order in this.allSelectedSeats ) {
// }
console.log( this.allSelectedSeats );
} );
} );
} );
// TODO: Load from event db subtract all occupied seats from the ordered db from it.
// TODO: When loading event data, also add currency to it from settings
this.ticketTotals = { 'test2': { 'ticket1': 5, 'ticket2': 5 } };
this.settings = JSON.parse( fs.readFileSync( path.join( __dirname + '/../../config/settings.config.json' ) ) );
}

View File

@@ -0,0 +1 @@
{"test4":{"secAr4s7":{"id":"secAr4s7","component":1,"ticketOption":"1","eventID":"test4","category":"1","name":"Row 5, Seat 8"}}}

View File

@@ -1 +1 @@
{"test4":{"name":"Test4Event","description":"Let's see...","location":"test2","date":"2023-09-18T10:00:00.000Z","categories":{"1":{"price":{"1":20,"2":30},"bg":"#FFFFFF","fg":"#000000","name":"Category 1","id":"1","ticketCount":1}},"ageGroups":{"1":{"id":1,"name":"Child","age":"0 - 15.99"},"2":{"id":2,"name":"Adult"}},"maxTickets":0,"eventID":"test4","time":"10:00:00.000","startingPrice":20,"currency":"USD","isDraft":true,"locationName":"TestLocation2","hasSeatplan":true}}
{"test4":{"name":"Test4Event","description":"Let's see...","location":"test2","date":"2023-09-18T10:00:00.000Z","categories":{"1":{"price":{"1":20,"2":30},"bg":"#FFFFFF","fg":"#000000","name":"Category 1","id":"1","ticketCount":1}},"ageGroups":{"1":{"id":1,"name":"Child","age":"0 - 15.99"},"2":{"id":2,"name":"Adult"}},"maxTickets":0,"eventID":"test4","time":"10:00:00.000","startingPrice":20,"currency":"CHF","isDraft":true,"locationName":"TestLocation2","hasSeatplan":true}}