b022c1c3b0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
import type { Metadata } from "next";
|
||
import { notFound } from "next/navigation";
|
||
import { PageHeader } from "@/components/page-header";
|
||
import { AssetsView } from "@/features/assets/components/assets-view";
|
||
import { PeriodReportView } from "@/features/assets/components/period-report";
|
||
import {
|
||
getPeriodReport,
|
||
listAssets,
|
||
REPORT_RANGES,
|
||
type ReportRange,
|
||
} from "@/features/assets/service";
|
||
import { NetWorthCard } from "@/features/net-worth/components/net-worth-card";
|
||
import { getNetWorth } from "@/features/net-worth/service";
|
||
import { tr } from "@/i18n/tr";
|
||
import { requireActiveHousehold } from "@/lib/dal";
|
||
|
||
export const metadata: Metadata = { title: tr.assets.title };
|
||
|
||
function parseRange(value: string | string[] | undefined): ReportRange {
|
||
return REPORT_RANGES.includes(value as ReportRange) ? (value as ReportRange) : "6";
|
||
}
|
||
|
||
/** /birikim — net varlık, varlıklar (ortalama maliyet, K/Z) ve dönemsel rapor. */
|
||
export default async function AssetsPage({ searchParams }: PageProps<"/birikim">) {
|
||
const { user, household } = await requireActiveHousehold("viewer");
|
||
const range = parseRange((await searchParams).donem);
|
||
const [data, report, netWorth] = await Promise.all([
|
||
listAssets(user.id, household.id),
|
||
getPeriodReport(user.id, household.id, range),
|
||
getNetWorth(user.id, household.id),
|
||
]);
|
||
if (!data || !report || !netWorth) notFound();
|
||
return (
|
||
<>
|
||
<PageHeader title={tr.assets.title} description={tr.assets.description} />
|
||
<section aria-labelledby="net-worth-title" className="flex flex-col gap-2">
|
||
<h2 id="net-worth-title" className="text-base font-medium">
|
||
{tr.assets.netWorth.title}
|
||
</h2>
|
||
<NetWorthCard data={netWorth} />
|
||
</section>
|
||
<AssetsView items={data.items} totals={data.totals} canWrite={data.canWrite} />
|
||
<PeriodReportView report={report} range={range} basePath="/birikim" />
|
||
</>
|
||
);
|
||
}
|