Working on exercise 1.2

This commit is contained in:
2024-11-16 16:56:20 +01:00
parent 70e508ce7a
commit 7912e38932
16 changed files with 85 additions and 59 deletions

View File

@@ -251,7 +251,8 @@
"date": "2024-10-30",
"price": 79.90,
"inStock": 1073,
"location": "LANXESS arena"
"location": "LANXESS arena",
"offered": false
},
{
"date": "2024-10-23",

View File

@@ -34,8 +34,8 @@
"descriptionEn": "Manipulate the URL and access the help page"
},
{
"nameDe": "Das ausgebuchte Konzert buchen",
"nameEn": "Book the unavailable concert",
"nameDe": "Das versteckte Konzert buchen",
"nameEn": "Book the hidden concert",
"exerciseNr": 2,
"descriptionDe": "Manipuliere die URL so, dass du das ausgebuchte Konzert aufrufen kannst und buche ein Ticket dafür",
"descriptionEn": "Manipulate the URL and access the sold out concert and buy a ticket"

View File

@@ -11,6 +11,7 @@ import { Seat } from "../models/locations/seat.model";
import { SeatRow } from "../models/locations/seatRow.model";
import { SeatGroup } from "../models/locations/seatGroup.model";
import { Account } from "../models/user/account.model";
import { Exercise } from "backend/models/exercises/exercise.model";
export const order = Router()

View File

@@ -296,13 +296,14 @@ export async function prepopulateDatabase() {
}
})
.then(async location => {
console.log(concert.offered)
concerts.push({
date: concert.date,
name: concertGroup.name,
price: concert.price,
image: "http://localhost:3000/static/" + concertGroup.image,
inStock: concert.inStock,
offered: true,
offered: concert.offered != undefined ? concert.offered : true,
bandId: dataset.dataValues.id,
locationId: location.dataValues.id
})

View File

@@ -40,7 +40,7 @@ defineProps({
:title="concert.name"
v-if="!loading"
:link="showButton && concert.inStock > 0"
@click="showButton && concert.inStock > 0 ? router.push('/concerts/booking/' + concert.id) : () => {}"
@click="showButton && concert.inStock > 0 ? router.push('/concerts/booking/' + location.urlName + '/' + concert.date) : () => {}"
>
<template #prepend>
<div>

View File

@@ -5,5 +5,4 @@ import { ConcertModel } from "./concertModel";
export class ConcertDetailsApiModel extends ConcertModel {
location: LocationDetailsApiModel = new LocationDetailsApiModel()
band: BandModel = new BandModel()
}

View File

@@ -6,4 +6,5 @@ export class LocationModel {
imageOutdoor: string = ""
capacity: number = 0
layout: number = 1
urlName: string = ""
}

View File

@@ -32,6 +32,7 @@ async function startLogin() {
v-model="accountStore.loginData.username"
variant="outlined"
clearable
@keyup.enter="startLogin"
/>
</v-col>
</v-row>
@@ -45,6 +46,7 @@ async function startLogin() {
variant="outlined"
v-model="accountStore.loginData.password"
clearable
@keyup.enter="startLogin"
/>
</v-col>
</v-row>

View File

@@ -3,7 +3,6 @@ import { useConcertStore } from '@/stores/concert.store';
import { useBandStore } from '@/stores/band.store';
import { useAccountStore } from '@/stores/account.store';
import { useLocationStore } from '@/stores/location.store';
import { useExerciseStore } from '@/stores/exercise.store';
import { useGenreStore } from '@/stores/genre.store';
import { usePreferencesStore } from '@/stores/preferences.store';
import dashboardCard from './dashboardCard.vue';
@@ -15,13 +14,10 @@ const bandStore = useBandStore()
const accountStore = useAccountStore()
const genreStore = useGenreStore()
const locationStore = useLocationStore()
const exerciseStore = useExerciseStore()
const preferencesStore = usePreferencesStore()
const orderStore = useOrderStore()
const filesStore = useFilesStore()
exerciseStore.solveExercise(2, 1)
filesStore.getStaticFolders()
bandStore.getBands()
locationStore.getLocations()

View File

@@ -20,7 +20,8 @@ const bandStore = useBandStore()
</v-col>
</v-row>
<v-row v-for="concert of bandStore.band.concerts">
<div v-for="concert of bandStore.band.concerts">
<v-row v-if="concert.offered">
<v-col>
<concert-list-item
:concert="concert"
@@ -31,4 +32,5 @@ const bandStore = useBandStore()
/>
</v-col>
</v-row>
</div>
</template>

View File

@@ -15,11 +15,17 @@ const basketStore = useBasketStore()
const concertStore = useConcertStore()
onMounted(async () => {
concertStore.getConcert(Number(router.currentRoute.value.params.id))
concertStore.getConcert(
String(router.currentRoute.value.params.locationUrl),
String(router.currentRoute.value.params.date)
)
})
watch(() => router.currentRoute.value.params.id, () => {
concertStore.getConcert(Number(router.currentRoute.value.params.id))
concertStore.getConcert(
String(router.currentRoute.value.params.locationUrl),
String(router.currentRoute.value.params.date)
)
})
</script>

View File

@@ -24,6 +24,7 @@ const concertStore = useConcertStore()
v-else-if="concertStore.concerts.length > 0"
v-for="(concert, index) of concertStore.concerts"
>
<div v-if="concert.offered">
<v-row
v-if="index == 0 ||
new Date(concertStore.concerts[index - 1].date).getMonth() !=
@@ -46,4 +47,5 @@ const concertStore = useConcertStore()
</v-col>
</v-row>
</div>
</div>
</template>

View File

@@ -23,9 +23,12 @@ const locationStore = useLocationStore()
</v-row>
<!-- Show concerts after fetching -->
<v-row
<div
v-else-if="locationStore.location.concerts.length > 0"
v-for="concert of locationStore.location.concerts"
>
<v-row
v-if="concert.offered"
>
<v-col>
<concert-list-item
@@ -40,6 +43,7 @@ const locationStore = useLocationStore()
</concert-list-item>
</v-col>
</v-row>
</div>
<!-- Show empty state if no items there -->
<v-row v-else>

View File

@@ -41,7 +41,7 @@ const routes = [
// Concerts
{ path: '/concerts', component: ConcertsPage },
{ path: '/concerts/booking/:id', component: ConcertBookingPage },
{ path: '/concerts/booking/:locationUrl/:date', component: ConcertBookingPage },
// Locations
{ path: '/locations', component: LocationsPage },

View File

@@ -114,6 +114,13 @@ export const useBasketStore = defineStore('basketStore', {
// Exercise 0.2 is solved
exerciseStore.solveExercise(0, 2)
for (let ticket of this.itemsInBasket) {
if (!ticket.concert.offered) {
exerciseStore.solveExercise(1, 2)
feedbackStore.addSnackbar(BannerStateEnum.EXERCISESOLVED12)
}
}
} else {
feedbackStore.addSnackbar(BannerStateEnum.ERROR)
}

View File

@@ -60,10 +60,14 @@ export const useConcertStore = defineStore("concertStore", {
*
* @param id ID of the concert in the database
*/
async getConcert(id: number) {
async getConcert(location: string, date: string) {
const feedbackStore = useFeedbackStore()
this.fetchInProgress = true
let id = this.concerts.find((concert: ConcertApiModel) => {
return (concert.location.urlName == location && concert.date == date)
}).id
fetchConcertById(id)
.then(result => {
this.concert = result.data