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))
}