From 29c42d7f34fda9131dfe6325085238761d29e96e Mon Sep 17 00:00:00 2001 From: taro Date: Tue, 18 Feb 2025 00:32:34 -0300 Subject: [PATCH 1/9] refactor: migrate `fetchUser` API call from PHP to Salix --- src/stores/user.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/stores/user.js b/src/stores/user.js index 90aaa688..a81b3c2c 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -248,11 +248,13 @@ export const useUserStore = defineStore('user', () => { const fetchUser = async (userType = 'user') => { try { - const userData = await jApi.getObject( - 'SELECT id, nickname, name, lang FROM account.myUser' - ); - if (userType === 'user') mainUser.value = userData; - else supplantedUser.value = userData; + const _token = getToken(); + const userData = await api.get('VnUsers/getCurrentUserData', { + headers: { Authorization: _token } + }); + + if (userType === 'user') mainUser.value = userData.data; + else supplantedUser.value = userData.data; } catch (error) { console.error('Error fetching user: ', error); } From bf449548c9116521407a37ab5a98c76bf3fe2ae9 Mon Sep 17 00:00:00 2001 From: taro Date: Wed, 19 Feb 2025 02:05:42 -0300 Subject: [PATCH 2/9] =?UTF-8?q?address=20comments=20=E2=80=94=20remove=20u?= =?UTF-8?q?nnecessary=20explicit=20passing=20of=20auth=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/user.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/stores/user.js b/src/stores/user.js index a81b3c2c..7f9d8a54 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -248,10 +248,7 @@ export const useUserStore = defineStore('user', () => { const fetchUser = async (userType = 'user') => { try { - const _token = getToken(); - const userData = await api.get('VnUsers/getCurrentUserData', { - headers: { Authorization: _token } - }); + const userData = await api.get('VnUsers/getCurrentUserData'); if (userType === 'user') mainUser.value = userData.data; else supplantedUser.value = userData.data; From 93c481aadf43084b994fae3a8f3e160e12ee76e5 Mon Sep 17 00:00:00 2001 From: taro Date: Wed, 19 Feb 2025 02:17:09 -0300 Subject: [PATCH 3/9] handle possible error case --- src/stores/user.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/stores/user.js b/src/stores/user.js index 7f9d8a54..992e6e06 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -250,6 +250,11 @@ export const useUserStore = defineStore('user', () => { try { const userData = await api.get('VnUsers/getCurrentUserData'); + if (!userData?.data) { + console.error('GET VnUsers/getCurrentUserData returned invalid data', userData); + return; + } + if (userType === 'user') mainUser.value = userData.data; else supplantedUser.value = userData.data; } catch (error) { From e444266db4c2dfef7af86ff4b80f48625fafad1c Mon Sep 17 00:00:00 2001 From: wbuezas Date: Wed, 19 Feb 2025 13:39:00 -0300 Subject: [PATCH 4/9] My menu query adaptation --- src/stores/app.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/stores/app.js b/src/stores/app.js index d950af10..71b3bb64 100644 --- a/src/stores/app.js +++ b/src/stores/app.js @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import { jApi } from '@/boot/axios'; +import { jApi, api } from '@/boot/axios'; import useNotify from '@/composables/useNotify.js'; import { i18n } from '@/boot/i18n'; import { useQuasar } from 'quasar'; @@ -32,7 +32,10 @@ export const useAppStore = defineStore('hedera', { }), actions: { async getMenuLinks() { - const sections = await jApi.query('SELECT * FROM myMenu'); + const { data: sections } = await api.get('MyMenus/getSections'); + + if (!sections) return; + const sectionMap = new Map(); for (const section of sections) { sectionMap.set(section.id, section); From 4ad4cb17e85cd19419d344f67abeb6118f1a1322 Mon Sep 17 00:00:00 2001 From: taro Date: Thu, 20 Feb 2025 04:57:23 -0300 Subject: [PATCH 5/9] refactor: remove unnecessary verification --- src/stores/user.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/stores/user.js b/src/stores/user.js index 992e6e06..7f9d8a54 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -250,11 +250,6 @@ export const useUserStore = defineStore('user', () => { try { const userData = await api.get('VnUsers/getCurrentUserData'); - if (!userData?.data) { - console.error('GET VnUsers/getCurrentUserData returned invalid data', userData); - return; - } - if (userType === 'user') mainUser.value = userData.data; else supplantedUser.value = userData.data; } catch (error) { From ce792f7bf69f02d2acbcd4cfcc0419006655d1d2 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Mon, 24 Feb 2025 17:52:15 -0300 Subject: [PATCH 6/9] Refactor front --- src/stores/app.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/stores/app.js b/src/stores/app.js index d950af10..d03f09eb 100644 --- a/src/stores/app.js +++ b/src/stores/app.js @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import { jApi } from '@/boot/axios'; +import { jApi, api } from '@/boot/axios'; import useNotify from '@/composables/useNotify.js'; import { i18n } from '@/boot/i18n'; import { useQuasar } from 'quasar'; @@ -56,9 +56,18 @@ export const useAppStore = defineStore('hedera', { this.menuEssentialLinks = sectionTree; }, + async loadConfig() { - const imageUrl = await jApi.getValue('SELECT url FROM imageConfig'); - this.$patch({ imageUrl }); + try { + const { data } = await api.get('/ImageConfigs/getImageConfig'); + + if (!data) return; + + const [config] = data; + this.imageUrl = config?.url; + } catch (err) { + console.error(err); + } }, async init() { From c2745a673cb73b697c1f28d1b65a4b2760f75259 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Wed, 26 Feb 2025 14:01:22 -0300 Subject: [PATCH 7/9] Change request url --- src/stores/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/app.js b/src/stores/app.js index d03f09eb..ddc787c5 100644 --- a/src/stores/app.js +++ b/src/stores/app.js @@ -59,7 +59,7 @@ export const useAppStore = defineStore('hedera', { async loadConfig() { try { - const { data } = await api.get('/ImageConfigs/getImageConfig'); + const { data } = await api.get('ImageConfigs'); if (!data) return; From f4dbf9509554a8aafc7452790ef4c1fc7e77ba42 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Wed, 26 Feb 2025 14:04:54 -0300 Subject: [PATCH 8/9] Change imageUrl asignment --- src/stores/app.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/stores/app.js b/src/stores/app.js index ddc787c5..45077306 100644 --- a/src/stores/app.js +++ b/src/stores/app.js @@ -63,8 +63,7 @@ export const useAppStore = defineStore('hedera', { if (!data) return; - const [config] = data; - this.imageUrl = config?.url; + this.imageUrl = data[0]?.url; } catch (err) { console.error(err); } From 1602218f07de0ece618e2aca807b96f841bf42d2 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Wed, 26 Feb 2025 14:34:45 -0300 Subject: [PATCH 9/9] Change query path --- src/stores/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/app.js b/src/stores/app.js index 71b3bb64..a7703e4b 100644 --- a/src/stores/app.js +++ b/src/stores/app.js @@ -32,7 +32,7 @@ export const useAppStore = defineStore('hedera', { }), actions: { async getMenuLinks() { - const { data: sections } = await api.get('MyMenus/getSections'); + const { data: sections } = await api.get('MyMenus'); if (!sections) return;