Redesign with toolbar
This commit is contained in:
@@ -51,7 +51,7 @@ class ProductsCompareController extends Controller
|
|||||||
Log::info("ONLINE {codes} {countries}", ["codes" => $codes, "countries" => $countries, "online" => $online]);
|
Log::info("ONLINE {codes} {countries}", ["codes" => $codes, "countries" => $countries, "online" => $online]);
|
||||||
$products = $this->countryCompareController->compare($countries, $cHash, $codes);
|
$products = $this->countryCompareController->compare($countries, $cHash, $codes);
|
||||||
} else {
|
} else {
|
||||||
$products = IkeaProducts::whereIn("code", $aCodes);
|
$products = IkeaProducts::whereIn("itemNoGlobal", $aCodes);
|
||||||
if (count($countries)) $products->whereIn("country", $countries);
|
if (count($countries)) $products->whereIn("country", $countries);
|
||||||
$products = $products->get();
|
$products = $products->get();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,5 +126,12 @@
|
|||||||
"typeerror: invalid assignment to const 'response'": "TypeError: invalid assignment to const 'response'",
|
"typeerror: invalid assignment to const 'response'": "TypeError: invalid assignment to const 'response'",
|
||||||
"error: request aborted": "Error: Request aborted",
|
"error: request aborted": "Error: Request aborted",
|
||||||
"typeerror: can't access property \"code\", form.country is null": "TypeError: can't access property \"code\", form.country is null",
|
"typeerror: can't access property \"code\", form.country is null": "TypeError: can't access property \"code\", form.country is null",
|
||||||
"error: request failed with status code 504": "Error: Request failed with status code 504"
|
"error: request failed with status code 504": "Error: Request failed with status code 504",
|
||||||
|
"referenceerror: geoip is not defined": "ReferenceError: geoip is not defined",
|
||||||
|
"referenceerror: ccodes is not defined": "ReferenceError: ccodes is not defined",
|
||||||
|
"referenceerror: items is not defined": "ReferenceError: items is not defined",
|
||||||
|
"referenceerror: settings is not defined": "ReferenceError: settings is not defined",
|
||||||
|
"referenceerror: currencyhash is not defined": "ReferenceError: currencyHash is not defined",
|
||||||
|
"typeerror: can't access property \"code\", (intermediate value).country.country is undefined": "TypeError: can't access property \"code\", (intermediate value).country.country is undefined",
|
||||||
|
"typeerror: can't access property \"code\", (intermediate value).country[0] is undefined": "TypeError: can't access property \"code\", (intermediate value).country[0] is undefined"
|
||||||
}
|
}
|
||||||
13
package.json
13
package.json
@@ -17,24 +17,27 @@
|
|||||||
"lodash": "^4.17.19",
|
"lodash": "^4.17.19",
|
||||||
"postcss": "^8.4.14",
|
"postcss": "^8.4.14",
|
||||||
"tailwindcss": "^3.1.0",
|
"tailwindcss": "^3.1.0",
|
||||||
"vite": "^2.9.11",
|
"vite": "^2.9.11"
|
||||||
"vue": "^3.4.15"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coreui/vue": "^4.10.2",
|
"@coreui/vue": "^4.10.2",
|
||||||
"@vueform/multiselect": "^2.5.1",
|
"@vueform/multiselect": "^2.5.1",
|
||||||
|
"flag-icons": "^7.2.0",
|
||||||
"flowbite": "^2.1.1",
|
"flowbite": "^2.1.1",
|
||||||
"flowbite-vue": "^0.1.3",
|
"flowbite-vue": "github:skjaro/flowbite-vue",
|
||||||
"laravel-echo": "^1.13.0",
|
"laravel-echo": "^1.13.0",
|
||||||
"pusher-js": "^7.3.0",
|
"pusher-js": "^7.3.0",
|
||||||
"sweetalert2": "^11.4.23",
|
"sweetalert2": "^11.4.23",
|
||||||
"vee-validate": "^4.12.4",
|
"vee-validate": "^4.12.4",
|
||||||
|
"vue": "3.3.x",
|
||||||
"vue-google-charts": "^1.1.0",
|
"vue-google-charts": "^1.1.0",
|
||||||
"vue-multiselect": "^3.0.0-beta.3",
|
"vue-multiselect": "^3.0.0-beta.3",
|
||||||
"vue3-easy-data-table": "^1.5.47",
|
|
||||||
"vue3-multiselect-checkboxed": "^0.0.9",
|
"vue3-multiselect-checkboxed": "^0.0.9",
|
||||||
"vue3-popper": "^1.5.0",
|
"vue3-popper": "^1.5.0",
|
||||||
"vuedraggable": "^4.1.0",
|
"vuedraggable": "^4.1.0",
|
||||||
"yup": "^1.3.3"
|
"yup": "^1.3.3"
|
||||||
}
|
},
|
||||||
|
"bundleDependencies": [
|
||||||
|
"flowbite-vue"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import Swal from 'sweetalert2';
|
import Swal from 'sweetalert2';
|
||||||
import { getCurrentInstance, ref, onMounted, onUnmounted, nextTick, computed } from 'vue';
|
import { ref, onMounted, computed ,watch } from 'vue';
|
||||||
import { FwbDropdown, FwbListGroup, FwbListGroupItem } from 'flowbite-vue';
|
|
||||||
import LogoIkea from '@/assets/Ikea_logo.svg';
|
import LogoIkea from '@/assets/Ikea_logo.svg';
|
||||||
import UserOptions from './UserOptions.vue';
|
|
||||||
import {
|
import {
|
||||||
FwbSelect,
|
FwbSelect,
|
||||||
FwbNavbar,
|
FwbNavbar,
|
||||||
@@ -11,9 +9,34 @@ import {
|
|||||||
FwbNavbarLink,
|
FwbNavbarLink,
|
||||||
FwbNavbarLogo,
|
FwbNavbarLogo,
|
||||||
FwbButton,
|
FwbButton,
|
||||||
|
FwbDropdown,
|
||||||
|
FwbListGroup,
|
||||||
|
FwbListGroupItem,
|
||||||
|
FwbMegaMenu,
|
||||||
|
FwbMegaMenuDropdown,
|
||||||
|
FwbRadio,
|
||||||
} from 'flowbite-vue';
|
} from 'flowbite-vue';
|
||||||
|
import Multiselect from "vue-multiselect";
|
||||||
|
import { settingsStore } from '../settingsStore.js';
|
||||||
const menu = ref([])
|
const menu = ref([])
|
||||||
|
const geoip = ref(null)
|
||||||
|
const ccodes = ref([])
|
||||||
|
const rates = ref([])
|
||||||
|
const currency = ref([])
|
||||||
|
const countryCurrency = ref([])
|
||||||
|
const currencyHash = ref([])
|
||||||
|
|
||||||
|
const ccountry = ref([])
|
||||||
|
const ccountry_list = ref([])
|
||||||
|
const items = ref([])
|
||||||
|
|
||||||
|
let tsettings = computed(() => {
|
||||||
|
let country = "GB";
|
||||||
|
console.log('AAAAA',settingsStore.country);
|
||||||
|
if (settingsStore.country != "") country = settingsStore.country.code;
|
||||||
|
return `${country} / ${settingsStore.currency}`;
|
||||||
|
});
|
||||||
|
|
||||||
const fetch_menu = async () => {
|
const fetch_menu = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(route('menu.user'))
|
const response = await axios.get(route('menu.user'))
|
||||||
@@ -31,12 +54,133 @@ const fetch_menu = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fetch_ccodes = async () => {
|
||||||
|
try {
|
||||||
|
const response2 = await axios.get(route("geo.ip.get"));
|
||||||
|
geoip.value = response2.data;
|
||||||
|
|
||||||
|
const response = await axios.get(route("ccountry.codes"));
|
||||||
|
ccodes.value = response.data;
|
||||||
|
ccodes.value = Object.entries(ccodes.value)
|
||||||
|
.map(([k, v]) => {
|
||||||
|
if (v !== null) return { country: k, code: v };
|
||||||
|
})
|
||||||
|
.filter((n) => n);
|
||||||
|
console.log("ccodes=", ccodes.value);
|
||||||
|
} catch (e) {
|
||||||
|
const response = await Swal.fire({
|
||||||
|
title: __("are you want to try again") + "?",
|
||||||
|
text: __(`${e}`),
|
||||||
|
icon: "question",
|
||||||
|
showCancelButton: true,
|
||||||
|
showCloseButton: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
response.isConfirmed && fetch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetch_rates = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(route("rates.index"));
|
||||||
|
rates.value = response.data;
|
||||||
|
currency.value = rates.value.map((currency) => currency.currency);
|
||||||
|
countryCurrency.value = Object.fromEntries(
|
||||||
|
rates.value.map((currency) => [currency.country_name, currency.currency])
|
||||||
|
);
|
||||||
|
currencyHash.value = Object.fromEntries(
|
||||||
|
rates.value.map((currency) => [currency.currency, currency.rate])
|
||||||
|
);
|
||||||
|
|
||||||
|
currency.value.unshift("EUR");
|
||||||
|
console.log("RATE=", rates.value);
|
||||||
|
console.log("HASH=", currencyHash.value);
|
||||||
|
} catch (e) {
|
||||||
|
const response = await Swal.fire({
|
||||||
|
title: __("are you want to try again") + "?",
|
||||||
|
text: __(`${e}`),
|
||||||
|
icon: "question",
|
||||||
|
showCancelButton: true,
|
||||||
|
showCloseButton: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
response.isConfirmed && fetch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const fetch = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(route("ccountry.active"));
|
||||||
|
ccountry.value = response.data;
|
||||||
|
let aCntry = ccountry.value.map((country) => [country.country_name]);
|
||||||
|
settingsStore.ccountry_filter.push(...aCntry);
|
||||||
|
|
||||||
|
ccountry_list.value = ccountry.value.map((country) => {
|
||||||
|
return {
|
||||||
|
name: country.country_name,
|
||||||
|
code: country.country_code,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
var i = 1;
|
||||||
|
items.value = ccountry.value.map((country) => {
|
||||||
|
return {
|
||||||
|
country: country.country_name,
|
||||||
|
currency: country.currency_code,
|
||||||
|
id: i++,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
console.log("TEST=", settingsStore.ccountry_filter, ccountry_list.value);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
const response = await Swal.fire({
|
||||||
|
title: __("are you want to try again") + "?",
|
||||||
|
text: __(`${e}`),
|
||||||
|
icon: "question",
|
||||||
|
showCancelButton: true,
|
||||||
|
showCloseButton: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
response.isConfirmed && fetch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function selectCountry(item, id) {
|
||||||
|
let cCntry = [["Country"]];
|
||||||
|
|
||||||
|
let aCntry = settingsStore.countries.map((country) => [country.name]);
|
||||||
|
if (settingsStore.countries.length == 0) aCntry = ccountry.value.map((country) => [country.country_name]);
|
||||||
|
|
||||||
|
settingsStore.ccountry_filter = cCntry;
|
||||||
|
settingsStore.ccountry_filter.push(...aCntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(ccodes, (codes) => {
|
||||||
|
console.log("NNN=", codes);
|
||||||
|
console.log("IP=", geoip.value);
|
||||||
|
|
||||||
|
let fonud = false;
|
||||||
|
codes.forEach((c) => {
|
||||||
|
if (c.code == geoip.value.iso_code) {
|
||||||
|
settingsStore.country = c;
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (fonud == false) settingsStore.country = codes.filter((c) => {return c.code == 'GB'})[0];
|
||||||
|
console.log("FC=", settingsStore.country);
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(fetch);
|
||||||
|
onMounted(fetch_rates);
|
||||||
|
onMounted(fetch_ccodes);
|
||||||
onMounted(fetch_menu);
|
onMounted(fetch_menu);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@import "flag-icons/css/flag-icons.min.css";
|
||||||
|
</style>
|
||||||
<template>
|
<template>
|
||||||
<fwb-navbar>
|
<fwb-navbar class="px-0">
|
||||||
<template #logo>
|
<template #logo>
|
||||||
<fwb-navbar-logo alt="IKEA Price Craweler" :image-url="LogoIkea" :link="route('root')">
|
<fwb-navbar-logo alt="IKEA Price Craweler" :image-url="LogoIkea" :link="route('root')">
|
||||||
IKEA Price Crawler
|
IKEA Price Crawler
|
||||||
@@ -45,13 +189,13 @@ onMounted(fetch_menu);
|
|||||||
|
|
||||||
<template #default="{ isShowMenu }">
|
<template #default="{ isShowMenu }">
|
||||||
<fwb-navbar-collapse :is-show-menu="isShowMenu" v-if="menu.length > 0">
|
<fwb-navbar-collapse :is-show-menu="isShowMenu" v-if="menu.length > 0">
|
||||||
<fwb-navbar-link>
|
|
||||||
<user-options></user-options>
|
|
||||||
|
|
||||||
</fwb-navbar-link>
|
|
||||||
<fwb-navbar-link :link="route(menu[0].route_or_url)">
|
<fwb-navbar-link :link="route(menu[0].route_or_url)">
|
||||||
Home
|
Home
|
||||||
</fwb-navbar-link>
|
</fwb-navbar-link>
|
||||||
|
<fwb-mega-menu link="#">
|
||||||
|
<template #default>{{ tsettings }}</template>
|
||||||
|
</fwb-mega-menu>
|
||||||
<template v-for="item in menu[0].childs" v-if="menu.length > 0">
|
<template v-for="item in menu[0].childs" v-if="menu.length > 0">
|
||||||
<fwb-navbar-link :link="route(item.route_or_url)">
|
<fwb-navbar-link :link="route(item.route_or_url)">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
@@ -60,7 +204,43 @@ onMounted(fetch_menu);
|
|||||||
</fwb-navbar-collapse>
|
</fwb-navbar-collapse>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<template #mega-menu>TEST</template>
|
<template #mega-menu-dropdown>
|
||||||
|
<fwb-mega-menu-dropdown>
|
||||||
|
|
||||||
|
<div class="flex-auto">
|
||||||
|
<div class="flex flex-col start-0">
|
||||||
|
<span class="font-extrabold font-mono">Country in which search product</span>
|
||||||
|
</div>
|
||||||
|
<div class="">
|
||||||
|
<multiselect placeholder="All" :close-on-select="true" :multiple="false" v-model="settingsStore.country" :options="ccodes" label="country" track-by="code">
|
||||||
|
<template #option="slotProps">
|
||||||
|
<span :class="'pl-6 fi fi-' + slotProps.option.code.toLowerCase()">{{ slotProps.option.country }}</span>
|
||||||
|
</template>
|
||||||
|
</multiselect>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-auto">
|
||||||
|
<div class="flex flex-col start-0">
|
||||||
|
<span class="font-extrabold font-mono">Countries in which compare</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<multiselect placeholder="All" @remove="selectCountry" @select="selectCountry" :close-on-select="false" :multiple="true" v-model="settingsStore.countries" :options="ccountry_list" label="name" track-by="name">
|
||||||
|
<template #option="slotProps">
|
||||||
|
<span :class="'pl-6 fi fi-' + slotProps.option.code.toLowerCase()">{{ slotProps.option.name }}</span>
|
||||||
|
</template>
|
||||||
|
</multiselect>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex-auto">
|
||||||
|
<div class="flex flex-col start-0">
|
||||||
|
<span class="font-extrabold font-mono">Currency recalculation</span>
|
||||||
|
</div>
|
||||||
|
<fwb-radio v-for="c in currency" v-model="settingsStore.currency" name="radio" :label="c" :value="c" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</fwb-mega-menu-dropdown>
|
||||||
|
</template>
|
||||||
</fwb-navbar>
|
</fwb-navbar>
|
||||||
<div class="m-3">
|
<div class="m-3">
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ import { GChart } from "vue-google-charts";
|
|||||||
import EasyTable from "vue3-easy-data-table";
|
import EasyTable from "vue3-easy-data-table";
|
||||||
import GuestLayout from "../Layouts/GuestLayout.vue";
|
import GuestLayout from "../Layouts/GuestLayout.vue";
|
||||||
|
|
||||||
import { useForm } from "@inertiajs/inertia-vue3";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import filterimg from "@/assets/eglass-filter.png";
|
import filterimg from "@/assets/eglass-filter.png";
|
||||||
import searchimg from "@/assets/search-icon.svg";
|
import searchimg from "@/assets/search-icon.svg";
|
||||||
import Popper from "vue3-popper";
|
import { settingsStore } from '../settingsStore.js';
|
||||||
|
|
||||||
|
|
||||||
const screenWidth = ref(screen.width)
|
const screenWidth = ref(screen.width)
|
||||||
@@ -37,7 +36,6 @@ const sdropdown = ref([
|
|||||||
const products = ref([]);
|
const products = ref([]);
|
||||||
const searchField = ref('descLong');
|
const searchField = ref('descLong');
|
||||||
const searchValue = ref('');
|
const searchValue = ref('');
|
||||||
const settings = ref({});
|
|
||||||
|
|
||||||
const countryHash = ref([]);
|
const countryHash = ref([]);
|
||||||
const countryCurrency = ref({});
|
const countryCurrency = ref({});
|
||||||
@@ -102,7 +100,7 @@ const tproducts = computed(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
const bodyRowClassNameFunction = (item) => {
|
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 filterOptions = computed(() => {
|
||||||
const filterOptionsArray = [];
|
const filterOptionsArray = [];
|
||||||
@@ -177,18 +175,11 @@ const descCriteria = ref(uniqDesc.value[0]);
|
|||||||
const unitsCriteria = ref(uniqUnits.value[0]);
|
const unitsCriteria = ref(uniqUnits.value[0]);
|
||||||
|
|
||||||
const type = "GeoChart";
|
const type = "GeoChart";
|
||||||
const form = useForm({
|
settingsStore.field = sdropdown.value[0];
|
||||||
countries: "",
|
|
||||||
country: "",
|
|
||||||
field: sdropdown.value[0],
|
|
||||||
text: "",
|
|
||||||
currency: "EUR",
|
|
||||||
online: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const ccodes = ref([]);
|
const ccodes = ref([]);
|
||||||
const ccountry = ref([]);
|
const ccountry = ref([]);
|
||||||
const ccountry_filter = ref([["Country"]]);
|
|
||||||
const ccountry_list = ref(["TEST"]);
|
const ccountry_list = ref(["TEST"]);
|
||||||
const currencyHash = ref({});
|
const currencyHash = ref({});
|
||||||
const currency = ref([]);
|
const currency = ref([]);
|
||||||
@@ -225,7 +216,7 @@ const sleep = (ms) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSelectCode = () => {
|
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"));
|
const response = await axios.get(route("ccountry.active"));
|
||||||
ccountry.value = response.data;
|
ccountry.value = response.data;
|
||||||
let aCntry = ccountry.value.map((country) => [country.country_name]);
|
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);
|
ccountry_list.value = ccountry.value.map((country) => country.country_name);
|
||||||
var i = 1;
|
var i = 1;
|
||||||
@@ -245,9 +236,10 @@ const fetch = async () => {
|
|||||||
id: i++,
|
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"));
|
const response2 = await axios.get(route("settings.index"));
|
||||||
settings.value = response2.data;
|
settingsStore.settings = response2.data;
|
||||||
|
console.log("SETTINGS=",settingsStore.settings);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const response = await Swal.fire({
|
const response = await Swal.fire({
|
||||||
@@ -317,15 +309,15 @@ const fetch_ccodes = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const async_search = async () => {
|
const async_search = async () => {
|
||||||
if (form.text.length < 2) return;
|
if (settingsStore.text.length < 2) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let country = null;
|
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(
|
console.log('SETTINGS',settingsStore.country);
|
||||||
route("products.search", [form.field.value, form.text, country, form.online])
|
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) => {
|
options_items.value = response.data.map((i) => {
|
||||||
return {
|
return {
|
||||||
@@ -337,11 +329,12 @@ const async_search = async () => {
|
|||||||
price: parseFloat(i.salesPrice),
|
price: parseFloat(i.salesPrice),
|
||||||
units: i.priceUnit,
|
units: i.priceUnit,
|
||||||
descLong: i.mainImageAlt,
|
descLong: i.mainImageAlt,
|
||||||
|
globalCode: i.itemNoGlobal,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
console.log("VALUES=", options_items.value);
|
console.log("VALUES=", options_items.value);
|
||||||
if (form.field.value == 'code') {
|
if (settingsStore.field.value == 'code') {
|
||||||
showRow({'code': form.text});
|
showRow({'code': settingsStore.text});
|
||||||
}
|
}
|
||||||
productsCriteria.value = null;
|
productsCriteria.value = null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -362,17 +355,6 @@ function customLabel({ item, desc, code }) {
|
|||||||
return `${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);
|
||||||
onMounted(fetch_rates);
|
onMounted(fetch_rates);
|
||||||
@@ -380,14 +362,14 @@ onMounted(fetch_ccodes);
|
|||||||
|
|
||||||
const showRow = async (item) => {
|
const showRow = async (item) => {
|
||||||
console.log("ITEM=", item);
|
console.log("ITEM=", item);
|
||||||
console.log("FORM=", form);
|
|
||||||
itemCode.value = item.code;
|
itemCode.value = item.code;
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(route("products.compare"), {
|
const response = await axios.post(route("products.compare"), {
|
||||||
codes: item.code,
|
codes: item.globalCode,
|
||||||
countries: form.countries,
|
countries: settingsStore.countries,
|
||||||
currency: form.currency,
|
currency: settingsStore.currency,
|
||||||
online: form.online,
|
online: settingsStore.online,
|
||||||
});
|
});
|
||||||
|
|
||||||
products.value = response.data.products;
|
products.value = response.data.products;
|
||||||
@@ -406,17 +388,17 @@ const showRow = async (item) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const onSelectCurrency = () => {
|
const onSelectCurrency = () => {
|
||||||
console.log("CURR", form.currency);
|
console.log("CURR", settingsStore.currency);
|
||||||
console.log("COEF", currencyCoef.value);
|
console.log("COEF", currencyCoef.value);
|
||||||
|
|
||||||
if (form.currency != "EUR")
|
if (settingsStore.currency != "EUR")
|
||||||
currencyCoef.value = currencyHash.value[form.currency];
|
currencyCoef.value = currencyHash.value[settingsStore.currency];
|
||||||
else currencyCoef.value = 1.0;
|
else currencyCoef.value = 1.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
console.log("ITEM=", form);
|
console.log("ITEM=", form);
|
||||||
if (form.codes.length == 0) {
|
if (settingsStore.codes.length == 0) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: "Empty code",
|
title: "Empty code",
|
||||||
text: "You must enter product!",
|
text: "You must enter product!",
|
||||||
@@ -424,17 +406,10 @@ const submit = () => {
|
|||||||
});
|
});
|
||||||
return false;
|
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);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<GuestLayout>
|
<GuestLayout>
|
||||||
@@ -470,26 +445,13 @@ watch(ccodes, (codes) => {
|
|||||||
<GChart
|
<GChart
|
||||||
:events="gchartEvents"
|
:events="gchartEvents"
|
||||||
:type="type"
|
:type="type"
|
||||||
:data="ccountry_filter"
|
:data="settingsStore.ccountry_filter"
|
||||||
:options="options"
|
:options="options"
|
||||||
:settings="chart_settings"
|
:settings="chart_settings"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
|
||||||
<span class="font-extrabold font-mono">Currency recalculation</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<multiselect
|
|
||||||
v-model="form.currency"
|
|
||||||
:multiple="false"
|
|
||||||
:allow-empty="false"
|
|
||||||
placeholder="Currency"
|
|
||||||
:searchable="true"
|
|
||||||
:options="currency"
|
|
||||||
@select="onSelectCurrency"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col start-0">
|
<div class="flex flex-col start-0">
|
||||||
<span class="font-extrabold font-mono"
|
<span class="font-extrabold font-mono"
|
||||||
>Results <b v-if="itemCode">for {{ itemCode }}</b>
|
>Results <b v-if="itemCode">for {{ itemCode }}</b>
|
||||||
@@ -514,14 +476,14 @@ watch(ccodes, (codes) => {
|
|||||||
}}</a>
|
}}</a>
|
||||||
</template>
|
</template>
|
||||||
</EasyTable>
|
</EasyTable>
|
||||||
<div v-if="form.field.value == 'code' && form.online == true">Online</div>
|
<div v-if="settingsStore.field == 'code' && settingsStore.online == true">Online</div>
|
||||||
<div v-else-if="settings['LAST_REFRESH_TIME']">Last Refresh Time: {{ settings["LAST_REFRESH_TIME"] }}</div>
|
<div v-else-if="'LAST_REFRESH_TIME' in settingsStore.settings">Last Refresh Time: {{ settingsStore.settings["LAST_REFRESH_TIME"] }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-auto">
|
<div class="mr-auto">
|
||||||
<form @submit.prevent="submit">
|
<form @submit.prevent="submit">
|
||||||
<div>
|
<div>
|
||||||
<div class="grid lg:grid-cols-3 md:grid-cols-1 sm:grid-cols-1">
|
<div class="flex flex-col start-0">
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<div>
|
<div>
|
||||||
<span class="font-extrabold font-mono">Dynamic search:</span>
|
<span class="font-extrabold font-mono">Dynamic search:</span>
|
||||||
@@ -529,20 +491,20 @@ watch(ccodes, (codes) => {
|
|||||||
<div>
|
<div>
|
||||||
<input
|
<input
|
||||||
class="rounded-md w-full"
|
class="rounded-md w-full"
|
||||||
v-model="form.text"
|
v-model="settingsStore.text"
|
||||||
@input="async_search"
|
@input="async_search"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-2" >
|
<div class="ml-2" >
|
||||||
<div v-if="form.field.value == 'code'">
|
<div v-if="settingsStore.field == 'code'">
|
||||||
<span class="font-extrabold font-mono">Online:</span>
|
<span class="font-extrabold font-mono">Online:</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="form.field.value == 'code'">
|
<div v-if="settingsStore.field == 'code'">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"
|
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"
|
||||||
v-model="form.online"
|
v-model="settingsStore.online"
|
||||||
@input="async_search"
|
@input="async_search"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -553,7 +515,7 @@ watch(ccodes, (codes) => {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<multiselect
|
<multiselect
|
||||||
v-model="form.field"
|
v-model="settingsStore.field"
|
||||||
:multiple="false"
|
:multiple="false"
|
||||||
:searchable="false"
|
:searchable="false"
|
||||||
:allow-empty="false"
|
:allow-empty="false"
|
||||||
@@ -565,40 +527,9 @@ watch(ccodes, (codes) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col start-0">
|
|
||||||
<span class="font-extrabold font-mono"
|
|
||||||
>Countries in which compare</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<multiselect
|
|
||||||
placeholder="All"
|
|
||||||
:close-on-select="false"
|
|
||||||
:multiple="true"
|
|
||||||
v-model="form.countries"
|
|
||||||
:options="ccountry_list"
|
|
||||||
@select="selectCountry"
|
|
||||||
@remove="selectCountry"
|
|
||||||
>
|
|
||||||
</multiselect>
|
|
||||||
</div>
|
|
||||||
<div v-if="form.field.value != 'code'" class="flex flex-col start-0">
|
|
||||||
<span class="font-extrabold font-mono"
|
|
||||||
>Country in which search product</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div v-if="form.field.value != 'code'">
|
|
||||||
<multiselect
|
|
||||||
placeholder="All"
|
|
||||||
:close-on-select="true"
|
|
||||||
:multiple="false"
|
|
||||||
v-model="form.country"
|
|
||||||
:options="ccodes"
|
|
||||||
label="country"
|
|
||||||
track-by="code"
|
|
||||||
>
|
|
||||||
</multiselect>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
|
|||||||
13
resources/js/settingsStore.js
Normal file
13
resources/js/settingsStore.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
import { reactive } from 'vue';
|
||||||
|
|
||||||
|
export const settingsStore = reactive({
|
||||||
|
countries: "",
|
||||||
|
country: "",
|
||||||
|
field: "",
|
||||||
|
text: "",
|
||||||
|
currency: "EUR",
|
||||||
|
online: false,
|
||||||
|
ccountry_filter: [["Country"]],
|
||||||
|
settings: {},
|
||||||
|
});
|
||||||
@@ -16,4 +16,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
resolve: {
|
||||||
|
dedupe: ["vue"],
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user