Implement global search
This commit is contained in:
43
software/src/data/stores/searchStore.ts
Normal file
43
software/src/data/stores/searchStore.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { searchBand } from "../api/bandApi";
|
||||
import { searchLocation } from "../api/locationApi";
|
||||
import { searchEvent } from "../api/eventApi";
|
||||
|
||||
export const useSearchStore = defineStore("searchStore", {
|
||||
state: () => ({
|
||||
searchTerm: ref(""),
|
||||
bands: ref(),
|
||||
locations: ref(),
|
||||
events: ref(),
|
||||
alreadySearched: ref(false),
|
||||
searchInProgress: ref(false)
|
||||
}),
|
||||
|
||||
actions: {
|
||||
/**
|
||||
* Search for the termin in all bands, locations, events
|
||||
*/
|
||||
async startSearch() {
|
||||
this.alreadySearched = true
|
||||
this.searchInProgress = true
|
||||
|
||||
await searchBand(this.searchTerm)
|
||||
.then(result => {
|
||||
this.bands = result.data
|
||||
})
|
||||
|
||||
await searchLocation(this.searchTerm)
|
||||
.then(result => {
|
||||
this.locations = result.data
|
||||
})
|
||||
|
||||
await searchEvent(this.searchTerm)
|
||||
.then(result => {
|
||||
this.events = result.data
|
||||
})
|
||||
|
||||
this.searchInProgress = false
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user