diff --git a/src/components/ConfirmedForm.vue b/src/components/ConfirmedForm.vue index b9b1d0c..6b8d2fc 100644 --- a/src/components/ConfirmedForm.vue +++ b/src/components/ConfirmedForm.vue @@ -4,6 +4,7 @@ import { useOrdersStore } from '@/stores/orders.store' import { storeToRefs } from 'pinia' import { useCategoriesStore } from '@/stores/categories.store' import { useContractorsStore } from '@/stores/contractors.store' +import { axiosInstance } from '@/main' const ordersStore = useOrdersStore(); const categoriesStore = useCategoriesStore(); @@ -17,6 +18,7 @@ const { contractor } = storeToRefs(contractorsStore); function cancelOrder(event: Event) { event.preventDefault(); + axiosInstance.delete('/zamowienie/' + uuid.value); } @@ -61,7 +63,7 @@ function cancelOrder(event: Event) { hide-input-icon/> - +
diff --git a/src/components/MainForm.vue b/src/components/MainForm.vue index d889408..164bd5e 100644 --- a/src/components/MainForm.vue +++ b/src/components/MainForm.vue @@ -6,6 +6,7 @@ import { useContractorsStore } from '@/stores/contractors.store' import { useOrdersStore } from '@/stores/orders.store' import { storeToRefs } from 'pinia' import { useSiteControlStore } from '@/stores/siteControl.store' +import { ref } from 'vue' const categoriesStore = useCategoriesStore(); const contractorsStore = useContractorsStore(); @@ -16,6 +17,7 @@ const { contractor, contractors } = storeToRefs(contractorsStore); const { deliveryDate, uuid } = storeToRefs(ordersStore); const { categories } = storeToRefs(categoriesStore); const { showConfirmationModal, isDarkTheme } = storeToRefs(siteControlStore); +const showErrorNotification = ref(false); function createJSON(event: Event) { event.preventDefault(); @@ -31,12 +33,16 @@ function createJSON(event: Event) { for (let category of categories.value) { for (let product of category.Towary) { - if(product.Quantity != null) { + if(product.Quantity != null && product.Quantity != '') { + if(isNaN(Number(product.Quantity)) || isNaN(Number(product.Twr_CenaZ)) || isNaN(Number(product.Twr_Cena))) { + showErrorNotification.value=true; + return; + } const productObject : OrderProduct = { MZE_TwrId: product.Twr_TwrId, MZE_TwrJm: product.ChosenOption, MZE_TwrCena: product.ChosenOption == product.Twr_JMZ ? product.Twr_CenaZ : product.Twr_Cena, - MZE_TwrIlosc: product.Quantity.toString(), + MZE_TwrIlosc: product.Quantity, MZE_TwrNazwa: product.Twr_Nazwa, MZE_MZNID: undefined, MZE_MZEID: undefined, @@ -46,6 +52,11 @@ function createJSON(event: Event) { } } } + if(json.MZamElem.length == 0) { + showErrorNotification.value=true; + return; + } + showErrorNotification.value=false; axiosInstance.post('/zamowienie', JSON.stringify(json)).then( response => { uuid.value = response.data.MZN_UUID; @@ -90,6 +101,10 @@ function setConfirmationModal(event : Event) {
+
+ + W formularzu znajdują się pola, które nie są liczbami, lub wszystkie pola są puste. +
@@ -105,7 +120,7 @@ function setConfirmationModal(event : Event) { type="text" placeholder="Kwota" v-model="product.Twr_Cena" - v-bind:class="{ 'is-success has-background-light': product.Quantity != undefined && product.Quantity as unknown as string != '' }" + v-bind:class="{ 'is-danger has-background-danger-90': product.Twr_Cena != undefined && isNaN(Number(product.Twr_Cena)),'is-success has-background-success-85': product.Quantity != undefined && product.Quantity as unknown as string != '' && !isNaN(Number(product.Quantity))}" />
@@ -116,21 +131,22 @@ function setConfirmationModal(event : Event) { type="text" placeholder="Kwota" v-model="product.Twr_CenaZ" - v-bind:class="{ 'is-success has-background-light': product.Quantity != undefined && product.Quantity as unknown as string != '' }" + v-bind:class="{ 'is-danger has-background-danger-90': product.Twr_CenaZ != undefined && isNaN(Number(product.Twr_CenaZ)), 'is-success has-background-success-90': product.Quantity != undefined && product.Quantity as unknown as string != '' && !isNaN(Number(product.Quantity)) + }" />

- -

- +

diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index c843d14..877f58a 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -7,6 +7,7 @@ import { useContractorsStore } from '@/stores/contractors.store' import { useCategoriesStore } from '@/stores/categories.store' import { storeToRefs } from 'pinia' import { useUserStore } from '@/stores/user.store' +import { axiosInstance } from '@/main' const activator = ref(false); @@ -39,6 +40,7 @@ function clickOrders() { } function routeLogin() { + axiosInstance.post('/logout'); router.push("/login"); } @@ -59,17 +61,17 @@ function newOrder() {