Files
nguyen van thai 795cd47e41 thainv-dev: Fix
2024-07-17 10:35:35 +07:00

28 lines
936 B
TypeScript

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