From 597f9c111ff49fdf4efecaaebdea1dedd2f01993 Mon Sep 17 00:00:00 2001 From: Jaroslav Drzik Date: Wed, 3 Jan 2024 18:41:37 +0100 Subject: [PATCH] Error on search empty product --- lang/id.json | 3 ++- resources/js/Pages/IkeaRoot.vue | 37 ++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/lang/id.json b/lang/id.json index 757bda4..490406e 100644 --- a/lang/id.json +++ b/lang/id.json @@ -107,5 +107,6 @@ "exchange": "Exchange", "referenceerror: rates is not defined": "ReferenceError: rates is not defined", "referenceerror: currency is not defined": "ReferenceError: currency is not defined", - "typeerror: can't access property \"unshift\", currency.velue is undefined": "TypeError: can't access property \"unshift\", currency.velue is undefined" + "typeerror: can't access property \"unshift\", currency.velue is undefined": "TypeError: can't access property \"unshift\", currency.velue is undefined", + "item must be selected": "Item must be selected" } \ No newline at end of file diff --git a/resources/js/Pages/IkeaRoot.vue b/resources/js/Pages/IkeaRoot.vue index 730b411..531bd6d 100644 --- a/resources/js/Pages/IkeaRoot.vue +++ b/resources/js/Pages/IkeaRoot.vue @@ -12,7 +12,7 @@ import { useForm } from '@inertiajs/inertia-vue3' import axios from 'axios'; import IkeaLogo from './Ikea/IkeaLogo.vue'; -const props = defineProps({ +const props = defineProps({ products: { type: Object, default: [] @@ -25,15 +25,15 @@ const props = defineProps({ type: Object, default: [] } - }) +}) - console.log(props.countryHash); +console.log(props.countryHash); let tproducts = computed(() => { - return props.products.map((prod) => { + return props.products.map((prod) => { prod.salesPrice = parseFloat(prod.salesPrice); prod.country = props.countryHash[prod.country]; return prod; - } ) + }) }) const type = 'GeoChart'; @@ -55,9 +55,9 @@ const hrates = ref([ ]); // { "country": "AT", "code": "50161321", "url": "https://www.ikea.com/at/de/p/hol-aufbewahrungstisch-akazie-50161321/", "name": "HOL", "typeName": "Aufbewahrungstisch", "mainImageUrl": "https://www.ikea.com/at/de/images/products/hol-aufbewahrungstisch-akazie__0104310_pe251255_s5.jpg", "itemNoGlobal": "50161321", "salesPrice": "80.99", "tag": "FAMILY_PRICE", "last_mod": "2023-12-03 16:44:24" }, const hproducts = ref([ - { text: "Country", value:"country", sortable: true}, - { text: "Name", value:"name", sortable: true}, - { text: "Price", value:"salesPrice", sortable: true} + { text: "Country", value: "country", sortable: true }, + { text: "Name", value: "name", sortable: true }, + { text: "Price", value: "salesPrice", sortable: true } ]); const rates = ref([]); @@ -174,12 +174,21 @@ onMounted(fetch); onMounted(fetch_rates); const submit = () => { - form.post(route('products.compare')); + console.log('ITEM=', form); + if (form.codes.length == 0) { + Swal.fire({ + title: "Empty code", + text: "You must enter product!", + icon: "error" + }); + return false; + } + form.post(route('products.compare')); };