diff --git a/components.d.ts b/components.d.ts index ff341c9..967a0d5 100644 --- a/components.d.ts +++ b/components.d.ts @@ -16,6 +16,7 @@ declare module 'vue' { DataTable: typeof import('primevue/datatable')['default'] Dropdown: typeof import('primevue/dropdown')['default'] Editor: typeof import('primevue/editor')['default'] + Fieldset: typeof import('primevue/fieldset')['default'] FirstStep: typeof import('./src/components/ProductFormSteps/FirstStep.vue')['default'] FloatLabel: typeof import('primevue/floatlabel')['default'] Galleria: typeof import('primevue/galleria')['default'] diff --git a/src/layouts/Main.vue b/src/layouts/Main.vue index b8b69ec..a88a557 100644 --- a/src/layouts/Main.vue +++ b/src/layouts/Main.vue @@ -79,7 +79,7 @@ const items = ref([ }, { label: t('سوالات متداول'), - icon: 'pi pi-exclamation-circle', + icon: 'pi pi-question-circle', command: () => router.push('/pages/Faq') }, // { diff --git a/src/router/index.js b/src/router/index.js index 60a83a2..02d4f3d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -83,6 +83,11 @@ const router = createRouter({ name: 'EditCoupon', component: () => import('@/views/EditCoupon.vue'), }, + { + path: '/tickets/:id', + name: 'ShowTickets', + component: () => import('@/views/ShowTickets.vue'), + }, { path: '/tickets', name: 'Tickets', diff --git a/src/stores/categoreis.js b/src/stores/categoreis.js index a9f4ef1..2c7fe16 100644 --- a/src/stores/categoreis.js +++ b/src/stores/categoreis.js @@ -48,13 +48,10 @@ export const useCategoriesStore = defineStore('categories', { actions: { async index(page, rows) { this.fetching = true - const params = { page, rows } - const { status, data } = await axios.get('/courseCategory', { params }) - this.fetching = false - + return data if (status === 200) { const map = (items, parent = null) => { return items.map((item) => { @@ -84,7 +81,7 @@ export const useCategoriesStore = defineStore('categories', { name: id.value }) -//console.log('result', result); + //console.log('result', result); return result; }, diff --git a/src/stores/tickets.js b/src/stores/tickets.js new file mode 100644 index 0000000..0345898 --- /dev/null +++ b/src/stores/tickets.js @@ -0,0 +1,207 @@ + +import axios from '../plugins/axios' +import { defineStore } from 'pinia' + +export const useTicketsStore = defineStore('tickets', { + 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 index(page, rows) { + this.fetching = true + + const params = { page, rows } + + const { status, data } = await axios.get('/ticket', { params }) + + 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 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 reply(form){ + this.fetching = true + const { status, data } = await axios.post('/ticket/message', form) + 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/views/Create.vue b/src/views/Create.vue index e4496a1..fba45b1 100644 --- a/src/views/Create.vue +++ b/src/views/Create.vue @@ -25,10 +25,8 @@
@@ -41,12 +39,12 @@
-
+
@@ -71,6 +69,25 @@
+ +
+ + + + + + + +
@@ -84,27 +101,8 @@
-
-
- - - - - - - -
- -
+
+
\ No newline at end of file diff --git a/src/views/ShowTickets.vue b/src/views/ShowTickets.vue new file mode 100644 index 0000000..4130c1b --- /dev/null +++ b/src/views/ShowTickets.vue @@ -0,0 +1,68 @@ + + + + diff --git a/src/views/Tickets.vue b/src/views/Tickets.vue index 482daa9..191ef48 100644 --- a/src/views/Tickets.vue +++ b/src/views/Tickets.vue @@ -1,3 +1,63 @@ \ No newline at end of file + + + + + + + + + + + + + + + + + + + \ No newline at end of file