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>([ new EventModel() ]), cities: ref>([ new CityModel() ]), genres: ref>([ new GenreModel() ]), cityFilterName: ref(), genreFilterName: ref() }), actions: { 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 }) } } })