From e733011a1e31100f487d6d321f142121a2b32189 Mon Sep 17 00:00:00 2001
From: taro <taro@taro.codes>
Date: Thu, 6 Feb 2025 13:50:49 -0300
Subject: [PATCH] chore: add docker files for local development for backend and
 frontend

...

lol

refactor: userStore, JSON loopback filter, `fields`, etc

refactor: drop redundant .map, access nested fields directly instead

rm back/Dockerfile

rm Dockerfile-front

revert quasar.config.js
---
 .dockerignore                        |  5 +-
 quasar.config.js                     | 35 ++-----------
 src/pages/Ecomerce/PendingOrders.vue | 75 ++++++++++++++++++++++------
 3 files changed, 67 insertions(+), 48 deletions(-)

diff --git a/.dockerignore b/.dockerignore
index ebf83b0b..aee456a4 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,2 +1,5 @@
 debian
-node_modules
\ No newline at end of file
+node_modules
+.quasar
+build
+.vscode
diff --git a/quasar.config.js b/quasar.config.js
index e7bbb5e0..84e934d1 100644
--- a/quasar.config.js
+++ b/quasar.config.js
@@ -8,7 +8,6 @@
 // Configuration for your app
 // https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js
 
-const ESLintPlugin = require('eslint-webpack-plugin');
 const path = require('path');
 
 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
 
             chainWebpack(chain) {
-                chain
-                    .plugin('eslint-webpack-plugin')
-                    .use(ESLintPlugin, [{ extensions: ['js', 'vue'] }]);
-                chain.resolve.alias
-                    .set('@', path.resolve(__dirname, 'src'));
+                chain.resolve.alias.set('@', path.resolve(__dirname, 'src'));
                 chain.module
                     .rule('i18n-resource')
                     .test(/\.(json5?|ya?ml)$/)
@@ -96,7 +91,7 @@ module.exports = configure(function (ctx) {
                 type: 'http'
             },
             port: 8080,
-            open: false,
+            open: true,
             // static: __dirname,
             headers: { 'Access-Control-Allow-Origin': '*' },
             // stats: { chunks: false },
@@ -144,12 +139,6 @@ module.exports = configure(function (ctx) {
             maxAge: 1000 * 60 * 60 * 24 * 30,
             // 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: [
                 ctx.prod ? 'compression' : '',
                 '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])
             // if using workbox in InjectManifest mode
 
-            chainWebpackCustomSW(chain) {
-                chain
-                    .plugin('eslint-webpack-plugin')
-                    .use(ESLintPlugin, [{ extensions: ['js'] }]);
-            },
+            chainWebpackCustomSW(chain) {},
 
             manifest: {
                 name: 'Hedera',
@@ -237,21 +222,9 @@ module.exports = configure(function (ctx) {
                 // https://www.electron.build/configuration/configuration
 
                 appId: 'hedera-web'
-            },
+            }
 
             // "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'] }]);
-            }
         }
     };
 });
diff --git a/src/pages/Ecomerce/PendingOrders.vue b/src/pages/Ecomerce/PendingOrders.vue
index c9257cb2..ebca0b2d 100644
--- a/src/pages/Ecomerce/PendingOrders.vue
+++ b/src/pages/Ecomerce/PendingOrders.vue
@@ -1,5 +1,5 @@
 <script setup>
-import { ref, inject, onMounted } from 'vue';
+import { ref, inject, watch } from 'vue';
 import { useI18n } from 'vue-i18n';
 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 useNotify from 'src/composables/useNotify.js';
 import { useAppStore } from 'stores/app';
+import { useUserStore } from 'stores/user';
 import { storeToRefs } from 'pinia';
 
 const jApi = inject('jApi');
+const api = inject('api');
 const { t } = useI18n();
 const { openConfirmationModal } = useVnConfirm();
 const { notify } = useNotify();
 const appStore = useAppStore();
+const userStore = useUserStore();
 const { isHeaderMounted } = storeToRefs(appStore);
 const router = useRouter();
 
@@ -26,15 +29,48 @@ const orders = ref([]);
 const getOrders = async () => {
     try {
         loading.value = true;
-        orders.value = await jApi.query(
-            `SELECT o.id, o.sent, o.deliveryMethodFk, o.taxableBase,
-        a.nickname, am.description agency
-        FROM myOrder o
-        JOIN myAddress a ON a.id = o.addressFk
-        JOIN vn.agencyMode am ON am.id = o.agencyModeFk
-        WHERE NOT o.isConfirmed
-        ORDER BY o.sent DESC`
-        );
+
+        const clientFk = userStore?.user?.id;
+
+        const filter = {
+          where: {
+            clientFk,
+            'address.clientFk': clientFk,
+            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;
     } catch (error) {
         console.error('Error getting orders:', error);
@@ -63,9 +99,16 @@ const loadOrder = orderId => {
     router.push({ name: 'catalog' });
 };
 
-onMounted(async () => {
-    getOrders();
-});
+watch(
+  () => userStore?.user?.id,
+  async userId => {
+    if (userId) {
+      getOrders();
+    }
+  },
+  { immediate: true }
+);
+
 </script>
 
 <template>
@@ -93,11 +136,11 @@ onMounted(async () => {
             >
                 <template #content>
                     <QItemLabel class="text-bold q-mb-sm">
-                        {{ formatDateTitle(order.sent) }}
+                        {{ formatDateTitle(order.landed) }}
                     </QItemLabel>
                     <QItemLabel> #{{ order.id }} </QItemLabel>
-                    <QItemLabel>{{ order.nickname }}</QItemLabel>
-                    <QItemLabel>{{ order.agency }}</QItemLabel>
+                    <QItemLabel>{{ order.address.nickname }}</QItemLabel>
+                    <QItemLabel>{{ order.agencyMode.description }}</QItemLabel>
                     <QItemLabel>{{ currency(order.taxableBase) }}</QItemLabel>
                 </template>
                 <template #actions>