mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-09 21:49:06 +01:00
34 lines
820 B
TypeScript
34 lines
820 B
TypeScript
'use client'
|
|
import { Currency } from '@/lib/currency'
|
|
import { cn, formatCurrency } from '@/lib/utils'
|
|
import { useLocale, useTranslations } from 'next-intl'
|
|
|
|
export function TotalsYourSpendings({
|
|
totalParticipantSpendings = 0,
|
|
currency,
|
|
}: {
|
|
totalParticipantSpendings?: number
|
|
currency: Currency
|
|
}) {
|
|
const locale = useLocale()
|
|
const t = useTranslations('Stats.Totals')
|
|
|
|
const balance =
|
|
totalParticipantSpendings < 0 ? 'yourEarnings' : 'yourSpendings'
|
|
|
|
return (
|
|
<div>
|
|
<div className="text-muted-foreground">{t(balance)}</div>
|
|
|
|
<div
|
|
className={cn(
|
|
'text-lg',
|
|
totalParticipantSpendings < 0 ? 'text-green-600' : 'text-red-600',
|
|
)}
|
|
>
|
|
{formatCurrency(currency, Math.abs(totalParticipantSpendings), locale)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|