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 { 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))
|
||||
}
|
||||
Reference in New Issue
Block a user