thainv-dev: tạo lại cấu trúc folder và làm UI
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type { Quiz } from '~/server/models/quiz';
|
||||
export const useQuizStore = defineStore('useQuizStore', () => {
|
||||
const currentQuiz = shallowReactive<Quiz>({})
|
||||
async function fetchById(id: number) {
|
||||
|
||||
try {
|
||||
const { data } = await useFetch<any>(`/api/services/quiz/get-by-id`, {
|
||||
query: {
|
||||
quizId: id
|
||||
}
|
||||
})
|
||||
data.value && (Object.assign(currentQuiz, data.value))
|
||||
return currentQuiz
|
||||
} catch(error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return { fetchById, currentQuiz }
|
||||
})
|
||||
|
||||
if(import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useQuizStore, import.meta.hot))
|
||||
}
|
||||
Reference in New Issue
Block a user