diff --git a/src/pages/Admin/PhotosView.vue b/src/pages/Admin/PhotosView.vue
index b1e32f94..257adef7 100644
--- a/src/pages/Admin/PhotosView.vue
+++ b/src/pages/Admin/PhotosView.vue
@@ -3,11 +3,10 @@ import { useI18n } from 'vue-i18n';
import { ref, onMounted, inject, reactive, computed } from 'vue';
import VnSelect from 'src/components/common/VnSelect.vue';
-import VnForm from 'src/components/common/VnForm.vue';
import VnInput from 'src/components/common/VnInput.vue';
import useNotify from 'src/composables/useNotify.js';
+import FormModel from 'src/components/common/FormModel.vue';
-const jApi = inject('jApi');
const api = inject('api');
const { t } = useI18n();
const { notify } = useNotify();
@@ -33,7 +32,7 @@ const statusIcons = {
}
};
const formInitialData = reactive({
- schema: 'catalog',
+ collectionFk: 'catalog',
updateMatching: true
});
const imageCollections = ref([]);
@@ -45,9 +44,8 @@ const isSubmitable = computed(() =>
const getImageCollections = async () => {
try {
- imageCollections.value = await jApi.query(
- 'SELECT name, `desc` FROM imageCollection ORDER BY `desc`'
- );
+ const { data } = await api.get('imageCollections');
+ imageCollections.value = data;
} catch (error) {
console.error('Error getting image collections:', error);
}
@@ -61,38 +59,36 @@ const onSubmit = async data => {
const filteredFiles = addedFiles.value.filter(
file => file.uploadStatus === 'pending'
);
- const promises = filteredFiles.map((file, index) => {
+ const promises = filteredFiles.map(async (file, index) => {
const fileIndex = filteredFiles[index].index;
addedFiles.value[fileIndex].uploadStatus = 'uploading';
-
const formData = new FormData();
- formData.append('updateMatching', data.updateMatching);
- formData.append('image', file.file);
- formData.append('name', file.name);
- formData.append('schema', data.schema);
- formData.append('srv', 'json:image/upload');
- return api({
- method: 'post',
- url: location.origin,
- data: formData,
+ const now = new Date();
+ const timestamp = now.getTime();
+ const fileName = `${file.name}_${timestamp}`;
+ formData.append('image', file.file, fileName);
+
+ await api.post('images/uploadPhotoAdmin', formData, {
+ params: {
+ name: fileName,
+ collection: data.collectionFk,
+ updateMatching: data.updateMatching
+ },
headers: {
'Content-Type': 'multipart/form-data'
}
});
});
-
const results = await Promise.allSettled(promises);
results.forEach((result, index) => {
const fileIndex = filteredFiles[index].index;
addedFiles.value[fileIndex].uploadStatus = result.status;
-
if (result.status === 'rejected') {
addedFiles.value[fileIndex].errorMessage = t(
result.reason?.response?.data?.data?.message
);
}
});
-
const allSuccessful = results.every(
result => result.status === 'fulfilled'
);
@@ -139,16 +135,17 @@ onMounted(async () => getImageCollections());
-
getImageCollections());
data-cy="photoUploadSubmitBtn"
/>
-
+
diff --git a/src/pages/Ecomerce/InvoicesView.vue b/src/pages/Ecomerce/InvoicesView.vue
index 76599998..b89e28fa 100644
--- a/src/pages/Ecomerce/InvoicesView.vue
+++ b/src/pages/Ecomerce/InvoicesView.vue
@@ -8,9 +8,10 @@ import { currency, formatDate } from 'src/lib/filters.js';
import { usePrintService } from 'src/composables/usePrintService';
import { useAppStore } from 'stores/app';
import { storeToRefs } from 'pinia';
+import { onUserId } from 'src/utils/onUserId';
const { t } = useI18n();
-const jApi = inject('jApi');
+const api = inject('api');
const { openReport } = usePrintService();
const appStore = useAppStore();
const { isHeaderMounted } = storeToRefs(appStore);
@@ -50,27 +51,38 @@ const columns = computed(() => [
}
]);
-const fetchInvoices = async () => {
- const params = {
+const fetchInvoices = async clientFk => {
+ const { from, to } = {
from: new Date(currentYear.value, 0),
to: new Date(currentYear.value, 11, 31, 23, 59, 59)
};
- invoices.value = await jApi.query(
- `SELECT id, ref, issued, amount, hasPdf
- FROM myInvoice
- WHERE issued BETWEEN #from AND #to
- ORDER BY issued DESC
- LIMIT 100`,
- params
- );
+ const filter = {
+ where: {
+ clientFk,
+ issued: {
+ between: [from, to]
+ }
+ },
+ order: ['issued DESC'],
+ fields: ['id', 'ref', 'issued', 'amount', 'hasPdf'],
+ limit: 100
+ };
+
+ const { data } = await api.get('InvoiceOuts', {
+ params: {
+ filter: JSON.stringify(filter)
+ }
+ });
+ invoices.value = data;
};
onMounted(async () => {
- await fetchInvoices();
for (let year = currentYear.value - 5; year <= currentYear.value; year++) {
years.value.push(year);
}
});
+
+onUserId(fetchInvoices);