Files
eventmaster/software/src/stores/bandStore.ts
2024-10-21 14:02:51 +02:00

35 lines
911 B
TypeScript

import { defineStore } from "pinia";
import { ref } from "vue";
import { BandApiModel } from "../data/models/acts/bandApiModel";
import { fetchAllBands, getBand } from "../data/api/bandApi";
import { BandDetailsApiModel } from "../data/models/acts/bandDetailsApiModel";
export const useBandStore = defineStore("bandStore", {
state: () => ({
bands: ref<Array<BandApiModel>>([]),
band: ref<BandDetailsApiModel>(new BandDetailsApiModel()),
fetchInProgress: ref(false)
}),
actions: {
async getBands() {
this.fetchInProgress = true
fetchAllBands()
.then(result => {
this.bands = result.data
this.fetchInProgress = false
})
},
async getBand(name: string) {
this.fetchInProgress = true
getBand(name)
.then(result => {
this.band = result.data
this.fetchInProgress = false
})
}
}
})