Redesign with toolbar
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
<script setup>
|
||||
import Swal from 'sweetalert2';
|
||||
import { getCurrentInstance, ref, onMounted, onUnmounted, nextTick, computed } from 'vue';
|
||||
import { FwbDropdown, FwbListGroup, FwbListGroupItem } from 'flowbite-vue';
|
||||
import { ref, onMounted, computed ,watch } from 'vue';
|
||||
import LogoIkea from '@/assets/Ikea_logo.svg';
|
||||
import UserOptions from './UserOptions.vue';
|
||||
import {
|
||||
FwbSelect,
|
||||
FwbNavbar,
|
||||
@@ -11,9 +9,34 @@ import {
|
||||
FwbNavbarLink,
|
||||
FwbNavbarLogo,
|
||||
FwbButton,
|
||||
FwbDropdown,
|
||||
FwbListGroup,
|
||||
FwbListGroupItem,
|
||||
FwbMegaMenu,
|
||||
FwbMegaMenuDropdown,
|
||||
FwbRadio,
|
||||
} from 'flowbite-vue';
|
||||
|
||||
import Multiselect from "vue-multiselect";
|
||||
import { settingsStore } from '../settingsStore.js';
|
||||
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 () => {
|
||||
try {
|
||||
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);
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
@import "flag-icons/css/flag-icons.min.css";
|
||||
</style>
|
||||
<template>
|
||||
<fwb-navbar>
|
||||
<fwb-navbar class="px-0">
|
||||
<template #logo>
|
||||
<fwb-navbar-logo alt="IKEA Price Craweler" :image-url="LogoIkea" :link="route('root')">
|
||||
IKEA Price Crawler
|
||||
@@ -45,13 +189,13 @@ onMounted(fetch_menu);
|
||||
|
||||
<template #default="{ isShowMenu }">
|
||||
<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)">
|
||||
Home
|
||||
</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">
|
||||
<fwb-navbar-link :link="route(item.route_or_url)">
|
||||
{{ item.name }}
|
||||
@@ -60,7 +204,43 @@ onMounted(fetch_menu);
|
||||
</fwb-navbar-collapse>
|
||||
|
||||
</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>
|
||||
<div class="m-3">
|
||||
<slot />
|
||||
|
||||
Reference in New Issue
Block a user