diff --git a/src/stores/app.js b/src/stores/app.js index 1f99a7e4..4117b8b5 100644 --- a/src/stores/app.js +++ b/src/stores/app.js @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import { jApi, api } from '@/boot/axios'; +import { api } from '@/boot/axios'; import useNotify from '@/composables/useNotify.js'; import { i18n } from '@/boot/i18n'; import { useQuasar } from 'quasar'; @@ -8,6 +8,29 @@ const { notify } = useNotify(); const storageOrderName = 'hederaBasket'; const { t } = i18n.global; +const userHasOrders = async () => { + try { + const filter = { + where: { + isConfirmed: false, + source_app: 'WEB' + }, + fields: ['id'], + limit: 1, + }; + + const { data: salixOrders } = await api.get('Orders', { + params: { + filter: JSON.stringify(filter) + } + }); + + return !!salixOrders?.length; + } catch (error) { + console.error('Error getting orders:', error); + } +}; + export const useAppStore = defineStore('hedera', { state: () => ({ customTitle: null, @@ -130,10 +153,8 @@ export const useAppStore = defineStore('hedera', { }, async redirect() { - const resultSet = await jApi.execQuery( - 'SELECT COUNT(*) > 0 FROM myOrder' - ); - if (resultSet.fetchValue()) { + const hasOrders = await userHasOrders(); + if (hasOrders) { this.router.push({ name: 'pendingOrders' }); notify('loadAnOrder', 'warning'); } else {