thainv-dev: tạo lại cấu trúc folder và làm UI

This commit is contained in:
nguyen van thai
2024-06-12 17:17:49 +07:00
parent c217ed82c9
commit 5b1e0af397
44 changed files with 2674 additions and 228 deletions
+17 -12
View File
@@ -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))
}