Add tag to results

This commit is contained in:
2024-01-10 21:43:49 +01:00
parent 84ce71a915
commit d7e74f5e71

View File

@@ -41,18 +41,19 @@ const countryCurrency = ref({});
const showItemFilter = ref(false); const showItemFilter = ref(false);
let tproducts = computed(() => { let tproducts = computed(() => {
console.log('PR=',products); console.log('PR=', products);
console.log('CC=',countryCurrency.value); console.log('CC=', countryCurrency.value);
return products.value.map((prod) => { return products.value.map((prod) => {
prod.currency = countryCurrency.value[prod.countryName]; prod.currency = countryCurrency.value[prod.countryName];
if (currencyHash.value[prod.currency]) prod.calcPrice = prod.salesPrice/currencyHash.value[prod.currency]; if (currencyHash.value[prod.currency]) prod.calcPrice = prod.salesPrice / currencyHash.value[prod.currency];
else { else {
prod.calcPrice = prod.salesPrice; prod.calcPrice = prod.salesPrice;
prod.currency = 'EUR' prod.currency = 'EUR'
} }
if (prod.tag == 'NONE') prod.tag = '';
prod.calcPrice = (prod.calcPrice * currencyCoef.value).toFixed(2); prod.calcPrice = (prod.calcPrice * currencyCoef.value).toFixed(2);
prod.rate = currencyHash.value[prod.currency]; prod.rate = currencyHash.value[prod.currency];
return prod; return prod;
}) })
}) })
@@ -95,9 +96,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" }, // { "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([ const hproducts = ref([
{ text: "Country", value: "countryName", sortable: true }, { text: "Country", value: "countryName", sortable: true },
// { text: "Name", value: "name", sortable: true }, { text: "Tag", value: "tag", sortable: true },
{ text: "Local Price", value: "salesPrice", sortable: true }, { text: "Local Price", value: "salesPrice", sortable: true },
{ text: "Cur", value: "currency", sortable: false}, { text: "Cur", value: "currency", sortable: false },
{ text: "Rate", value: "rate" }, { text: "Rate", value: "rate" },
{ text: "Price", value: "calcPrice", sortable: true } { text: "Price", value: "calcPrice", sortable: true }
]); ]);
@@ -167,8 +168,8 @@ const fetch_rates = async () => {
const response = await axios.get(route('rates.index')) const response = await axios.get(route('rates.index'))
rates.value = response.data; rates.value = response.data;
currency.value = rates.value.map((currency) => currency.currency); currency.value = rates.value.map((currency) => currency.currency);
countryCurrency.value = Object.fromEntries( countryCurrency.value = Object.fromEntries(
rates.value.map((currency) => [currency.country_name, currency.currency ]) rates.value.map((currency) => [currency.country_name, currency.currency])
); );
currencyHash.value = Object.fromEntries( currencyHash.value = Object.fromEntries(
rates.value.map((currency) => [currency.currency, currency.rate]), rates.value.map((currency) => [currency.currency, currency.rate]),