diff --git a/src/components/common/FetchData.vue b/src/components/common/FetchData.vue
new file mode 100644
index 00000000..26ec77a4
--- /dev/null
+++ b/src/components/common/FetchData.vue
@@ -0,0 +1,66 @@
+
+
+
+
diff --git a/src/pages/Account/AddressList.vue b/src/pages/Account/AddressList.vue
index 43fe2b0c..9939c926 100644
--- a/src/pages/Account/AddressList.vue
+++ b/src/pages/Account/AddressList.vue
@@ -5,6 +5,7 @@ import { useRouter } from 'vue-router';
import CardList from 'src/components/ui/CardList.vue';
import VnList from 'src/components/ui/VnList.vue';
+import FetchData from 'src/components/common/FetchData.vue';
import useNotify from 'src/composables/useNotify.js';
import { useVnConfirm } from 'src/composables/useVnConfirm.js';
@@ -21,6 +22,7 @@ const { openConfirmationModal } = useVnConfirm();
const appStore = useAppStore();
const userStore = useUserStore();
const { isHeaderMounted } = storeToRefs(appStore);
+const fetchAddressesRef = ref(null);
const addresses = ref([]);
const defaultAddress = ref(null);
@@ -41,19 +43,6 @@ const getDefaultAddress = async () => {
}
};
-const getActiveAddresses = async () => {
- try {
- addresses.value = await jApi.query(
- `SELECT a.id, a.nickname, p.name province, a.postalCode, a.city, a.street, a.isActive
- FROM myAddress a
- LEFT JOIN vn.province p ON p.id = a.provinceFk
- WHERE a.isActive`
- );
- } catch (error) {
- console.error('Error getting active addresses:', error);
- }
-};
-
const changeDefaultAddress = async () => {
if (!clientId.value) return;
await jApi.execQuery(
@@ -77,7 +66,7 @@ async function removeAddress(address) {
isActive: false
}
);
- getActiveAddresses();
+ fetchAddressesRef.value.fetch();
notify(t('dataSaved'), 'positive');
} catch (error) {
console.error('Error removing address:', error);
@@ -86,11 +75,28 @@ async function removeAddress(address) {
onMounted(async () => {
getDefaultAddress();
- getActiveAddresses();
});
+ (addresses = data)"
+ />
import { ref, onMounted, inject } from 'vue';
const jApi = inject('jApi');
+const api = inject('api');
const news = ref([]);
const showPreview = ref(false);
const selectedImageSrc = ref('');
const fetchData = async () => {
- news.value = await jApi.query(
- `SELECT title, text, image, id
- FROM news
- ORDER BY priority, created DESC`
- );
+ const newsResponse = await api.get('News');
+
+ news.value = newsResponse.data;
};
const showImagePreview = src => {
diff --git a/src/stores/app.js b/src/stores/app.js
index 45077306..d5183dc8 100644
--- a/src/stores/app.js
+++ b/src/stores/app.js
@@ -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');
+
+ if (!sections) return;
+
const sectionMap = new Map();
for (const section of sections) {
sectionMap.set(section.id, section);
diff --git a/src/stores/user.js b/src/stores/user.js
index 91278afa..97c8d6fe 100644
--- a/src/stores/user.js
+++ b/src/stores/user.js
@@ -248,11 +248,10 @@ 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 userData = await api.get('VnUsers/getCurrentUserData');
+
+ if (userType === 'user') mainUser.value = userData.data;
+ else supplantedUser.value = userData.data;
} catch (error) {
console.error('Error fetching user: ', error);
}