refactor: use Salix in app.js for `hasOrders`
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
This commit is contained in:
parent
0dd10adc03
commit
45e35e4a6f
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue