mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 21:33:02 +01:00
* add missing translations and translate page titles * fix: actually use the declared localized variables * lint and prettier fixes * add missing translations for toasts and confirms * use components for shift/enter keys, add pluralization for photos, and fix primary photo conditional * remove prop defaults since we're computing these anyways
46 lines
959 B
Vue
46 lines
959 B
Vue
<template>
|
|
<Suspense>
|
|
<template #default>
|
|
{{ formattedValue }}
|
|
</template>
|
|
<template #fallback> {{ $t("global.loading") }} </template>
|
|
</Suspense>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, computed } from "vue";
|
|
import { useI18n } from "vue-i18n";
|
|
|
|
const { t } = useI18n();
|
|
|
|
type Props = {
|
|
amount: string | number;
|
|
};
|
|
|
|
const props = defineProps<Props>();
|
|
|
|
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R>
|
|
? R
|
|
: any;
|
|
|
|
const fmt = ref<AsyncReturnType<typeof useFormatCurrency> | null>(null);
|
|
|
|
const loadFormatter = async () => {
|
|
fmt.value = await useFormatCurrency();
|
|
};
|
|
|
|
loadFormatter();
|
|
|
|
const formattedValue = computed(() => {
|
|
if (!fmt.value) {
|
|
return t("global.loading");
|
|
}
|
|
|
|
if (!props.amount || props.amount === "0") {
|
|
return fmt.value(0);
|
|
}
|
|
|
|
return fmt.value(props.amount);
|
|
});
|
|
</script>
|