import type { Survey } from '~/server/models/survey';
export const useSurveyStore = defineStore('useSurveyStore', () => {
    const currentSurvey = shallowReactive<Survey>({})
    async function fetchById(id: number) {

        try {
            const { data } = await useFetch<any>(`/api/services/survey/get-by-id`, {
                query: {
                    surveyId: id
                }
            })
            data.value && (Object.assign(currentSurvey, data.value))
            return currentSurvey
        } catch(error) {

        }
    }

    return { fetchById, currentSurvey }
})

if(import.meta.hot) {
    import.meta.hot.accept(acceptHMRUpdate(useSurveyStore, import.meta.hot))
}