Skip to content

Commit

Permalink
components(calculator/share-dialog-screenshot-exchange-rate-item): re…
Browse files Browse the repository at this point in the history
…factor
  • Loading branch information
ozgurg committed Apr 2, 2024
1 parent bc5dc25 commit 6622773
Showing 1 changed file with 15 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,22 @@
width="100%"
type="image" />
</template>
<template v-else-if="exchangeRate !== null">
<span class="grey--text text--lighten-1">
{{ moneyFormat(exchangeRate.rate, "TRY") }}
</span>
</template>
<template v-else>
<div class="grey--text text--lighten-1">
<template v-if="exchangeRate">
{{ moneyFormat(exchangeRate.rate, "TRY") }}
</template>
<template v-else>
<v-icon
color="red"
size="20">
{{ errorIcon }}
</v-icon>
</template>
</div>
Hata 😊
</template>
</div>
</template>

<script>
import { mdiAlertCircle } from "@mdi/js";
import { moneyFormat } from "@/utils/formatter.js";
export default {
data: () => ({
errorIcon: mdiAlertCircle,
isLoading: true,
exchangeRate: null
}),
Expand All @@ -47,18 +39,16 @@ export default {
},
methods: {
moneyFormat,
_load() {
async _load() {
const vm = this;
vm.$store.dispatch("exchange-rates/loadExchangeRateFromApi", vm.currencyCode)
.then(exchangeRate => {
vm.exchangeRate = exchangeRate;
})
.catch(() => {
vm.exchangeRate = null;
})
.finally(() => {
vm.isLoading = false;
});
vm.exchangeRate = null;
try {
vm.exchangeRate = await vm.$store.dispatch("exchange-rates/loadExchangeRateFromApi", vm.currencyCode);
} catch (error) {
vm.exchangeRate = null;
} finally {
vm.isLoading = false;
}
}
},
mounted() {
Expand Down

0 comments on commit 6622773

Please sign in to comment.