Improve filterBar on eventsPage, improve API access from frontend

This commit is contained in:
2024-10-03 19:56:44 +02:00
parent 2b7e87a68d
commit c611cc04fc
27 changed files with 170 additions and 164 deletions

View File

@@ -29,15 +29,15 @@ export const useConcertStore = defineStore("concertStore", {
async fetchAllTours() {
await getAllTours()
.then(result => {
this.tours = result.data
// this.tours = result.data
this.tours.sort((a, b) => {
return new Date(a.concerts[0].date) < new Date(b.concerts[0].date) ? -1 : 1
})
// this.tours.sort((a, b) => {
// return new Date(a.concerts[0].date) < new Date(b.concerts[0].date) ? -1 : 1
// })
this.filteredTours = this.tours
// this.filteredTours = this.tours
this.filterTours()
// this.filterTours()
})
await getAllBands()
@@ -47,7 +47,6 @@ export const useConcertStore = defineStore("concertStore", {
await getAllLocations()
.then(result => {
console.log(result.data)
this.locations = result.data
})

View File

@@ -2,18 +2,43 @@ import { defineStore } from "pinia";
import { ref } from "vue";
import { EventModel } from "../models/acts/eventModel";
import { fetchEvents } from "../api/eventApi";
import { fetchAllCities } from "../api/cityApi";
import { CityModel } from "../models/locations/cityModel";
import { GenreModel } from "../models/acts/genreModel";
import { fetchAllGenres } from "../api/genreApi";
export const useShoppingStore = defineStore("shoppingStore", {
state: () => ({
events: ref<Array<EventModel>>([])
events: ref<Array<EventModel>>([ new EventModel() ]),
cities: ref<Array<CityModel>>([ new CityModel() ]),
genres: ref<Array<GenreModel>>([ new GenreModel() ]),
cityFilterName: ref<String>(),
genreFilterName: ref<String>()
}),
actions: {
getEvents(city: string = "", genre: string = "") {
fetchEvents(city, genre)
async getEvents() {
await fetchEvents(
this.cityFilterName != null ? this.cityFilterName : "",
this.genreFilterName != null ? this.genreFilterName : ""
)
.then(result => {
this.events = result.data
})
},
async getCities() {
await fetchAllCities()
.then(result => {
this.cities = result.data
})
},
async getGenres() {
await fetchAllGenres()
.then(result => {
this.genres = result.data
})
}
}
})