mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-06 04:26:13 +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>
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { cached } from '@/app/cached-functions'
|
|
import { Totals } from '@/app/groups/[groupId]/stats/totals'
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from '@/components/ui/card'
|
|
import { getGroupExpenses } from '@/lib/api'
|
|
import { getTotalGroupSpending } from '@/lib/totals'
|
|
import { Metadata } from 'next'
|
|
import { notFound } from 'next/navigation'
|
|
|
|
export const metadata: Metadata = {
|
|
title: 'Totals',
|
|
}
|
|
|
|
export default async function TotalsPage({
|
|
params: { groupId },
|
|
}: {
|
|
params: { groupId: string }
|
|
}) {
|
|
const group = await cached.getGroup(groupId)
|
|
if (!group) notFound()
|
|
|
|
const expenses = await getGroupExpenses(groupId)
|
|
const totalGroupSpendings = getTotalGroupSpending(expenses)
|
|
|
|
return (
|
|
<>
|
|
<Card className="mb-4">
|
|
<CardHeader>
|
|
<CardTitle>Totals</CardTitle>
|
|
<CardDescription>
|
|
Spending summary of the entire group.
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="flex flex-col space-y-4">
|
|
<Totals
|
|
group={group}
|
|
expenses={expenses}
|
|
totalGroupSpendings={totalGroupSpendings}
|
|
/>
|
|
</CardContent>
|
|
</Card>
|
|
</>
|
|
)
|
|
}
|