25 lines
820 B
TypeScript
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))
|
|
} |