Skip to content
Snippets Groups Projects
Commit 57d928fd authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

feat: add read-only hosts store

refs #127
parent 505b5a8e
No related branches found
No related tags found
No related merge requests found
import BootstrapVue from 'bootstrap-vue'
import { createPinia } from 'pinia'
import { createApp } from 'vue'
import { createApp, reactive, watchEffect } from 'vue'
import VueToast from 'vue-toast-notification'
import VueLogger from 'vuejs-logger'
......@@ -15,6 +15,8 @@ import '../node_modules/bootstrap/scss/bootstrap.scss'
import './assets/custom.scss'
import './assets/styles/tailwind.css'
import { shouldLog } from '@/utilities'
import { useAuthStore } from '@/stores/auth'
import { useHostStore } from '@/stores/hosts'
const pinia = createPinia()
const app = createApp(App)
......@@ -44,3 +46,16 @@ app.use(TranslationPlugin)
app.use(VueToast, { position: 'bottom-left' })
store.$log = app.$log
app.mount('#app')
const authStore = reactive(useAuthStore())
const hostStore = useHostStore()
watchEffect(async () => {
if (authStore.currentUser) {
try {
await Promise.allSettled([hostStore.list()])
} catch (e) {
console.error('unable to load base state from stores', e)
}
}
})
import { defineStore } from 'pinia'
import { steeringAuthInit } from '@/stores/auth'
import { APIListUnpaginated, APIRetrieve, createExtendableAPI, createSteeringURL } from '@/api'
import { Host } from '@/types'
export const useHostStore = defineStore('hosts', () => {
const endpoint = createSteeringURL.prefix('hosts')
const { base, ...api } = createExtendableAPI<Host>(endpoint, steeringAuthInit)
return {
...base,
...APIListUnpaginated(api),
...APIRetrieve(api),
}
})
......@@ -20,3 +20,4 @@ export type TimeSlot = Required<steeringComponents['schemas']['TimeSlot']>
export type Show = Required<steeringComponents['schemas']['Show']>
export type Playlist = Required<tankComponents['schemas']['store.Playlist']>
export type Schedule = Required<steeringComponents['schemas']['Schedule']>
export type Host = Required<steeringComponents['schemas']['Host']>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment