+
{{ tag.tag.name }}
{{ tag.value }}
-
+
{{ $t('cancel') }}
-
+
{{ $t('accept') }}
@@ -391,6 +346,7 @@
import { date, currency, formatDate } from 'src/lib/filters.js';
import axios from 'axios';
import { useAppStore } from 'stores/app';
+import { storeToRefs } from 'pinia';
const CancelToken = axios.CancelToken;
@@ -398,7 +354,8 @@ export default {
name: 'HederaCatalog',
setup() {
const appStore = useAppStore();
- return { appStore };
+ const { isHeaderMounted } = storeToRefs(appStore);
+ return { isHeaderMounted };
},
data() {
return {
diff --git a/src/pages/Ecomerce/InvoicesView.vue b/src/pages/Ecomerce/InvoicesView.vue
index 5c49eb63..e9032603 100644
--- a/src/pages/Ecomerce/InvoicesView.vue
+++ b/src/pages/Ecomerce/InvoicesView.vue
@@ -6,11 +6,14 @@ import VnTable from 'src/components/ui/VnTable.vue';
import { currency, formatDate } from 'src/lib/filters.js';
import { usePrintService } from 'src/composables/usePrintService';
-// import { date as qdate } from 'quasar';
+import { useAppStore } from 'stores/app';
+import { storeToRefs } from 'pinia';
const { t } = useI18n();
const jApi = inject('jApi');
const { openReport } = usePrintService();
+const appStore = useAppStore();
+const { isHeaderMounted } = storeToRefs(appStore);
const currentYear = ref(Date.vnNew().getFullYear());
const years = ref([]);
@@ -36,6 +39,7 @@ const columns = computed(() => [
name: 'amount',
label: t('amount'),
field: 'amount',
+ align: 'right',
sortable: true,
format: val => currency(val)
},
@@ -59,6 +63,7 @@ const fetchInvoices = async () => {
LIMIT 100`,
params
);
+ console.log(invoices.value);
};
onMounted(async () => {
@@ -70,7 +75,7 @@ onMounted(async () => {
-
+
{
{
};
const onConfirmPay = async () => {
- if (amountToPay.value <= 0) {
+ if (!amountToPay.value || amountToPay.value <= 0) {
notify(t('amountError'), 'negative');
return;
}
- if (amountToPay.value) {
- const amount = amountToPay.value.toString().replace('.', ',');
- amountToPay.value = parseFloat(amount);
- await tpv.pay(amountToPay.value);
- }
+
+ const amount = amountToPay.value.toString().replace('.', ',');
+ amountToPay.value = parseFloat(amount);
+ await tpv.pay(amountToPay.value);
};
-
+
{{ t('balance') }}
-
+
{{ currency(debt || 0) }}
-
+
{{ t('paymentInfo') }}
diff --git a/src/pages/Ecomerce/PendingOrders.vue b/src/pages/Ecomerce/PendingOrders.vue
index b332df81..dbf7acca 100644
--- a/src/pages/Ecomerce/PendingOrders.vue
+++ b/src/pages/Ecomerce/PendingOrders.vue
@@ -7,13 +7,15 @@ import CardList from 'src/components/ui/CardList.vue';
import { currency, formatDateTitle } from 'src/lib/filters.js';
import { useVnConfirm } from 'src/composables/useVnConfirm.js';
import useNotify from 'src/composables/useNotify.js';
-import { useAppStore } from 'src/stores/app.js';
+import { useAppStore } from 'stores/app';
+import { storeToRefs } from 'pinia';
const jApi = inject('jApi');
const { t } = useI18n();
const { openConfirmationModal } = useVnConfirm();
const { notify } = useNotify();
-const store = useAppStore();
+const appStore = useAppStore();
+const { isHeaderMounted } = storeToRefs(appStore);
const router = useRouter();
const orders = ref([]);
@@ -52,7 +54,7 @@ const removeOrder = async (id, index) => {
};
const loadOrder = orderId => {
- store.loadIntoBasket(orderId);
+ appStore.loadIntoBasket(orderId);
router.push({ name: 'catalog' });
};
@@ -62,7 +64,7 @@ onMounted(async () => {
-
+
{
-
+
import { useI18n } from 'vue-i18n';
-import { userStore } from 'stores/user';
+import { useUserStore } from 'stores/user';
import { onMounted, ref } from 'vue';
import useNotify from 'src/composables/useNotify.js';
import { useRouter, useRoute } from 'vue-router';
const { notify } = useNotify();
const t = useI18n();
-const user = userStore();
+const userStore = useUserStore();
const route = useRoute();
const router = useRouter();
const email = ref(null);
@@ -29,7 +29,7 @@ onMounted(() => {
}
});
async function onLogin() {
- await user.login(email.value, password.value, remember.value);
+ await userStore.login(email.value, password.value, remember.value);
router.push('/');
}
@@ -37,27 +37,13 @@ async function onLogin() {
-
+
-
+
-
-
+
+
{{ $t(`langs.${lang}`) }}
@@ -127,10 +105,7 @@ async function onLogin() {
/>
-
+
{{ $t('haveForgottenPassword') }}
diff --git a/src/router/routes.js b/src/router/routes.js
index d8a523ac..21c2434c 100644
--- a/src/router/routes.js
+++ b/src/router/routes.js
@@ -88,6 +88,46 @@ const routes = [
name: 'addressDetails',
path: '/account/address/:id?',
component: () => import('pages/Account/AddressDetails.vue')
+ },
+ {
+ name: 'controlPanel',
+ path: 'admin/links',
+ component: () => import('pages/Admin/LinksView.vue')
+ },
+ {
+ name: 'adminUsers',
+ path: 'admin/users',
+ component: () => import('pages/Admin/UsersView.vue')
+ },
+ {
+ name: 'adminConnections',
+ path: 'admin/connections',
+ component: () => import('pages/Admin/ConnectionsView.vue')
+ },
+ {
+ name: 'adminVisits',
+ path: 'admin/visits',
+ component: () => import('pages/Admin/VisitsView.vue')
+ },
+ {
+ name: 'adminNews',
+ path: 'news/news',
+ component: () => import('pages/Admin/NewsView.vue')
+ },
+ {
+ name: 'adminNewsDetails',
+ path: 'news/new/:id?',
+ component: () => import('pages/Admin/NewsDetails.vue')
+ },
+ {
+ name: 'adminPhotos',
+ path: 'admin/photos',
+ component: () => import('pages/Admin/PhotosView.vue')
+ },
+ {
+ name: 'adminItems',
+ path: 'admin/items',
+ component: () => import('pages/Admin/ItemsView.vue')
}
]
},
diff --git a/src/stores/app.js b/src/stores/app.js
index 60af8c8e..8e6259ea 100644
--- a/src/stores/app.js
+++ b/src/stores/app.js
@@ -11,11 +11,43 @@ export const useAppStore = defineStore('hedera', {
imageUrl: '',
useRightDrawer: false,
rightDrawerOpen: false,
- basketOrderId: null,
- isHeaderMounted: false
+ isHeaderMounted: false,
+ menuEssentialLinks: [],
+ basketOrderId: null
}),
actions: {
+ async getMenuLinks() {
+ const sections = await jApi.query('SELECT * FROM myMenu');
+ const sectionMap = new Map();
+ for (const section of sections) {
+ sectionMap.set(section.id, section);
+ }
+
+ const sectionTree = [];
+ for (const section of sections) {
+ const parent = section.parentFk;
+ if (parent) {
+ const parentSection = sectionMap.get(parent);
+ if (!parentSection) continue;
+ let childs = parentSection.childs;
+ if (!childs) {
+ childs = parentSection.childs = [];
+ }
+ childs.push(section);
+ } else {
+ sectionTree.push(section);
+ }
+ }
+
+ this.menuEssentialLinks = sectionTree;
+ },
+
+ async loadConfig() {
+ const imageUrl = await jApi.getValue('SELECT url FROM imageConfig');
+ this.$patch({ imageUrl });
+ },
+
async init() {
this.getBasketOrderId();
},
@@ -24,11 +56,6 @@ export const useAppStore = defineStore('hedera', {
this.basketOrderId = localStorage.getItem('hederaBasket');
},
- async loadConfig() {
- const imageUrl = await jApi.getValue('SELECT url FROM imageConfig');
- this.$patch({ imageUrl });
- },
-
async checkOrder(orderId) {
try {
const resultSet = await jApi.execQuery(
diff --git a/src/stores/user.js b/src/stores/user.js
index e90123bf..c7df4d12 100644
--- a/src/stores/user.js
+++ b/src/stores/user.js
@@ -1,7 +1,7 @@
import { defineStore } from 'pinia';
import { api, jApi } from 'boot/axios';
-export const userStore = defineStore('user', {
+export const useUserStore = defineStore('user', {
state: () => {
const token =
sessionStorage.getItem('vnToken') ||
@@ -9,10 +9,9 @@ export const userStore = defineStore('user', {
return {
token,
- id: null,
- name: null,
- nickname: null,
- isGuest: false
+ isGuest: false,
+ user: null,
+ supplantedUser: null
};
},
@@ -21,6 +20,11 @@ export const userStore = defineStore('user', {
},
actions: {
+ async getToken() {
+ this.token =
+ sessionStorage.getItem('vnToken') ||
+ localStorage.getItem('vnToken');
+ },
async login(user, password, remember) {
const params = { user, password };
const res = await api.post('Accounts/login', params);
@@ -36,7 +40,6 @@ export const userStore = defineStore('user', {
name: user
});
},
-
async logout() {
if (this.token != null) {
try {
@@ -48,16 +51,38 @@ export const userStore = defineStore('user', {
this.$reset();
},
- async loadData() {
- const userData = await jApi.getObject(
- 'SELECT id, nickname, name FROM account.myUser'
- );
+ async fetchUser(userType = 'user') {
+ try {
+ const userData = await jApi.getObject(
+ 'SELECT id, nickname, name FROM account.myUser'
+ );
+ this.$patch({ [userType]: userData });
+ } catch (error) {
+ console.error('Error fetching user: ', error);
+ }
+ },
- this.$patch({
- id: userData.id,
- nickname: userData.nickname,
- name: userData.name
+ async supplantUser(supplantUser) {
+ const json = await jApi.send('client/supplant', {
+ supplantUser
});
+ this.token = json;
+ sessionStorage.setItem('supplantUser', supplantUser);
+ await this.fetchUser('supplantedUser');
+ },
+
+ async supplantInit() {
+ const user = sessionStorage.getItem('supplantUser');
+ if (user == null) return;
+ await this.supplantUser(user);
+ },
+
+ async logoutSupplantedUser() {
+ sessionStorage.removeItem('supplantUser');
+ this.supplantedUser = null;
+ await api.post('Accounts/logout');
+ this.getToken();
+ await this.fetchUser();
}
}
});