mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-09 13:49:04 +01:00
* feat: initialise a new totals tab with basic UI * fix: update group tabs and add stats page * fix: styling within the new elements * Prettier * Display active user expenses only if active user is set --------- Co-authored-by: Sebastien Castiel <sebastien@castiel.me>
31 lines
860 B
TypeScript
31 lines
860 B
TypeScript
'use client'
|
|
import { getGroup, getGroupExpenses } from '@/lib/api'
|
|
import { useActiveUser } from '@/lib/hooks'
|
|
import { getTotalActiveUserPaidFor } from '@/lib/totals'
|
|
import { formatCurrency } from '@/lib/utils'
|
|
|
|
type Props = {
|
|
group: NonNullable<Awaited<ReturnType<typeof getGroup>>>
|
|
expenses: NonNullable<Awaited<ReturnType<typeof getGroupExpenses>>>
|
|
}
|
|
|
|
export function TotalsYourSpendings({ group, expenses }: Props) {
|
|
const activeUser = useActiveUser(group.id)
|
|
|
|
const totalYourSpendings =
|
|
activeUser === '' || activeUser === 'None'
|
|
? 0
|
|
: getTotalActiveUserPaidFor(activeUser, expenses)
|
|
const currency = group.currency
|
|
|
|
return (
|
|
<div>
|
|
<div className="text-muted-foreground">Total you paid for</div>
|
|
|
|
<div className="text-lg">
|
|
{formatCurrency(currency, totalYourSpendings)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|