+
IKEA Price Crawler
@@ -45,13 +189,13 @@ onMounted(fetch_menu);
-
-
-
Home
+
+ {{ tsettings }}
+
{{ item.name }}
@@ -60,7 +204,43 @@ onMounted(fetch_menu);
- TEST
+
+
+
+
+
+
+
+
+
+
+ {{ slotProps.option.country }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ slotProps.option.name }}
+
+
+
+
+
+
+
+
+
diff --git a/resources/js/Pages/IkeaRoot.vue b/resources/js/Pages/IkeaRoot.vue
index 5c8f0fa..312bb3f 100644
--- a/resources/js/Pages/IkeaRoot.vue
+++ b/resources/js/Pages/IkeaRoot.vue
@@ -16,11 +16,10 @@ import { GChart } from "vue-google-charts";
import EasyTable from "vue3-easy-data-table";
import GuestLayout from "../Layouts/GuestLayout.vue";
-import { useForm } from "@inertiajs/inertia-vue3";
import axios from "axios";
import filterimg from "@/assets/eglass-filter.png";
import searchimg from "@/assets/search-icon.svg";
-import Popper from "vue3-popper";
+import { settingsStore } from '../settingsStore.js';
const screenWidth = ref(screen.width)
@@ -37,7 +36,6 @@ const sdropdown = ref([
const products = ref([]);
const searchField = ref('descLong');
const searchValue = ref('');
-const settings = ref({});
const countryHash = ref([]);
const countryCurrency = ref({});
@@ -102,7 +100,7 @@ const tproducts = computed(() => {
});
});
const bodyRowClassNameFunction = (item) => {
- if (item.country == form.country.code) return "result-country";
+ if (item.country == settingsStore.country.code) return "result-country";
};
const filterOptions = computed(() => {
const filterOptionsArray = [];
@@ -177,18 +175,11 @@ const descCriteria = ref(uniqDesc.value[0]);
const unitsCriteria = ref(uniqUnits.value[0]);
const type = "GeoChart";
-const form = useForm({
- countries: "",
- country: "",
- field: sdropdown.value[0],
- text: "",
- currency: "EUR",
- online: false,
-});
+settingsStore.field = sdropdown.value[0];
const ccodes = ref([]);
const ccountry = ref([]);
-const ccountry_filter = ref([["Country"]]);
+
const ccountry_list = ref(["TEST"]);
const currencyHash = ref({});
const currency = ref([]);
@@ -225,7 +216,7 @@ const sleep = (ms) => {
};
const onSelectCode = () => {
- if (form.field.value == 'code') {
+ if (settingsStore.field.value == 'code') {
}
}
@@ -234,7 +225,7 @@ const fetch = async () => {
const response = await axios.get(route("ccountry.active"));
ccountry.value = response.data;
let aCntry = ccountry.value.map((country) => [country.country_name]);
- ccountry_filter.value.push(...aCntry);
+ settingsStore.ccountry_filter.push(...aCntry);
ccountry_list.value = ccountry.value.map((country) => country.country_name);
var i = 1;
@@ -245,9 +236,10 @@ const fetch = async () => {
id: i++,
};
});
- console.log("TEST=", ccountry_filter.value, ccountry_list.value);
+ console.log("TEST=", settingsStore.ccountry_filter, ccountry_list.value);
const response2 = await axios.get(route("settings.index"));
- settings.value = response2.data;
+ settingsStore.settings = response2.data;
+ console.log("SETTINGS=",settingsStore.settings);
} catch (e) {
const response = await Swal.fire({
@@ -317,15 +309,15 @@ const fetch_ccodes = async () => {
};
const async_search = async () => {
- if (form.text.length < 2) return;
+ if (settingsStore.text.length < 2) return;
try {
let country = null;
- if (form.country.code !== undefined) country = form.country.code;
+ if (settingsStore.country.code !== undefined) country = settingsStore.country.code;
- const response = await axios.get(
- route("products.search", [form.field.value, form.text, country, form.online])
- );
+ console.log('SETTINGS',settingsStore.country);
+ console.log('URL',route("products.search", [settingsStore.field.value, settingsStore.text, country]));
+ const response = await axios.get(route("products.search", [settingsStore.field.value, settingsStore.text, country, settingsStore.online]));
options_items.value = response.data.map((i) => {
return {
@@ -337,11 +329,12 @@ const async_search = async () => {
price: parseFloat(i.salesPrice),
units: i.priceUnit,
descLong: i.mainImageAlt,
+ globalCode: i.itemNoGlobal,
};
});
console.log("VALUES=", options_items.value);
- if (form.field.value == 'code') {
- showRow({'code': form.text});
+ if (settingsStore.field.value == 'code') {
+ showRow({'code': settingsStore.text});
}
productsCriteria.value = null;
} catch (e) {
@@ -362,17 +355,6 @@ function customLabel({ item, desc, code }) {
return `${item} - ${desc} - ${code}`;
}
-function selectCountry(item, id) {
- let cCntry = [["Country"]];
- console.log(form.countries);
- let aCntry = form.countries.map((country) => [country]);
- if (form.countries.length == 0) aCntry = ccountry.value.map((country) => [country.country_name]);
-
- ccountry_filter.value = cCntry;
- ccountry_filter.value.push(...aCntry);
-
-
-}
onMounted(fetch);
onMounted(fetch_rates);
@@ -380,14 +362,14 @@ onMounted(fetch_ccodes);
const showRow = async (item) => {
console.log("ITEM=", item);
- console.log("FORM=", form);
+
itemCode.value = item.code;
try {
const response = await axios.post(route("products.compare"), {
- codes: item.code,
- countries: form.countries,
- currency: form.currency,
- online: form.online,
+ codes: item.globalCode,
+ countries: settingsStore.countries,
+ currency: settingsStore.currency,
+ online: settingsStore.online,
});
products.value = response.data.products;
@@ -406,17 +388,17 @@ const showRow = async (item) => {
}
};
const onSelectCurrency = () => {
- console.log("CURR", form.currency);
+ console.log("CURR", settingsStore.currency);
console.log("COEF", currencyCoef.value);
- if (form.currency != "EUR")
- currencyCoef.value = currencyHash.value[form.currency];
+ if (settingsStore.currency != "EUR")
+ currencyCoef.value = currencyHash.value[settingsStore.currency];
else currencyCoef.value = 1.0;
};
const submit = () => {
console.log("ITEM=", form);
- if (form.codes.length == 0) {
+ if (settingsStore.codes.length == 0) {
Swal.fire({
title: "Empty code",
text: "You must enter product!",
@@ -424,17 +406,10 @@ const submit = () => {
});
return false;
}
- form.post(route("products.compare"));
+ settingsStore.post(route("products.compare"));
};
-watch(ccodes, (codes) => {
- console.log("NNN=", codes);
- console.log("IP=", geoip.value);
- codes.forEach((c) => {
- if (c.code == geoip.value.iso_code) form.country = c;
- });
- console.log("FC=", form.country);
-});
+
@@ -470,26 +445,13 @@ watch(ccodes, (codes) => {
-
-
-
-
-
-
+