31 lines
752 B
Vue
31 lines
752 B
Vue
<script setup lang="ts">
|
|
const props = defineProps<{
|
|
amountMinor: number;
|
|
currency: string;
|
|
}>();
|
|
|
|
const { formatPrice, currency } = usePrice();
|
|
const display = ref("");
|
|
const failed = ref(false);
|
|
|
|
async function refresh(): Promise<void> {
|
|
if (import.meta.server) return;
|
|
failed.value = false;
|
|
try {
|
|
display.value = await formatPrice(props.amountMinor, props.currency, currency.value);
|
|
} catch {
|
|
failed.value = true;
|
|
display.value = "";
|
|
}
|
|
}
|
|
|
|
watch([() => props.amountMinor, () => props.currency, currency], () => void refresh(), {
|
|
immediate: true,
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<span v-if="failed" class="text-muted">{{ $t("mall.notAvailable") }}</span>
|
|
<span v-else>{{ display || $t("common.loading") }}</span>
|
|
</template>
|