✨ Proper user login
This commit is contained in:
@@ -1,16 +1,26 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { useSolarNetwork } from '~/composables/useSolarNetwork'
|
||||
import type { SnPublisher } from '~/types/api'
|
||||
import { defineStore } from "pinia"
|
||||
import { ref } from "vue"
|
||||
import { useSolarNetwork } from "~/composables/useSolarNetwork"
|
||||
import type { SnPublisher } from "~/types/api"
|
||||
|
||||
export const usePubStore = defineStore('pub', () => {
|
||||
export const usePubStore = defineStore("pub", () => {
|
||||
const publishers = ref<SnPublisher[]>([])
|
||||
|
||||
async function fetchPublishers() {
|
||||
const api = useSolarNetwork()
|
||||
const resp = await api('/publishers')
|
||||
const resp = await api("/sphere/publishers")
|
||||
publishers.value = resp as SnPublisher[]
|
||||
}
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
watch(
|
||||
userStore,
|
||||
(value) => {
|
||||
if (value.isAuthenticated) fetchPublishers()
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
)
|
||||
|
||||
return { publishers, fetchPublishers }
|
||||
})
|
||||
|
Reference in New Issue
Block a user