Files
NSG_PORTAL_V2/stores/poll-option.ts
T

28 lines
936 B
TypeScript
Raw Normal View History

import type { PollOption } from "~/server/models/poll-option"
export const usePollOptionStore = defineStore('usePollOptionStore', () => {
const currentPollOption = shallowReactive<PollOption>({})
const currentPollOptions = shallowRef<PollOption[] | any[]>([])
2024-07-17 10:35:35 +07:00
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
2024-06-06 13:29:22 +07:00
async function fetchByPollId(id: string) {
try {
const { data } = await useFetch<any>(`/api/services/poll-option/pollId`, {
query: {
2024-07-17 10:35:35 +07:00
pollId: id,
site: host
}
})
data.value && (currentPollOptions.value = data.value)
return currentPollOptions.value
} catch(error) {}
2024-06-06 13:29:22 +07:00
}
return { currentPollOptions, fetchByPollId }
2024-06-06 13:29:22 +07:00
})
if(import.meta.hot) {
import.meta.hot.accept(acceptHMRUpdate(usePollOptionStore, import.meta.hot))
2024-06-06 13:29:22 +07:00
}