thainv-dev: tạo lại cấu trúc folder và làm UI
This commit is contained in:
+17
-12
@@ -1,20 +1,25 @@
|
||||
export const usePollOptionStore = defineStore('usepollOptionStore', () => {
|
||||
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) {
|
||||
const { data, error } = await useFetch<any>(`/api/services/poll-option/pollId`, {
|
||||
query: {
|
||||
pollId: id
|
||||
}
|
||||
})
|
||||
if(error.value) {
|
||||
return null
|
||||
}
|
||||
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 data.value
|
||||
}
|
||||
|
||||
return { fetchByPollId }
|
||||
return { currentPollOptions, fetchByPollId }
|
||||
})
|
||||
|
||||
if(import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useTagStore, import.meta.hot))
|
||||
import.meta.hot.accept(acceptHMRUpdate(usePollOptionStore, import.meta.hot))
|
||||
}
|
||||
Reference in New Issue
Block a user