-
diff --git a/definitions/cms/page.type.ts b/definitions/cms/page.type.ts
index e988734..a87eae5 100644
--- a/definitions/cms/page.type.ts
+++ b/definitions/cms/page.type.ts
@@ -164,11 +164,16 @@ export const pageComponentLayouts = {
{ title: "Dọc và ẩn Hình ảnh", value: enumPageComponentLayouts[enumPageComponentTemplates.ARTICLE]['VERTICAL-HIDE_THUMBNAIL'] },
{ title: "Dọc và ẩn Giới thiệu", value: enumPageComponentLayouts[enumPageComponentTemplates.ARTICLE]['VERTICAL-HIDE_PARAGRAPH'] },
{ title: "Dọc và ẩn Giới thiệu, ngược", value: enumPageComponentLayouts[enumPageComponentTemplates.ARTICLE]['VERTICAL-HIDE_PARAGRAPH-REVERSE'] },
+ { title: "mặc định", value: enumPageComponentLayouts[enumPageComponentTemplates.ARTICLE]['DEFAULT'] },
],
[`${enumPageComponentTemplates.CATEGORY}`]: [
{ title: "Danh mục", value: enumPageComponentLayouts[enumPageComponentTemplates.CATEGORY]['DEFAULT'] }
],
[`${enumPageComponentTemplates.COLLECTION}`]: [
{ title: "Cụm Bài viết 5 phần tử, Bài viết ngang", value: enumPageComponentLayouts[enumPageComponentTemplates.COLLECTION]['ARTICLE-VERTICAL-|HORIZONTAL|-MAX_5'] },
+ { title: "Cụm Bài viết Mặc định", value: enumPageComponentLayouts[enumPageComponentTemplates.COLLECTION]['DEFAULT'] },
+ ],
+ [`${enumPageComponentTemplates.ADVERTISING}`]: [
+ { title: "Quảng cáo mặc định", value: enumPageComponentLayouts[enumPageComponentTemplates.ADVERTISING]['DEFAULT'] },
]
};
diff --git a/definitions/enum/page.enum.ts b/definitions/enum/page.enum.ts
index 60b2489..a885308 100644
--- a/definitions/enum/page.enum.ts
+++ b/definitions/enum/page.enum.ts
@@ -131,6 +131,7 @@ export const enumPageComponentLayouts = {
'VERTICAL-HIDE_THUMBNAIL': "LAYOUT:vertical-HIDE:thumbnail",
'VERTICAL-HIDE_PARAGRAPH': "LAYOUT:vertical-HIDE:paragraph",
'VERTICAL-HIDE_PARAGRAPH-REVERSE': "LAYOUT:vertical-HIDE:paragraph-REVERSE:true",
+ "DEFAULT": "TYPE:Detail-LAYOUT:default"
},
[`${enumPageComponentTemplates.CATEGORY}`]: {
NONE: "None",
@@ -141,6 +142,9 @@ export const enumPageComponentLayouts = {
},
[`${enumPageComponentTemplates.OTHER}`]: {
'"ARTICLE_BUTTON"': '"ARTICLE_BUTTON"'
+ },
+ [`${enumPageComponentTemplates.ADVERTISING}`]: {
+ 'DEFAULT': 'DEFAULT'
}
};
diff --git a/pages/bai-viet/[slug].vue b/pages/bai-viet/[slug].vue
index f607f5c..8d241b9 100644
--- a/pages/bai-viet/[slug].vue
+++ b/pages/bai-viet/[slug].vue
@@ -40,35 +40,31 @@ watch(currentArticle, async () => {
let isContentType : string = '';
switch (currentArticle.value?.contentType) {
case 1:
- isContentType = 'trang-doi-song'
+ isContentType = 'trang-chi-tiet-bai-viet-general'
break;
case 2:
- isContentType = 'ArticleLayoutImage'
+ isContentType = 'trang-chi-tiet-bai-viet-image'
break;
case 3:
- isContentType = 'trang-chi-tiet-podcast'
+ isContentType = 'trang-chi-tiet-bai-viet-postcart'
break;
case 4:
- isContentType = 'trang-chi-tiet-video-clip'
+ isContentType = 'trang-chi-tiet-bai-viet-video'
break;
case 5:
if (currentArticle.value?.layoutType === 4) {
- isContentType = 'trang-chi-tiet-emagazine'
+ isContentType = 'trang-chi-tiet-bai-viet-emagazine'
break;
}
if (currentArticle.value?.layoutType === 3) {
- isContentType = 'trang-chi-tiet-infographics'
+ isContentType = 'trang-chi-tiet-bai-viet-infographics'
break;
}
- // else {
- // isContentType = 'trang-chi-tiet-emagazine'
- // break;
- // }
default:
- isContentType = 'trang-chi-tiet-emagazine'
+ isContentType = 'trang-chi-tiet-bai-viet-general'
break;
}
await loadPage(isContentType);
@@ -83,9 +79,6 @@ useSeoMeta({
twitterCard: 'summary_large_image',
})
-onMounted(() => {
- console.log(document.querySelectorAll('document'), '12')
-})
diff --git a/server/api/services/[...].ts b/server/api/services/[...].ts
index 5affaaa..1127478 100644
--- a/server/api/services/[...].ts
+++ b/server/api/services/[...].ts
@@ -6,6 +6,9 @@ import * as topicCtrl from '~/server/models/topic'
import * as pollCtrl from '~/server/models/poll'
import * as pollOptionCtrl from '~/server/models/poll-option'
import * as pollResponseCtrl from '~/server/models/poll-response'
+import * as CategoryCtrl from '~/server/models/category'
+import * as quizCtrl from '~/server/models/quiz'
+import * as survetCtrl from '~/server/models/survey'
const router = createRouter()
@@ -16,4 +19,8 @@ router.get('/event', defineEventHandler(eventCtrl.fetchById))
router.get('/poll-by-id', defineEventHandler(pollCtrl.fetchById))
router.get('/poll-option/pollId', defineEventHandler(pollOptionCtrl.fetchByPollId))
router.post('/poll-response', defineEventHandler(pollResponseCtrl.create))
+router.get('/poll-response/pollId', defineEventHandler(pollResponseCtrl.fetchByPollId))
+router.get('/quiz/get-by-id', defineEventHandler(quizCtrl.fetchById))
+router.get('/survey/get-by-id', defineEventHandler(survetCtrl.fetchById))
+router.get('/category-tree', defineEventHandler(CategoryCtrl.list))
export default useBase('/api/services', router.handler)
diff --git a/server/models/category.ts b/server/models/category.ts
index a20cd85..4a6be1e 100644
--- a/server/models/category.ts
+++ b/server/models/category.ts
@@ -24,20 +24,22 @@ export type Category = {
status: number;
} & Base;
+export type CategoryTree = Category & {
+ children?: Category[]
+}
+
export const list = async () => {
+ console.log('vào category service')
try {
const { site, apiUrl } = useRuntimeConfig().public;
- const {items}:any = await $fetch(`${apiUrl}/cms/category/site`, {
+ const { items }: CategoryTree[] | any = await $fetch(`${apiUrl}/cms/category/tree/site:1`, {
method: "GET",
headers: {
- "Content-Type": "application/json",
- Accept: "application/json",
- site: site,
+ site: 1,
},
});
-
- return items;
+ return { items } ;
} catch (error) {
handleError(error);
}
diff --git a/server/models/poll-option.ts b/server/models/poll-option.ts
index e8bfab0..c506c7e 100644
--- a/server/models/poll-option.ts
+++ b/server/models/poll-option.ts
@@ -1,13 +1,25 @@
import { H3Event } from 'h3';
import Base from './base'
+export type PollOption = {
+ id?: number; // Mã định danh
+ siteId?: number; // Mã hệ thống
+ pollId?: number; // Mã bình chọn
+ title?: string; // Tiêu đề
+ thumbnail?: string; // Ảnh đại diện
+ description?: string; // Mô tả
+ type?: number; // Phân loại
+ order?: number; // Sắp xếp
+ status?: number; // Trạng thái
+ responsesCount?: number //số lượng response của option
+ }
export const fetchByPollId = async (event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
- const { pollId}: any = getQuery(event)
- const { items }: any = await $fetch(`${apiUrl}/cms/poll-option/poll:${pollId}`, {
+ const { pollId }: any = getQuery(event)
+ const { items }: PollOption[] | any = await $fetch(`${apiUrl}/cms/poll-option/poll:${pollId}`, {
method: 'GET',
headers: {
site: 1
diff --git a/server/models/poll-response.ts b/server/models/poll-response.ts
index d4f81f9..8aaf572 100644
--- a/server/models/poll-response.ts
+++ b/server/models/poll-response.ts
@@ -1,8 +1,17 @@
import { H3Event } from 'h3';
import Base from './base'
+export type PollResponse = {
+ id?: number; // Mã định danh
+ siteId?: number; // Mã hệ thống
+ pollId?: number; // Mã bình chọn
+ optionId?: number; // Mã tùy chọn
+ responderId?: number; // Mã người phản hồi
+ responderInfo?: string; // Thông tin người phản hồi
+ status?: number; // Trạng thái
+}
- export const create = async (event: H3Event) => {
+export const create = async (event: H3Event) => {
try {
const { apiUrl } = useRuntimeConfig().public
const payload = await readBody(event)
@@ -11,14 +20,31 @@ import Base from './base'
headers: {
site: 1
},
- body: {
- payload
- }
+ body: payload
})
-
+ console.log(payload, 'payload')
return item
} catch (error) {
handleError(error);
}
- }
\ No newline at end of file
+}
+
+export const fetchByPollId = async (event: H3Event) => {
+ try {
+
+ const { apiUrl } = useRuntimeConfig().public
+ const { pollId }: any = getQuery(event)
+ const { items }: PollResponse[] | any = await $fetch(`${apiUrl}/cms/poll-response/poll:${pollId}`, {
+ method: 'GET',
+ headers: {
+ site: 1
+ }
+ })
+
+ return items
+
+ } catch (error) {
+ handleError(error);
+ }
+}
\ No newline at end of file
diff --git a/server/models/poll.ts b/server/models/poll.ts
index 1c96ac8..614b019 100644
--- a/server/models/poll.ts
+++ b/server/models/poll.ts
@@ -1,6 +1,11 @@
import { H3Event } from 'h3';
import Base from './base'
+export type PollSetting = {
+ participantType?: number; // Loại thành phần tham gia
+ resultPublication?: number; // Nguyên tắc công bố kết quả
+}
+
export type Poll = {
id?: number; // Mã định danh
siteId?: number; // Mã hệ thống
@@ -12,7 +17,7 @@ export type Poll = {
startTime?: string; // Bắt đầu (string)
endTime?: string; // Kết thúc (string)
type?: number; // Phân loại
- settings?: object; // Thiết lập: PollSettings (Json)
+ settings?: PollSetting; // Thiết lập: PollSettings (Json)
features?: string; // Đặc trưng: Featured (nổi bật)
taxonomy?: string; // Phân nhóm
isPublished?: boolean; // Đã xuất bản
@@ -25,10 +30,9 @@ export type Poll = {
export const fetchById = async (event: H3Event) => {
try {
-
const { apiUrl } = useRuntimeConfig().public
const { pollId}: any = getQuery(event)
- const { item }: any = await $fetch(`${apiUrl}/cms/poll/${pollId}`, {
+ const { item }: Poll | any = await $fetch(`${apiUrl}/cms/poll/${pollId}`, {
method: 'GET',
headers: {
site: 1
diff --git a/server/models/quiz.ts b/server/models/quiz.ts
new file mode 100644
index 0000000..dcf5493
--- /dev/null
+++ b/server/models/quiz.ts
@@ -0,0 +1,46 @@
+import { H3Event } from 'h3';
+export type QuizSetting = {
+ participantType?: number; // Loại thành phần tham gia
+ resultPublication?: number; // Nguyên tắc công bố kết quả
+ }
+
+export type Quiz = {
+ id?: number; // Mã định danh
+ siteId?: number; // Mã hệ thống
+ title?: string; // Tiêu đề
+ code?: string; // Nhận diện
+ keywords?: string; // Từ khóa
+ thumbnail?: string; // Ảnh nhỏ
+ description?: string; // Mô tả
+ startTime?: string; // Bắt đầu
+ endTime?: string; // Kết thúc
+ type?: number; // Phân loại
+ settings?: object; // Thiết lập
+ features?: string; // Đặc trưng
+ taxonomy?: string; // Phân nhóm
+ isPublished?: boolean; // Đã xuất bản
+ publishedBy?: number; // Xuất bản bởi
+ publishedOn?: string; // Xuất bản vào lúc
+ expiresOn?: string; // Đã hết hạn vào lúc
+ order?: number; // Thứ tự sắp xếp
+ status?: number; // Trạng thái
+ }
+
+ export const fetchById = async (event: H3Event) => {
+ try {
+
+ const { apiUrl } = useRuntimeConfig().public
+ const { quizId }: any = getQuery(event)
+ const { item }: Quiz | any = await $fetch(`${apiUrl}/cms/quiz/${quizId}`, {
+ method: 'GET',
+ headers: {
+ site: 1
+ }
+ })
+
+ return item
+
+ } catch (error) {
+ handleError(error);
+ }
+ }
\ No newline at end of file
diff --git a/server/models/survey.ts b/server/models/survey.ts
new file mode 100644
index 0000000..a8c1bee
--- /dev/null
+++ b/server/models/survey.ts
@@ -0,0 +1,46 @@
+import { H3Event } from 'h3';
+export type SurveySetting = {
+ participantType?: number; // Loại thành phần tham gia
+ resultPublication?: number; // Nguyên tắc công bố kết quả
+ }
+
+export type Survey = {
+ id?: number; // Mã định danh
+ siteId?: number; // Mã hệ thống
+ title?: string; // Tiêu đề
+ code?: string; // Nhận diện
+ keywords?: string; // Từ khóa
+ thumbnail?: string; // Ảnh nhỏ
+ description?: string; // Mô tả
+ startTime?: string; // Bắt đầu, assuming date is handled as ISO string
+ endTime?: string; // Kết thúc, assuming date is handled as ISO string
+ type?: number; // Phân loại
+ settings?: SurveySetting; // Thiết lập, as a JSON string
+ features?: string; // Đặc trưng
+ taxonomy?: string; // Phân nhóm
+ isPublished?: boolean; // Đã xuất bản
+ publishedBy?: number; // Xuất bản bởi
+ publishedOn?: string; // Xuất bản vào lúc, assuming date is handled as ISO string
+ expiresOn?: string; // Đã hết hạn vào lúc, assuming date is handled as ISO string
+ order?: number; // Thứ tự sắp xếp
+ status?: number; // Trạng thái
+ }
+
+ export const fetchById = async (event: H3Event) => {
+ try {
+
+ const { apiUrl } = useRuntimeConfig().public
+ const { surveyId }: any = getQuery(event)
+ const { item }: Survey | any = await $fetch(`${apiUrl}/cms/survey/${surveyId}`, {
+ method: 'GET',
+ headers: {
+ site: 1
+ }
+ })
+
+ return item
+
+ } catch (error) {
+ handleError(error);
+ }
+ }
\ No newline at end of file
diff --git a/stores/category.ts b/stores/category.ts
index 26b0a2d..86e7767 100644
--- a/stores/category.ts
+++ b/stores/category.ts
@@ -1,72 +1,102 @@
-import type { Category } from "~/server/models/category";
+import type { Category, CategoryTree } from "~/server/models/category";
-export const useCategoryStore = defineStore("category-v2", () => {
- const categories = ref([]);
+// export const useCategoryStore = defineStore("category-v2", () => {
+// const categories = ref([]);
+// const categoryTree = ref([]);
+// const currentCategoryTree = ref([])
- async function fetchCategories() {
- const { data, error } = await useFetch("/api/v2/categories");
- if (error.value) {
- return [] as Category[];
- }
+// const findBySiteId = async () => {
+// try {
+// const { data } = await useFetch(`/api/services/category-tree`)
+// categoryTree.value = data.value
+// return categoryTree.value
+// } catch (error) {}
+// }
- categories.value = Object.assign([], data.value);
+// async function fetchCategories() {
+// const { data, error } = await useFetch("/api/v2/categories");
+// if (error.value) {
+// return [] as Category[];
+// }
- return categories.value;
+// categories.value = Object.assign([], data.value);
+
+// return categories.value;
+// }
+
+// function findByCode(code?: string) {
+// if (code) return categories.value.find((c) => c.code === code);
+// }
+
+// function findById(id?: number) {
+// return categories.value.find((c) => c.id === id);
+// }
+
+// function findParents(category?: Category) {
+// if (!category) return [];
+
+// const parents = [];
+// let parent = findById(category.parentId);
+// while (parent) {
+// parents.push(parent);
+// parent = findById(parent.parentId);
+// }
+
+// return parents.reverse().concat(category);
+// }
+
+// function findSubTree(category?: Category) {
+// if (!category) return [];
+
+// let subTree = [] as Category[];
+
+// function findChildren(category: Category) {
+// const children = categories.value.filter((c:Category) => c.parentId === category.id);
+// if (children.length === 0) return;
+
+// subTree.push(...children,category);
+// }
+
+// if(category.parentId === 41){
+// findChildren(category);
+// }else{
+// const parent = findById(category.parentId);
+// if(parent){
+// findChildren(parent);
+// }
+// }
+
+// return subTree.reverse();
+// }
+
+// function findChildren(category: Category) {
+// const children = categories.value.filter((c:Category) => c.parentId === category.id);
+// if (children.length === 0) return;
+// else return [...children]
+// }
+
+
+
+// return { categories, categoryTree, currentCategoryTree, findBySiteId, fetchCategories, findByCode, findById, findParents,findSubTree, findChildren };
+// });
+
+export const useCategoryStore = defineStore('usecategorystore', () => {
+ const categoryTree = shallowRef([])
+ const currentCategoryTree = shallowRef([])
+
+ async function fetchBySiteId() {
+ const { data }: any = await useFetch(`/api/services/category-tree`)
+ categoryTree.value = data.value.items
+ return categoryTree.value
}
- function findByCode(code?: string) {
- if (code) return categories.value.find((c) => c.code === code);
+ return {
+ categoryTree,
+ currentCategoryTree,
+
+ fetchBySiteId
}
-
- function findById(id?: number) {
- return categories.value.find((c) => c.id === id);
- }
-
- function findParents(category?: Category) {
- if (!category) return [];
-
- const parents = [];
- let parent = findById(category.parentId);
- while (parent) {
- parents.push(parent);
- parent = findById(parent.parentId);
- }
-
- return parents.reverse().concat(category);
- }
-
- function findSubTree(category?: Category) {
- if (!category) return [];
-
- let subTree = [] as Category[];
-
- function findChildren(category: Category) {
- const children = categories.value.filter((c:Category) => c.parentId === category.id);
- if (children.length === 0) return;
-
- subTree.push(...children,category);
- }
-
- if(category.parentId === 41){
- findChildren(category);
- }else{
- const parent = findById(category.parentId);
- if(parent){
- findChildren(parent);
- }
- }
-
- return subTree.reverse();
- }
-
- function findChildren(category: Category) {
- const children = categories.value.filter((c:Category) => c.parentId === category.id);
- if (children.length === 0) return;
- else return [...children]
- }
-
- return { categories, fetchCategories, findByCode, findById, findParents,findSubTree, findChildren };
-});
+})
if (import.meta.hot) {
import.meta.hot.accept(acceptHMRUpdate(useCategoryStore, import.meta.hot));
diff --git a/stores/dynamic-page.ts b/stores/dynamic-page.ts
index 6df74b8..e59e777 100644
--- a/stores/dynamic-page.ts
+++ b/stores/dynamic-page.ts
@@ -10,6 +10,866 @@ export const useDynamicPageStore = defineStore("dynamicPageStore", () => {
async function fetchPageByCode(slug: any) {
try {
const { data } = await useFetch(`/api/dynamic-page/get-by-code/${slug}`)
+ // const data = ref({
+ // "sections": [
+ // {
+ // "id": 42,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section5hang",
+ // "slug": "section5hang",
+ // "code": "section5hang",
+ // "type": 1,
+ // "content": "[{\"type\":\"component\",\"data\":57},{\"type\":\"component\",\"data\":68},{\"type\":\"component\",\"data\":69},{\"type\":\"component\",\"data\":44},{\"type\":\"component\",\"data\":50}]",
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:horizontal-TYPE:Default-MAX:5",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T16:17:57.386059",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:18:56.082485"
+ // },
+ // {
+ // "id": 32,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section2hang",
+ // "slug": "section2hang",
+ // "code": "section2hang_doisong",
+ // "type": 1,
+ // "content": "[{\"type\":\"component\",\"data\":58},{\"type\":\"component\",\"data\":101}]",
+ // "keywords": null,
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:horizontal-TYPE:Default-MAX:2",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T10:33:59.071404",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:18:56.493553"
+ // },
+ // {
+ // "id": 31,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section2left3",
+ // "slug": "section2left3",
+ // "code": "section2left3_doisong",
+ // "type": 1,
+ // "content": "[{\"type\":\"section\",\"data\":42},{\"type\":\"section\",\"data\":32}]",
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:vertical-TYPE:LEFT-MAX:2",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": "",
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:02:35.828188",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T09:36:43.623068"
+ // },
+ // {
+ // "id": 30,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section2left2",
+ // "slug": "section2left2",
+ // "code": "section2left2_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:vertical-TYPE:LEFT-MAX:2",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": "",
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:02:09.626405",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T09:37:17.837094"
+ // },
+ // {
+ // "id": 29,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section2left1",
+ // "slug": "section2left1",
+ // "code": "section2left1_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:vertical-TYPE:LEFT-MAX:2",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": "",
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:01:11.78265",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T09:01:40.494573"
+ // },
+ // {
+ // "id": 28,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section3cot",
+ // "slug": "section3cot",
+ // "code": "section3cot_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:vertical-TYPE:Default-MAX:3",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": "",
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:00:32.765855",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T09:37:50.127734"
+ // },
+ // {
+ // "id": 27,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section2left",
+ // "slug": "section2left",
+ // "code": "section2left_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:vertical-TYPE:LEFT-MAX:2",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": "",
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:00:05.873579",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T09:38:06.600079"
+ // },
+ // {
+ // "id": 26,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section3hang",
+ // "slug": "section3hang",
+ // "code": "section3hang_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": null,
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:horizontal-TYPE:Default-MAX:3",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T08:59:19.411836",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T09:38:29.410238"
+ // },
+ // {
+ // "id": 25,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section1hang1",
+ // "slug": "section1hang1",
+ // "code": "section1hang1_doisong",
+ // "type": 1,
+ // "content": "",
+ // "keywords": null,
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:horizontal-TYPE:Default-MAX:1",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T08:53:59.364384",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T08:57:34.1155"
+ // },
+ // {
+ // "id": 24,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "parentId": null,
+ // "title": "section1hang",
+ // "slug": "section1hang",
+ // "code": "section1hang_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": null,
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:horizontal-TYPE:Default-MAX:1",
+ // "template": "Article",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T08:53:52.871306",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T09:39:00.332127"
+ // }
+ // ],
+ // "components": [
+ // {
+ // "id": 101,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "ads2_doisong",
+ // "code": "ads2_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "ADS_DEFAULT",
+ // "template": "Other",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-06-04T15:44:49.728501",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-06-04T15:45:02.192997"
+ // },
+ // {
+ // "id": 69,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "coppy_link_2",
+ // "code": "coppy_link_2",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "ARTICLE_BUTTON",
+ // "template": "Other",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T15:51:28.699877",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:00.334897"
+ // },
+ // {
+ // "id": 68,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "article_detail_1",
+ // "code": "article_detail_1",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "ARTICLE_DETAIL_DEFAULT",
+ // "template": "Other",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T15:37:58.099224",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:00.742949"
+ // },
+ // {
+ // "id": 62,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "coppy_link_1",
+ // "code": "coppy_link_1",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "ARTICLE_DETAIL_DEFAULT",
+ // "template": "Other",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": -1,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T15:24:08.987936",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T15:25:38.566902"
+ // },
+ // {
+ // "id": 58,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "ads_1",
+ // "code": "ads_1",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "ADS_DEFAULT",
+ // "template": "Other",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T15:09:08.953513",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:01.56169"
+ // },
+ // {
+ // "id": 57,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "breadcrumb_1",
+ // "code": "breadcrumb_1",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "BREADCRUM_DEFAULT",
+ // "template": "Other",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T15:01:25.190114",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:01.972624"
+ // },
+ // {
+ // "id": 50,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "comment",
+ // "code": "comment_default1",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "COMMENT",
+ // "template": "Other",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T11:37:42.957585",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T11:38:23.481239"
+ // },
+ // {
+ // "id": 47,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "collection_paging",
+ // "code": "collection_paging_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "DEFAULT",
+ // "template": "Section",
+ // "dataQuery": "Get[Article] Top[10] With[Categories:81]",
+ // "dataResult": "[]",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:49:48.945226",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:02.788055"
+ // },
+ // {
+ // "id": 44,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "collection5item2",
+ // "code": "collection5item2_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "TYPE:Article-LAYOUT:vertical-DATA:HORIZONTAL-MAX:5",
+ // "template": "Collection",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": true,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:18:53.361283",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:03.20532"
+ // },
+ // {
+ // "id": 43,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "article_doc",
+ // "code": "article_doc_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:vertical",
+ // "template": "Article",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:18:26.503605",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:03.613773"
+ // },
+ // {
+ // "id": 42,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "collection5item",
+ // "code": "collection5item_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "TYPE:Article-LAYOUT:vertical-DATA:HORIZONTAL-MAX:5",
+ // "template": "Collection",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:17:57.798722",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:04.026497"
+ // },
+ // {
+ // "id": 41,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "article_doc_intro3",
+ // "code": "article_doc_intro3_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:vertical-HIDE:paragraph",
+ // "template": "Article",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:17:21.675354",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:04.431454"
+ // },
+ // {
+ // "id": 40,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "article_doc_intro2",
+ // "code": "article_doc_intro2_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:vertical-HIDE:paragraph",
+ // "template": "Article",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:16:56.07848",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:04.842294"
+ // },
+ // {
+ // "id": 39,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "article_doc_intro1",
+ // "code": "article_doc_intro1_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:vertical-HIDE:paragraph",
+ // "template": "Article",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:16:39.074945",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:05.246938"
+ // },
+ // {
+ // "id": 38,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "article_ngang",
+ // "code": "article_ngang_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "LAYOUT:horizontal",
+ // "template": "Article",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:15:38.638781",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:05.664736"
+ // },
+ // {
+ // "id": 37,
+ // "siteId": 1,
+ // "pageId": 4,
+ // "sectionId": null,
+ // "title": "category",
+ // "code": "category_doisong",
+ // "type": 1,
+ // "content": null,
+ // "keywords": "",
+ // "settings": {
+ // "label": "",
+ // "layout": "DEFAULT",
+ // "template": "Category",
+ // "dataQuery": null,
+ // "dataResult": "",
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": null,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T09:14:11.978206",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:19:06.0724"
+ // }
+ // ],
+ // "id": 4,
+ // "siteId": 1,
+ // "parentId": null,
+ // "title": "Trang đời sống",
+ // "slug": "trang-doi-song",
+ // "code": "page-doi-song",
+ // "type": 1,
+ // "content": null,
+ // "favicon": null,
+ // "keywords": null,
+ // "thumbnail": null,
+ // "settings": {
+ // "label": "",
+ // "layout": "Center_Page",
+ // "template": "Home",
+ // "dataQuery": null,
+ // "dataResult": null,
+ // "pinned": null
+ // },
+ // "features": "Navigation",
+ // "taxonomy": "Navigation",
+ // "description": null,
+ // "isPublished": false,
+ // "publishedBy": null,
+ // "publishedOn": null,
+ // "expiresOn": null,
+ // "order": 0,
+ // "status": 6,
+ // "createdBy": 1,
+ // "createdOn": "2024-05-30T08:42:10.319911",
+ // "updatedBy": 1,
+ // "updatedOn": "2024-05-30T16:18:55.254121"
+ // })
currentPage.value = {}
currentPage.value = data.value
} catch (error: any) {}
@@ -35,6 +895,8 @@ export const useDynamicPageStore = defineStore("dynamicPageStore", () => {
(section: any) => section.isPublished && !contentArr.flat().some((_section: any) => _section && _section.data && _section.type === "section" && section.id === _section.data)
).sort((a: any, b: any) => a.order - b.order);
+ console.log(sectionPublished.value, 'section');
+
};
const setComponentPublished = () => {
@@ -44,7 +906,7 @@ export const useDynamicPageStore = defineStore("dynamicPageStore", () => {
return section;
});
componentPublished.value = currentPage.value.components && currentPage.value.components.filter((section: any) => section.isPublished);
-
+ console.log(componentPublished.value ,'123123')
};
const setDataQuery = (query: any, componentId: number | string) => {
@@ -63,30 +925,16 @@ export const useDynamicPageStore = defineStore("dynamicPageStore", () => {
setComponentPublished();
};
-
- function increaseStep(increase: number) {
- step.value += increase
- return step.value
- }
-
- function decreaseStep(decrease: number) {
- step.value -= decrease
- return step.value
- }
return {
currentPage,
sectionPublished,
componentPublished,
- step,
fetchPageByCode,
fetchPageById,
setSectionPublished,
setComponentPublished,
setDataQuery,
-
- increaseStep,
- decreaseStep,
};
});
diff --git a/stores/poll-option.ts b/stores/poll-option.ts
index f95a044..c2dc72d 100644
--- a/stores/poll-option.ts
+++ b/stores/poll-option.ts
@@ -1,20 +1,25 @@
-export const usePollOptionStore = defineStore('usepollOptionStore', () => {
+import type { PollOption } from "~/server/models/poll-option"
+export const usePollOptionStore = defineStore('usePollOptionStore', () => {
+ const currentPollOption = shallowReactive({})
+ const currentPollOptions = shallowRef([])
async function fetchByPollId(id: string) {
- const { data, error } = await useFetch(`/api/services/poll-option/pollId`, {
- query: {
- pollId: id
- }
- })
- if(error.value) {
- return null
- }
+ try {
+ const { data } = await useFetch(`/api/services/poll-option/pollId`, {
+ query: {
+ pollId: id
+ }
+ })
+
+ data.value && (currentPollOptions.value = data.value)
+ return currentPollOptions.value
+ } catch(error) {}
+
- return data.value
}
- return { fetchByPollId }
+ return { currentPollOptions, fetchByPollId }
})
if(import.meta.hot) {
- import.meta.hot.accept(acceptHMRUpdate(useTagStore, import.meta.hot))
+ import.meta.hot.accept(acceptHMRUpdate(usePollOptionStore, import.meta.hot))
}
\ No newline at end of file
diff --git a/stores/poll-response.ts b/stores/poll-response.ts
index c4786ae..a0bd216 100644
--- a/stores/poll-response.ts
+++ b/stores/poll-response.ts
@@ -1,19 +1,40 @@
-export const usePollResponseStore = defineStore('usepollResponseStore', () => {
- async function create(pollResponse: any) {
- const { data, error } = await useFetch(`/api/services/poll-response`, {
- method: 'POST',
- body: pollResponse
- })
- if(error.value) {
- return null
+import type { PollResponse } from "~/server/models/poll-response"
+export const usePollResponseStore = defineStore('usePollResponseStore', () => {
+ const currentPollResponse = shallowReactive({})
+ const currentPollResponses = shallowRef([])
+ const create = async (pollResponse: any) => {
+
+ try {
+ const { data } = await useFetch(`/api/services/poll-response`, {
+ method: 'POST',
+ body: pollResponse
+ })
+ data.value && (Object.assign(currentPollResponse, data.value))
+ return currentPollResponse
+ } catch (error) {
+
}
- return data.value
}
- return { create }
+ async function fetchByPollId(id: string) {
+ try {
+ const { data } = await useFetch(`/api/services/poll-response/pollId`, {
+ query: {
+ pollId: id
+ }
+ })
+
+ data.value && (currentPollResponses.value = data.value)
+ return currentPollResponses.value
+ } catch (error) { }
+
+
+ }
+
+ return { currentPollResponse, currentPollResponses, create, fetchByPollId }
})
-if(import.meta.hot) {
- import.meta.hot.accept(acceptHMRUpdate(useTagStore, import.meta.hot))
+if (import.meta.hot) {
+ import.meta.hot.accept(acceptHMRUpdate(usePollResponseStore, import.meta.hot))
}
\ No newline at end of file
diff --git a/stores/poll.ts b/stores/poll.ts
index 6142186..cf75ff5 100644
--- a/stores/poll.ts
+++ b/stores/poll.ts
@@ -1,20 +1,33 @@
-export const usePollStore = defineStore('usepollStore', () => {
+import type { Poll } from "~/server/models/poll"
+export const usePollStore = defineStore('usePollStore', () => {
+ const currentPoll = shallowReactive({})
async function fetchById(id: string) {
- const { data, error } = await useFetch(`/api/services/poll-by-id`, {
- query: {
- pollId: id
- }
- })
- if(error.value) {
- return null
- }
- return data.value
+ try {
+ const { data } = await useFetch(`/api/services/poll-by-id`, {
+ query: {
+ pollId: id
+ }
+ })
+
+ data.value && (Object.assign(currentPoll, data.value))
+ return currentPoll
+ } catch(error) {
+
+ }
}
- return { fetchById }
+ async function categoryId() {
+ try {
+ const { data } = await useFetch(`/api/services/category-tree`)
+ return data.value
+ } catch (error) {}
+
+ }
+
+ return { fetchById, currentPoll, categoryId }
})
if(import.meta.hot) {
- import.meta.hot.accept(acceptHMRUpdate(useTagStore, import.meta.hot))
+ import.meta.hot.accept(acceptHMRUpdate(usePollStore, import.meta.hot))
}
\ No newline at end of file
diff --git a/stores/quiz.ts b/stores/quiz.ts
new file mode 100644
index 0000000..bdd646a
--- /dev/null
+++ b/stores/quiz.ts
@@ -0,0 +1,24 @@
+import type { Quiz } from '~/server/models/quiz';
+export const useQuizStore = defineStore('useQuizStore', () => {
+ const currentQuiz = shallowReactive({})
+ async function fetchById(id: number) {
+
+ try {
+ const { data } = await useFetch(`/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))
+}
\ No newline at end of file
diff --git a/stores/survey.ts b/stores/survey.ts
new file mode 100644
index 0000000..f36084b
--- /dev/null
+++ b/stores/survey.ts
@@ -0,0 +1,24 @@
+import type { Survey } from '~/server/models/survey';
+export const useSurveyStore = defineStore('useSurveyStore', () => {
+ const currentSurvey = shallowReactive({})
+ async function fetchById(id: number) {
+
+ try {
+ const { data } = await useFetch(`/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))
+}
\ No newline at end of file
diff --git a/uno.config.ts b/uno.config.ts
index 03ba25c..8a237c5 100644
--- a/uno.config.ts
+++ b/uno.config.ts
@@ -40,6 +40,7 @@ export default defineConfig({
"after:no-content": "after:content-['']",
"before:no-content": "before:content-['']",
'container-xxl': 'px-[8px] mx-auto w-full sm:w-620px md:w-760px lg:w-980px xl:w-1100px 2xl:w-1200px',
+ 'container-long': 'px-2 mx-auto w-full sm:w-620px md:w-760px lg:w-980px xl:w-1100px 2xl:w-1200px'
},
],
rules: [