refactor: remove deprecated components and streamline member coverage calculations, enhance budget management with improved payroll handling, and update UI elements for better clarity
This commit is contained in:
parent
983aeca2dc
commit
09d8794d72
42 changed files with 2166 additions and 2974 deletions
37
composables/useCurrency.ts
Normal file
37
composables/useCurrency.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { getCurrencySymbol } from '~/utils/currency'
|
||||
|
||||
export function useCurrency() {
|
||||
const coop = useCoopBuilder()
|
||||
|
||||
const currencySymbol = computed(() => getCurrencySymbol(coop.currency.value))
|
||||
|
||||
const formatCurrency = (amount: number, options?: { showSymbol?: boolean; precision?: number }) => {
|
||||
const { showSymbol = true, precision = 0 } = options || {}
|
||||
|
||||
const formatted = new Intl.NumberFormat('en-US', {
|
||||
minimumFractionDigits: precision,
|
||||
maximumFractionDigits: precision
|
||||
}).format(amount)
|
||||
|
||||
if (showSymbol) {
|
||||
return `${currencySymbol.value}${formatted}`
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
const formatCurrencyCompact = (amount: number) => {
|
||||
if (amount >= 1000000) {
|
||||
return `${currencySymbol.value}${(amount / 1000000).toFixed(1)}M`
|
||||
} else if (amount >= 1000) {
|
||||
return `${currencySymbol.value}${(amount / 1000).toFixed(1)}k`
|
||||
}
|
||||
return formatCurrency(amount)
|
||||
}
|
||||
|
||||
return {
|
||||
currencySymbol,
|
||||
formatCurrency,
|
||||
formatCurrencyCompact
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue