feat(i18n): complete portal localized surfaces

This commit is contained in:
poyrazavsever
2026-07-21 13:37:35 +03:00
parent 86a9c79511
commit 1227588320
12 changed files with 163 additions and 47 deletions
+21 -4
View File
@@ -2,6 +2,7 @@ import { Card, CardContent, Badge } from "poyraz-ui/atoms";
import { FolderKanban, CheckCircle2, Clock, BarChart } from "lucide-react";
import Link from "next/link";
import { StatCard } from "@/components/system/stat-card";
import { getPublicBranding } from "@/server/branding/runtime";
import { getSqliteConnection } from "@/server/db/client";
import { ContentTranslationService, getContentFallbackLocale } from "@/server/i18n/content";
import { formatDate } from "@/lib/i18n/format";
@@ -16,6 +17,12 @@ export default async function PortalDashboardPage() {
const content = new ContentTranslationService(getSqliteConnection().db);
const localization = content.getPublicLocalizationContext();
const fallbackLocale = getContentFallbackLocale(locale.locale, localization);
const branding = content.resolveEntity("branding", { id: "default", ...getPublicBranding() }, {
locale: locale.locale,
fallbackLocale,
defaultLocale: locale.defaultLocale,
translations: content.listEntityTranslations("branding", "default"),
});
const projectRows = service.listProjects(actor);
const projectTranslations = content.listBatch("project", projectRows.map((project) => project.id));
const projects = projectRows.map((project) => content.resolveEntity("project", project, {
@@ -29,19 +36,23 @@ export default async function PortalDashboardPage() {
const avgProgress = projects.length
? Math.round(projects.reduce((sum, project) => sum + project.progress, 0) / projects.length)
: 0;
const number = new Intl.NumberFormat(locale.locale);
return (
<div className="mx-auto flex max-w-7xl flex-col gap-6">
<div className="flex flex-col gap-4 border-b border-border pb-5 lg:flex-row lg:items-end lg:justify-between">
<div>
<h1 className="text-3xl font-semibold tracking-normal text-foreground">{t("portal.dashboard.title")}</h1>
{branding.portalWelcomeText ? (
<p className="mt-2 max-w-3xl text-sm text-muted-foreground">{branding.portalWelcomeText}</p>
) : null}
</div>
</div>
<div className="grid gap-4 md:grid-cols-3">
<StatCard label={t("portal.dashboard.activeProjects")} value={String(activeProjects.length)} icon={FolderKanban} tone="blue" />
<StatCard label={t("portal.dashboard.completed")} value={String(completedProjects.length)} icon={CheckCircle2} tone="green" />
<StatCard label={t("portal.dashboard.averageProgress")} value={`%${avgProgress}`} icon={BarChart} tone="amber" />
<StatCard label={t("portal.dashboard.activeProjects")} value={number.format(activeProjects.length)} icon={FolderKanban} tone="blue" />
<StatCard label={t("portal.dashboard.completed")} value={number.format(completedProjects.length)} icon={CheckCircle2} tone="green" />
<StatCard label={t("portal.dashboard.averageProgress")} value={t("portal.labels.percent", { value: number.format(avgProgress) })} icon={BarChart} tone="amber" />
</div>
<div className="space-y-4">
@@ -62,6 +73,9 @@ export default async function PortalDashboardPage() {
<h3 className="font-semibold text-base line-clamp-2 leading-tight">{project.name}</h3>
</div>
</div>
{project.description ? (
<p className="line-clamp-2 text-sm text-muted-foreground">{project.description}</p>
) : null}
<div className="flex items-center gap-2 flex-wrap">
<Badge variant={project.status === "completed" ? "secondary" : "default"} className="capitalize text-[10px] px-1.5 py-0">
{project.status === "completed" ? t("portal.status.project.completed") : project.status === "active" ? t("portal.status.project.active") : t("portal.status.project.waiting")}
@@ -77,7 +91,7 @@ export default async function PortalDashboardPage() {
<div className="space-y-1.5 mt-2">
<div className="flex items-center justify-between text-xs font-medium">
<span className="text-muted-foreground">{t("portal.labels.progress")}</span>
<span>%{project.progress}</span>
<span>{t("portal.labels.percent", { value: number.format(project.progress) })}</span>
</div>
<div className="h-2 w-full bg-secondary rounded-full overflow-hidden">
<div className="h-full bg-primary transition-all duration-500" style={{ width: `${project.progress}%` }} />
@@ -89,6 +103,9 @@ export default async function PortalDashboardPage() {
))}
</div>
</div>
{branding.portalFooterText ? (
<p className="border-t border-border pt-4 text-sm text-muted-foreground">{branding.portalFooterText}</p>
) : null}
</div>
);
}