Working on exercise 1.2
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -5,5 +5,4 @@ import { ConcertModel } from "./concertModel";
|
||||
export class ConcertDetailsApiModel extends ConcertModel {
|
||||
location: LocationDetailsApiModel = new LocationDetailsApiModel()
|
||||
band: BandModel = new BandModel()
|
||||
|
||||
}
|
||||
@@ -6,4 +6,5 @@ export class LocationModel {
|
||||
imageOutdoor: string = ""
|
||||
capacity: number = 0
|
||||
layout: number = 1
|
||||
urlName: string = ""
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -20,15 +20,17 @@ const bandStore = useBandStore()
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row v-for="concert of bandStore.band.concerts">
|
||||
<v-col>
|
||||
<concert-list-item
|
||||
:concert="concert"
|
||||
:band="bandStore.band"
|
||||
:location="concert.location"
|
||||
:title="concert.location.city.name"
|
||||
:link="concert.inStock > 0"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<div v-for="concert of bandStore.band.concerts">
|
||||
<v-row v-if="concert.offered">
|
||||
<v-col>
|
||||
<concert-list-item
|
||||
:concert="concert"
|
||||
:band="bandStore.band"
|
||||
:location="concert.location"
|
||||
:title="concert.location.city.name"
|
||||
:link="concert.inStock > 0"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
</template>
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -24,26 +24,28 @@ const concertStore = useConcertStore()
|
||||
v-else-if="concertStore.concerts.length > 0"
|
||||
v-for="(concert, index) of concertStore.concerts"
|
||||
>
|
||||
<v-row
|
||||
v-if="index == 0 ||
|
||||
new Date(concertStore.concerts[index - 1].date).getMonth() !=
|
||||
new Date(concertStore.concerts[index].date).getMonth()"
|
||||
>
|
||||
<v-col>
|
||||
<section-divider
|
||||
:title="new Date(concert.date).toLocaleString('default', { month: 'long' }) + ' ' + new Date(concert.date).getFullYear()"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<div v-if="concert.offered">
|
||||
<v-row
|
||||
v-if="index == 0 ||
|
||||
new Date(concertStore.concerts[index - 1].date).getMonth() !=
|
||||
new Date(concertStore.concerts[index].date).getMonth()"
|
||||
>
|
||||
<v-col>
|
||||
<section-divider
|
||||
:title="new Date(concert.date).toLocaleString('default', { month: 'long' }) + ' ' + new Date(concert.date).getFullYear()"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row>
|
||||
<v-col>
|
||||
<concert-list-item
|
||||
:concert="concert"
|
||||
:band="concert.band"
|
||||
:location="concert.location"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<concert-list-item
|
||||
:concert="concert"
|
||||
:band="concert.band"
|
||||
:location="concert.location"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -23,23 +23,27 @@ 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-col>
|
||||
<concert-list-item
|
||||
:concert="concert"
|
||||
:band="concert.band"
|
||||
:location="locationStore.location"
|
||||
:title="concert.name"
|
||||
>
|
||||
<template #description>
|
||||
{{ concert.band.name }}
|
||||
</template>
|
||||
</concert-list-item>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row
|
||||
v-if="concert.offered"
|
||||
>
|
||||
<v-col>
|
||||
<concert-list-item
|
||||
:concert="concert"
|
||||
:band="concert.band"
|
||||
:location="locationStore.location"
|
||||
:title="concert.name"
|
||||
>
|
||||
<template #description>
|
||||
{{ concert.band.name }}
|
||||
</template>
|
||||
</concert-list-item>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
|
||||
<!-- Show empty state if no items there -->
|
||||
<v-row v-else>
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user