thainv-dev: Fix

This commit is contained in:
nguyen van thai
2024-07-17 10:35:35 +07:00
parent 5f9525371d
commit 795cd47e41
18 changed files with 78 additions and 43 deletions
+7 -2
View File
@@ -83,9 +83,14 @@ import type { Category, CategoryTree } from "~/server/models/category";
export const useCategoryStore = defineStore('usecategorystore', () => {
const categoryTree = shallowRef<CategoryTree[]>([])
const currentCategoryTree = shallowRef<any[]>([])
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
async function fetchBySiteId() {
const { data }: any = await useFetch(`/api/services/category-tree`)
const { data }: any = await useFetch(`/api/services/category-tree`,{
query: {
site: host
}
})
categoryTree.value = data.value.items
return categoryTree.value
}
+4 -1
View File
@@ -2,11 +2,14 @@ import type { PollOption } from "~/server/models/poll-option"
export const usePollOptionStore = defineStore('usePollOptionStore', () => {
const currentPollOption = shallowReactive<PollOption>({})
const currentPollOptions = shallowRef<PollOption[] | any[]>([])
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
async function fetchByPollId(id: string) {
try {
const { data } = await useFetch<any>(`/api/services/poll-option/pollId`, {
query: {
pollId: id
pollId: id,
site: host
}
})
+6 -2
View File
@@ -2,12 +2,15 @@ import type { PollResponse } from "~/server/models/poll-response"
export const usePollResponseStore = defineStore('usePollResponseStore', () => {
const currentPollResponse = shallowReactive<PollResponse>({})
const currentPollResponses = shallowRef<PollResponse[]>([])
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
const create = async (pollResponse: any) => {
try {
const { data } = await useFetch<any>(`/api/services/poll-response`, {
method: 'POST',
body: pollResponse
body: pollResponse,
query: {site: host}
})
data.value && (Object.assign(currentPollResponse, data.value))
return currentPollResponse
@@ -21,7 +24,8 @@ export const usePollResponseStore = defineStore('usePollResponseStore', () => {
try {
const { data } = await useFetch<any>(`/api/services/poll-response/pollId`, {
query: {
pollId: id
pollId: id,
site: host
}
})
+7 -11
View File
@@ -1,12 +1,17 @@
import type { Poll } from "~/server/models/poll"
export const usePollStore = defineStore('usePollStore', () => {
const currentPoll = shallowReactive<Poll>({})
const url : any = useRequestURL();
const host = url.hostname.split('.')[0];
async function fetchById(id: string) {
try {
const { data } = await useFetch<any>(`/api/services/poll-by-id`, {
query: {
pollId: id
pollId: id,
site: host
}
})
@@ -16,16 +21,7 @@ export const usePollStore = defineStore('usePollStore', () => {
}
}
async function categoryId() {
try {
const { data } = await useFetch(`/api/services/category-tree`)
return data.value
} catch (error) {}
}
return { fetchById, currentPoll, categoryId }
return { fetchById, currentPoll }
})
if(import.meta.hot) {