Files
NSG_PORTAL_V2/stores/poll-option.ts
T
2024-06-12 17:17:49 +07:00

25 lines
820 B
TypeScript

import type { PollOption } from "~/server/models/poll-option"
export const usePollOptionStore = defineStore('usePollOptionStore', () => {
const currentPollOption = shallowReactive<PollOption>({})
const currentPollOptions = shallowRef<PollOption[] | any[]>([])
async function fetchByPollId(id: string) {
try {
const { data } = await useFetch<any>(`/api/services/poll-option/pollId`, {
query: {
pollId: id
}
})
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))
}