refactor: use Salix for the pending orders
gitea/hedera-web/pipeline/pr-beta This commit looks good Details

This commit is contained in:
taro 2025-02-06 13:50:49 -03:00
parent 30dca813b6
commit 0f0717f382
3 changed files with 67 additions and 48 deletions

View File

@ -1,2 +1,5 @@
debian debian
node_modules node_modules
.quasar
build
.vscode

View File

@ -8,7 +8,6 @@
// Configuration for your app // Configuration for your app
// https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js // https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js
const ESLintPlugin = require('eslint-webpack-plugin');
const path = require('path'); const path = require('path');
const { configure } = require('quasar/wrappers'); const { configure } = require('quasar/wrappers');
@ -68,11 +67,7 @@ module.exports = configure(function (ctx) {
// "chain" is a webpack-chain object https://github.com/neutrinojs/webpack-chain // "chain" is a webpack-chain object https://github.com/neutrinojs/webpack-chain
chainWebpack(chain) { chainWebpack(chain) {
chain chain.resolve.alias.set('@', path.resolve(__dirname, 'src'));
.plugin('eslint-webpack-plugin')
.use(ESLintPlugin, [{ extensions: ['js', 'vue'] }]);
chain.resolve.alias
.set('@', path.resolve(__dirname, 'src'));
chain.module chain.module
.rule('i18n-resource') .rule('i18n-resource')
.test(/\.(json5?|ya?ml)$/) .test(/\.(json5?|ya?ml)$/)
@ -96,7 +91,7 @@ module.exports = configure(function (ctx) {
type: 'http' type: 'http'
}, },
port: 8080, port: 8080,
open: false, open: true,
// static: __dirname, // static: __dirname,
headers: { 'Access-Control-Allow-Origin': '*' }, headers: { 'Access-Control-Allow-Origin': '*' },
// stats: { chunks: false }, // stats: { chunks: false },
@ -144,12 +139,6 @@ module.exports = configure(function (ctx) {
maxAge: 1000 * 60 * 60 * 24 * 30, maxAge: 1000 * 60 * 60 * 24 * 30,
// Tell browser when a file from the server should expire from cache (in ms) // Tell browser when a file from the server should expire from cache (in ms)
chainWebpackWebserver(chain) {
chain
.plugin('eslint-webpack-plugin')
.use(ESLintPlugin, [{ extensions: ['js'] }]);
},
middlewares: [ middlewares: [
ctx.prod ? 'compression' : '', ctx.prod ? 'compression' : '',
'render' // keep this as last one 'render' // keep this as last one
@ -164,11 +153,7 @@ module.exports = configure(function (ctx) {
// for the custom service worker ONLY (/src-pwa/custom-service-worker.[js|ts]) // for the custom service worker ONLY (/src-pwa/custom-service-worker.[js|ts])
// if using workbox in InjectManifest mode // if using workbox in InjectManifest mode
chainWebpackCustomSW(chain) { chainWebpackCustomSW(chain) {},
chain
.plugin('eslint-webpack-plugin')
.use(ESLintPlugin, [{ extensions: ['js'] }]);
},
manifest: { manifest: {
name: 'Hedera', name: 'Hedera',
@ -237,21 +222,9 @@ module.exports = configure(function (ctx) {
// https://www.electron.build/configuration/configuration // https://www.electron.build/configuration/configuration
appId: 'hedera-web' appId: 'hedera-web'
}, }
// "chain" is a webpack-chain object https://github.com/neutrinojs/webpack-chain // "chain" is a webpack-chain object https://github.com/neutrinojs/webpack-chain
chainWebpackMain(chain) {
chain
.plugin('eslint-webpack-plugin')
.use(ESLintPlugin, [{ extensions: ['js'] }]);
},
chainWebpackPreload(chain) {
chain
.plugin('eslint-webpack-plugin')
.use(ESLintPlugin, [{ extensions: ['js'] }]);
}
} }
}; };
}); });

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, inject, onMounted } from 'vue'; import { ref, inject, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
@ -10,13 +10,16 @@ import { currency, formatDateTitle } from 'src/lib/filters.js';
import { useVnConfirm } from 'src/composables/useVnConfirm.js'; import { useVnConfirm } from 'src/composables/useVnConfirm.js';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { useAppStore } from 'stores/app'; import { useAppStore } from 'stores/app';
import { useUserStore } from 'stores/user';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
const jApi = inject('jApi'); const jApi = inject('jApi');
const api = inject('api');
const { t } = useI18n(); const { t } = useI18n();
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const { notify } = useNotify(); const { notify } = useNotify();
const appStore = useAppStore(); const appStore = useAppStore();
const userStore = useUserStore();
const { isHeaderMounted } = storeToRefs(appStore); const { isHeaderMounted } = storeToRefs(appStore);
const router = useRouter(); const router = useRouter();
@ -26,15 +29,48 @@ const orders = ref([]);
const getOrders = async () => { const getOrders = async () => {
try { try {
loading.value = true; loading.value = true;
orders.value = await jApi.query(
`SELECT o.id, o.sent, o.deliveryMethodFk, o.taxableBase, const clientFk = userStore?.user?.id;
a.nickname, am.description agency
FROM myOrder o const filter = {
JOIN myAddress a ON a.id = o.addressFk where: {
JOIN vn.agencyMode am ON am.id = o.agencyModeFk clientFk,
WHERE NOT o.isConfirmed 'address.clientFk': clientFk,
ORDER BY o.sent DESC` isConfirmed: 0,
); source_app: 'WEB',
},
include: [
{
relation: 'address',
scope: {
fields: ['nickname', 'city'],
}
},
{
relation: 'agencyMode',
scope: {
fields: ['description'],
}
},
],
fields: [
'id',
'landed',
'delivery_method_id',
'taxableBase',
'addressFk',
'agencyModeFk'
]
};
const { data: salixOrders } = await api.get('Orders', {
params: {
filter: JSON.stringify(filter)
}
});
orders.value = salixOrders;
loading.value = false; loading.value = false;
} catch (error) { } catch (error) {
console.error('Error getting orders:', error); console.error('Error getting orders:', error);
@ -63,9 +99,16 @@ const loadOrder = orderId => {
router.push({ name: 'catalog' }); router.push({ name: 'catalog' });
}; };
onMounted(async () => { watch(
getOrders(); () => userStore?.user?.id,
}); async userId => {
if (userId) {
getOrders();
}
},
{ immediate: true }
);
</script> </script>
<template> <template>
@ -93,11 +136,11 @@ onMounted(async () => {
> >
<template #content> <template #content>
<QItemLabel class="text-bold q-mb-sm"> <QItemLabel class="text-bold q-mb-sm">
{{ formatDateTitle(order.sent) }} {{ formatDateTitle(order.landed) }}
</QItemLabel> </QItemLabel>
<QItemLabel> #{{ order.id }} </QItemLabel> <QItemLabel> #{{ order.id }} </QItemLabel>
<QItemLabel>{{ order.nickname }}</QItemLabel> <QItemLabel>{{ order.address.nickname }}</QItemLabel>
<QItemLabel>{{ order.agency }}</QItemLabel> <QItemLabel>{{ order.agencyMode.description }}</QItemLabel>
<QItemLabel>{{ currency(order.taxableBase) }}</QItemLabel> <QItemLabel>{{ currency(order.taxableBase) }}</QItemLabel>
</template> </template>
<template #actions> <template #actions>