mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-14 11:12:16 +01:00
add frontend format support for currencies, add currencies endpoint
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import TextInput from '@/packages/ui/src/Input/TextInput.vue';
|
||||
import {
|
||||
formatCents,
|
||||
getOrganizationCurrencySymbol,
|
||||
} from '@/packages/ui/src/utils/money';
|
||||
import { ref, watch } from 'vue';
|
||||
import { formatCents } from '@/packages/ui/src/utils/money';
|
||||
import { ref, watch, inject, type ComputedRef } from 'vue';
|
||||
import { useFocus } from '@vueuse/core';
|
||||
import type { Organization } from '@/packages/api/src';
|
||||
|
||||
const props = defineProps<{
|
||||
name: string;
|
||||
@@ -13,6 +11,8 @@ const props = defineProps<{
|
||||
currency: string;
|
||||
}>();
|
||||
|
||||
const organization = inject<ComputedRef<Organization>>('organization');
|
||||
|
||||
const model = defineModel<number | null>({
|
||||
default: null,
|
||||
});
|
||||
@@ -58,9 +58,15 @@ function updateRate(value: string) {
|
||||
}
|
||||
|
||||
function formatValue(modelValue: number | null) {
|
||||
const formattedValue = formatCents(modelValue ?? 0, props.currency);
|
||||
const formattedValue = formatCents(
|
||||
modelValue ?? 0,
|
||||
props.currency,
|
||||
organization?.value?.currency_format,
|
||||
organization?.value?.currency_symbol,
|
||||
organization?.value?.number_format
|
||||
);
|
||||
return formattedValue
|
||||
.replace(getOrganizationCurrencySymbol(props.currency), '')
|
||||
?.replace(organization?.value?.currency_symbol ?? '', '')
|
||||
.trim();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user