diff --git a/components.d.ts b/components.d.ts index 967a0d5..872bec6 100644 --- a/components.d.ts +++ b/components.d.ts @@ -41,6 +41,7 @@ declare module 'vue' { RouterView: typeof import('vue-router')['RouterView'] SecondStep: typeof import('./src/components/ProductFormSteps/SecondStep.vue')['default'] Sidebar: typeof import('primevue/sidebar')['default'] + Tag: typeof import('primevue/tag')['default'] Textarea: typeof import('primevue/textarea')['default'] TheWelcome: typeof import('./src/components/TheWelcome.vue')['default'] ThirdStep: typeof import('./src/components/ProductFormSteps/ThirdStep.vue')['default'] diff --git a/src/layouts/Main.vue b/src/layouts/Main.vue index a88a557..efb4206 100644 --- a/src/layouts/Main.vue +++ b/src/layouts/Main.vue @@ -106,7 +106,7 @@ const items = ref([ { label: t('addVideo'), icon: 'pi pi-file-edit', - command: () => router.push('/courses/update') + command: () => router.push('/videos') }, ] diff --git a/src/router/index.js b/src/router/index.js index 02d4f3d..7cda070 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -53,11 +53,11 @@ const router = createRouter({ // name: 'Orders', // component: () => import('@/views/Orders.vue'), // }, - // { - // path: '/comments', - // name: 'Comments', - // component: () => import('@/views/Comments.vue'), - // }, + { + path: '/comments', + name: 'Comments', + component: () => import('@/views/Comments.vue'), + }, { path: '/users', name: 'Users', @@ -83,6 +83,11 @@ const router = createRouter({ name: 'EditCoupon', component: () => import('@/views/EditCoupon.vue'), }, + { + path: '/comments/:id', + name: 'Answer', + component: () => import('@/views/AnswerComment.vue'), + }, { path: '/tickets/:id', name: 'ShowTickets', @@ -93,6 +98,16 @@ const router = createRouter({ name: 'Tickets', component: () => import('@/views/Tickets.vue'), }, + { + path: '/videos', + name: 'Videos', + component: () => import('@/views/Videos.vue'), + }, + { + path: '/videos/:id', + name: 'AddVideos', + component: () => import('@/views/AddVideos.vue'), + }, { path: '/pages', children: [ diff --git a/src/stores/Headlines.js b/src/stores/Headlines.js new file mode 100644 index 0000000..9ead11b --- /dev/null +++ b/src/stores/Headlines.js @@ -0,0 +1,83 @@ +import axios from '../plugins/axios' +import { defineStore } from 'pinia' + +export const useHeadlinesStore = defineStore('headlines', { + state: () => ({ + items: [], + brands: [], + categories: [], + fetching: true, + total: 0 + }), + actions: { + async index(courseId) { + this.items = []; + this.fetching = true + const { status, data } = await axios.get('/courseHeadline', courseId) + this.fetching = false + return data + + }, + + async create(newCourse) { + const { status, data } = await axios.post('/course', newCourse) + + return data + + }, + async delete(id) { + const { status, data } = await axios.delete(`/course/${id}`, id) + + return data + + }, + + async edit(id) { + const { status, data } = await axios.get(`/course/${id}`) + return data + + }, + + + + // async store(form) { + // const result = await axios.post('/admin/products/add', form) + + // if (result.status === 201) + // this.items.unshift(result.data) + + // return result; + // }, + // async update(id, form) { + // const result = await axios.put(`/admin/products/${id}`, form) + + // if (result.status === 200) { + // const index = this.items.findIndex(({ _id }) => _id == id) + // this.items[index] = result.data + // } + + // return result; + // }, + // async confirm(id, form) { + // const result = await axios.post(`/admin/products/confirm/${id}`, form) + + // if (result.status === 200) { + // const index = this.items.findIndex(({ _id }) => _id == id) + // this.items[index] = result.data + // } + + // return result; + // }, + // async remove(id) { + // const result = await axios.delete(`/admin/products/${id}`) + + // if (result.status === 200) { + // const index = this.items.findIndex(({ _id }) => _id == id) + // this.items.splice(index, 1) + // } + + // return result; + // }, + + } +}) \ No newline at end of file diff --git a/src/stores/courseComments.js b/src/stores/courseComments.js new file mode 100644 index 0000000..cf39547 --- /dev/null +++ b/src/stores/courseComments.js @@ -0,0 +1,178 @@ + +import axios from '../plugins/axios' +import { defineStore } from 'pinia' + +export const useCommentStore = defineStore('comments', { + state: () => ({ + items: [], + fetching: true, + total: 0 + }), + getters: { + // treeSelect: (state) => (id = null) => { + // if (id) { + // const foreach = (items) => { + // return items.filter((item) => { + // if (item.key != id) { + // if (item.children) + // item.children = foreach(item.children) + // return true + // } else return false + // }) + // } + // return foreach(state.items) + // } + // return state.items + // }, + find: (state) => (id) => { + if (id) { + const foreach = (items) => { + const item = items.find(({ key }) => key == id) + if (item) return item + + for (let i = 0; i < items.length; i++) { + const item = items[i]; + + if (item.children) { + const temp = foreach(item.children) + if (temp) return temp + } + } + } + + return foreach(state.items) + } + return ''; + } + }, + actions: { + async reply(id, body) { + this.fetching = true + const data = await axios.post(`/course/${id}/comment`, body) + this.fetching = false + console.log(id, 'id'); + return data + + + if (status === 200) { + const map = (items, parent = null) => { + return items.map((item) => { + const temp = { + key: item._id, + label: item.name, + data: item + } + if (parent) + temp.data.parentCategoryID = { [parent]: true } + if (item.sub) { + temp.children = map(item.sub, temp.key) + delete temp.data.sub + } + return temp; + }); + } + + this.items = map(data) + + // this.items = data.items + // this.total = data.total + } + }, + async ticket(id) { + this.fetching = true + const { status, data } = await axios.get(`/ticket/${id}`) + this.fetching = false + return data + if (status === 200) { + const map = (items, parent = null) => { + return items.map((item) => { + const temp = { + key: item._id, + label: item.name, + data: item + } + if (parent) + temp.data.parentCategoryID = { [parent]: true } + if (item.sub) { + temp.children = map(item.sub, temp.key) + delete temp.data.sub + } + return temp; + }); + } + + this.items = map(data) + + // this.items = data.items + // this.total = data.total + } + }, + async close(id){ + this.fetching = true + const { status, data } = await axios.patch(`/ticket/close/${id}`, id) + this.fetching = false + return data + if (status === 200) { + const map = (items, parent = null) => { + return items.map((item) => { + const temp = { + key: item._id, + label: item.name, + data: item + } + if (parent) + temp.data.parentCategoryID = { [parent]: true } + if (item.sub) { + temp.children = map(item.sub, temp.key) + delete temp.data.sub + } + return temp; + }); + } + + this.items = map(data) + + // this.items = data.items + // this.total = data.total + } + }, + + async create(id) { + const result = await axios.post('/courseCategory', { + name: id.value + }) + + //console.log('result', result); + return result; + }, + + async store(form) { + const result = await axios.post('/admin/categories', form) + + if (result.status === 201) + this.items.unshift(result.data) + + return result; + }, + async update(id, form) { + const result = await axios.put(`/admin/categories/${id}`, form) + + if (result.status === 200) { + const index = this.items.findIndex(({ _id }) => _id == id) + this.items[index] = result.data + } + + return result; + }, + async remove(id) { + const result = await axios.delete(`/courseCategory/${id}`) + + if (result.status === 200) { + const index = this.items.findIndex(({ _id }) => _id == id) + this.items.splice(index, 1) + } + + return result; + }, + } +}) \ No newline at end of file diff --git a/src/stores/statics.js b/src/stores/statics.js index 1d9e6c2..83c875b 100644 --- a/src/stores/statics.js +++ b/src/stores/statics.js @@ -57,17 +57,6 @@ export const useStaticsStore = defineStore('statics', { }, async edit(data) { this.fetching = true - // const json = { - // "about": "", - // "student": 100, - // "hours": 0, - // "title": 0, - // "expertise": 0, - // "nameCompany": "string", - // "mission": "string", - // "start": "string", - // "goals": "string" - // } const result = await axios.patch('/admin/settings/edit', data) this.fetching = false return result diff --git a/src/views/About.vue b/src/views/About.vue index 76f2faf..dbb5d0d 100644 --- a/src/views/About.vue +++ b/src/views/About.vue @@ -24,7 +24,7 @@
- +
@@ -57,24 +57,13 @@ import { useStaticsStore } from "@/stores/statics"; import { useRoute } from "vue-router"; const data = reactive({ - about: "string", - student: 0, - hours: 0, - title: 0, expertise: 0, - nameCompany: "string", - mission: "string", - start: "string", - goals: "string", - // description: "", - // videosCount: null, - // rates: null, + student: 0, + title: 0, + hours: 0, }); const save = async (data) => { - console.log('form', data); - console.log('json', JSON.stringify(data)); - const { result } = await store.edit(data); - console.log("res", result); + const result = await store.edit(data); }; const expandedKeys = ref({}); @@ -88,9 +77,10 @@ watchEffect(async () => { await store.index(); - // console.log(store.items); - data.student = store.items.student; - //data.videosCount = store.items.hours; + data.expertise = store.items.expertise; + data.student = store.items.student; + data.title = store.items.title; + data.hours = store.items.hours; }); \ No newline at end of file diff --git a/src/views/AddVideos.vue b/src/views/AddVideos.vue new file mode 100644 index 0000000..9fd6c18 --- /dev/null +++ b/src/views/AddVideos.vue @@ -0,0 +1,24 @@ + + + + \ No newline at end of file diff --git a/src/views/Admins.vue b/src/views/Admins.vue index 0fae710..44e3202 100644 --- a/src/views/Admins.vue +++ b/src/views/Admins.vue @@ -1,31 +1,69 @@ \ No newline at end of file diff --git a/src/views/AnswerComment.vue b/src/views/AnswerComment.vue new file mode 100644 index 0000000..b6d3e42 --- /dev/null +++ b/src/views/AnswerComment.vue @@ -0,0 +1,125 @@ +