Working on exercise 1.2

This commit is contained in:
2024-11-16 16:56:20 +01:00
parent d92533ab6a
commit 9fbd9a1375
16 changed files with 85 additions and 59 deletions

View File

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

View File

@@ -34,8 +34,8 @@
"descriptionEn": "Manipulate the URL and access the help page" "descriptionEn": "Manipulate the URL and access the help page"
}, },
{ {
"nameDe": "Das ausgebuchte Konzert buchen", "nameDe": "Das versteckte Konzert buchen",
"nameEn": "Book the unavailable concert", "nameEn": "Book the hidden concert",
"exerciseNr": 2, "exerciseNr": 2,
"descriptionDe": "Manipuliere die URL so, dass du das ausgebuchte Konzert aufrufen kannst und buche ein Ticket dafür", "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" "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 { SeatRow } from "../models/locations/seatRow.model";
import { SeatGroup } from "../models/locations/seatGroup.model"; import { SeatGroup } from "../models/locations/seatGroup.model";
import { Account } from "../models/user/account.model"; import { Account } from "../models/user/account.model";
import { Exercise } from "backend/models/exercises/exercise.model";
export const order = Router() export const order = Router()

View File

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

View File

@@ -40,7 +40,7 @@ defineProps({
:title="concert.name" :title="concert.name"
v-if="!loading" v-if="!loading"
:link="showButton && concert.inStock > 0" :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> <template #prepend>
<div> <div>

View File

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

View File

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

View File

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

View File

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

View File

@@ -20,15 +20,17 @@ const bandStore = useBandStore()
</v-col> </v-col>
</v-row> </v-row>
<v-row v-for="concert of bandStore.band.concerts"> <div v-for="concert of bandStore.band.concerts">
<v-col> <v-row v-if="concert.offered">
<concert-list-item <v-col>
:concert="concert" <concert-list-item
:band="bandStore.band" :concert="concert"
:location="concert.location" :band="bandStore.band"
:title="concert.location.city.name" :location="concert.location"
:link="concert.inStock > 0" :title="concert.location.city.name"
/> :link="concert.inStock > 0"
</v-col> />
</v-row> </v-col>
</v-row>
</div>
</template> </template>

View File

@@ -15,11 +15,17 @@ const basketStore = useBasketStore()
const concertStore = useConcertStore() const concertStore = useConcertStore()
onMounted(async () => { 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, () => { 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> </script>

View File

@@ -24,26 +24,28 @@ const concertStore = useConcertStore()
v-else-if="concertStore.concerts.length > 0" v-else-if="concertStore.concerts.length > 0"
v-for="(concert, index) of concertStore.concerts" v-for="(concert, index) of concertStore.concerts"
> >
<v-row <div v-if="concert.offered">
v-if="index == 0 || <v-row
new Date(concertStore.concerts[index - 1].date).getMonth() != v-if="index == 0 ||
new Date(concertStore.concerts[index].date).getMonth()" new Date(concertStore.concerts[index - 1].date).getMonth() !=
> new Date(concertStore.concerts[index].date).getMonth()"
<v-col> >
<section-divider <v-col>
:title="new Date(concert.date).toLocaleString('default', { month: 'long' }) + ' ' + new Date(concert.date).getFullYear()" <section-divider
/> :title="new Date(concert.date).toLocaleString('default', { month: 'long' }) + ' ' + new Date(concert.date).getFullYear()"
</v-col> />
</v-row> </v-col>
</v-row>
<v-row> <v-row>
<v-col> <v-col>
<concert-list-item <concert-list-item
:concert="concert" :concert="concert"
:band="concert.band" :band="concert.band"
:location="concert.location" :location="concert.location"
/> />
</v-col> </v-col>
</v-row> </v-row>
</div>
</div> </div>
</template> </template>

View File

@@ -23,23 +23,27 @@ const locationStore = useLocationStore()
</v-row> </v-row>
<!-- Show concerts after fetching --> <!-- Show concerts after fetching -->
<v-row <div
v-else-if="locationStore.location.concerts.length > 0" v-else-if="locationStore.location.concerts.length > 0"
v-for="concert of locationStore.location.concerts" v-for="concert of locationStore.location.concerts"
> >
<v-col> <v-row
<concert-list-item v-if="concert.offered"
:concert="concert" >
:band="concert.band" <v-col>
:location="locationStore.location" <concert-list-item
:title="concert.name" :concert="concert"
> :band="concert.band"
<template #description> :location="locationStore.location"
{{ concert.band.name }} :title="concert.name"
</template> >
</concert-list-item> <template #description>
</v-col> {{ concert.band.name }}
</v-row> </template>
</concert-list-item>
</v-col>
</v-row>
</div>
<!-- Show empty state if no items there --> <!-- Show empty state if no items there -->
<v-row v-else> <v-row v-else>

View File

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

View File

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

View File

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