From 670ae0c5e1d92796b3f53b0c2359a4287fe10385 Mon Sep 17 00:00:00 2001 From: Jaroslav Drzik Date: Wed, 17 Jan 2024 20:48:27 +0100 Subject: [PATCH] Exchange rates move --- app/Models/IkeaProducts.php | 1 + deploy.yaml | 8 ++++ lang/id.json | 5 ++- resources/js/Pages/IkeaExchange.vue | 67 +++++++++++++++++++++++++++-- resources/js/Pages/IkeaRoot.vue | 20 ++------- 5 files changed, 81 insertions(+), 20 deletions(-) diff --git a/app/Models/IkeaProducts.php b/app/Models/IkeaProducts.php index d0eee1d..44ce8d7 100644 --- a/app/Models/IkeaProducts.php +++ b/app/Models/IkeaProducts.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Model; class IkeaProducts extends Model { use HasFactory; + protected $table = 't_ikea_products'; diff --git a/deploy.yaml b/deploy.yaml index 051fbeb..7909f11 100644 --- a/deploy.yaml +++ b/deploy.yaml @@ -1,5 +1,6 @@ import: - recipe/laravel.php + - contrib/php-fpm.php config: repository: 'https://git.bh.ttx.sk/jaro/ikea/' @@ -14,6 +15,12 @@ hosts: branch: newlook deploy_path: '/var/www/html/ikea' bin/php: /usr/bin/php81 + php_fpm_version: 8.1 + php_fpm_service: php81-php-fpm + after: + deploy: php-fpm:reload + + tasks: @@ -24,3 +31,4 @@ tasks: after: deploy:failed: deploy:unlock + \ No newline at end of file diff --git a/lang/id.json b/lang/id.json index adfaee3..a890365 100644 --- a/lang/id.json +++ b/lang/id.json @@ -120,5 +120,8 @@ "typeerror: can't access property \"map\", ccountry.value is undefined": "TypeError: can't access property \"map\", ccountry.value is undefined", "referenceerror: priceunit is not defined": "ReferenceError: priceUnit is not defined", "referenceerror: mainimagealt is not defined": "ReferenceError: mainImageAlt is not defined", - "referenceerror: countrycurrency is not defined": "ReferenceError: countryCurrency is not defined" + "referenceerror: countrycurrency is not defined": "ReferenceError: countryCurrency is not defined", + "referenceerror: currencycountryrate is not defined": "ReferenceError: currencyCountryRate is not defined", + "referenceerror: ccountry is not defined": "ReferenceError: ccountry is not defined", + "typeerror: invalid assignment to const 'response'": "TypeError: invalid assignment to const 'response'" } \ No newline at end of file diff --git a/resources/js/Pages/IkeaExchange.vue b/resources/js/Pages/IkeaExchange.vue index 44bcfeb..831d7ca 100644 --- a/resources/js/Pages/IkeaExchange.vue +++ b/resources/js/Pages/IkeaExchange.vue @@ -2,15 +2,76 @@ import { getCurrentInstance, ref, onMounted, onUnmounted, nextTick, computed } from 'vue'; import GuestLayout from '../Layouts/GuestLayout.vue'; import { useForm } from '@inertiajs/inertia-vue3' + +import EasyTable from "vue3-easy-data-table"; import axios from 'axios'; +const headers = ref([ + { text: "Id", value: "id", sortable: true }, + { text: "Country", value: "country", sortable: true }, + { text: "Currency", value: "currency", sortable: true }, + { text: "Rate", value: "rate", sortable: true }, +]); +const currencyCountryRate = ref([]); +const rates = ref([]); +const currencyHash = ref({}); +const currency = ref([]); +const countryCurrency = ref([]); +const ccountry = ref([]); + +const fetch_rates = async () => { + try { + var response = await axios.get(route('rates.index')); + rates.value = response.data; + response = await axios.get(route('ccountry.active')) + ccountry.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]), + ); + var i = 1; + currencyCountryRate.value = ccountry.value.map((country) => { + console.log(country); + return { "country": country.country_name, "currency": country.currency_code, "rate": currencyHash.value[country.currency_code], "id": i++ } + }); + currency.value.unshift('EUR'); + console.log("RATE=", rates.value); + console.log('HASH=', currencyHash.value); + console.log('CCC=',currencyCountryRate); + } 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() + } +} + +onMounted(fetch_rates); \ No newline at end of file + + + diff --git a/resources/js/Pages/IkeaRoot.vue b/resources/js/Pages/IkeaRoot.vue index 2e0a302..cafa94c 100644 --- a/resources/js/Pages/IkeaRoot.vue +++ b/resources/js/Pages/IkeaRoot.vue @@ -174,6 +174,9 @@ const ccountry_list = ref(['TEST']); const currencyHash = ref({}); const currency = ref([]); const currencyCoef = ref(1.0); + +const items = ref([]); + const hrates = ref([ { text: "Currency", value: "currency", sortable: true }, { text: "Country", value: "country_name", sortable: true }, @@ -237,6 +240,7 @@ const fetch_rates = async () => { 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); @@ -303,12 +307,6 @@ function customLabel({ item, desc, code }) { //console.log(item); return `${item} - ${desc} - ${code}`; } -const headers = ref([ - { text: "Id", value: "id", sortable: true }, - { text: "Country", value: "country", sortable: true }, - { text: "Currency", value: "currency" }, -]); -const items = ref([]); function selectCountry(item, id) { let cCntry = [['Country'],]; @@ -463,18 +461,8 @@ const submit = () => { - -
- -
-
- -
- - -