feat(i18n): complete portal localized surfaces
This commit is contained in:
+21
-4
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,21 +2,28 @@
|
||||
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { cleanText } from "@/server/web/form-data";
|
||||
import { resolvePortalLocale } from "@/server/i18n/resolver";
|
||||
import { requirePortalBackend } from "@/server/web/portal";
|
||||
|
||||
export async function createRevisionRequest(projectId: string, formData: FormData) {
|
||||
try {
|
||||
const { actor, service } = await requirePortalBackend();
|
||||
const { actor, context, service } = await requirePortalBackend();
|
||||
const locale = await resolvePortalLocale(context);
|
||||
const description = cleanText(formData.get("description"));
|
||||
if (!description) return { error: "Revizyon açıklaması boş olamaz." };
|
||||
if (!description) return { errorKey: "portal.revision.errors.descriptionRequired" };
|
||||
|
||||
service.requestRevision(actor, { projectId, description });
|
||||
service.requestRevision(actor, {
|
||||
projectId,
|
||||
description,
|
||||
sourceLocale: locale.locale,
|
||||
});
|
||||
revalidatePath(`/portal/projects/${projectId}`);
|
||||
revalidatePath("/portal/revisions");
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Portal revision request failed", error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : "Revizyon talebi oluşturulamadı.",
|
||||
errorKey: "portal.revision.error",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ export default async function PortalProjectPage({ params }: { params: Promise<{
|
||||
id: revision.id,
|
||||
description: revision.description,
|
||||
status: revision.status,
|
||||
source_locale: revision.sourceLocale,
|
||||
created_at: revision.createdAt.toISOString(),
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -48,6 +48,7 @@ export type PortalTask = {
|
||||
export type PortalRevision = {
|
||||
id: string;
|
||||
description: string;
|
||||
source_locale: string | null;
|
||||
status: "pending" | "in_progress" | "completed" | "rejected";
|
||||
created_at: string;
|
||||
};
|
||||
@@ -78,11 +79,11 @@ export function PortalProjectClient({
|
||||
|
||||
try {
|
||||
const response = await createRevisionRequest(project.id, formData);
|
||||
if (response.error) throw new Error(response.error);
|
||||
if (response.errorKey) throw new Error(response.errorKey);
|
||||
toast.success(t("portal.revision.success"));
|
||||
setOpenRevision(false);
|
||||
} catch (error: unknown) {
|
||||
toast.error(error instanceof Error ? error.message : t("portal.revision.error"));
|
||||
toast.error(error instanceof Error ? t(error.message) : t("portal.revision.error"));
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
@@ -92,12 +93,16 @@ export function PortalProjectClient({
|
||||
(revision) => revision.status === "pending" || revision.status === "in_progress",
|
||||
).length;
|
||||
const hasRevisionQuota = project.can_request_revision;
|
||||
const number = new Intl.NumberFormat(locale);
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex max-w-7xl flex-col gap-8 animate-in fade-in slide-in-from-bottom-4 duration-500">
|
||||
<div className="flex flex-col justify-between gap-4 md:flex-row md:items-start">
|
||||
<div className="space-y-1">
|
||||
<h1 className="text-3xl font-bold text-foreground">{project.name}</h1>
|
||||
{project.description ? (
|
||||
<p className="max-w-3xl text-sm text-muted-foreground">{project.description}</p>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex flex-col gap-2 md:items-end">
|
||||
<div className="flex gap-2">
|
||||
@@ -189,7 +194,7 @@ export function PortalProjectClient({
|
||||
<h3 className="font-semibold">{t("portal.sections.progress")}</h3>
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between text-3xl font-bold">
|
||||
<span>%{project.progress}</span>
|
||||
<span>{t("portal.labels.percent", { value: number.format(project.progress) })}</span>
|
||||
</div>
|
||||
<div className="h-3 w-full overflow-hidden rounded-full bg-secondary">
|
||||
<div className="h-full bg-primary transition-all duration-500" style={{ width: `${project.progress}%` }} />
|
||||
@@ -248,7 +253,7 @@ export function PortalProjectClient({
|
||||
<div className="flex items-center justify-between">
|
||||
<h4 className="font-medium text-foreground">{section.title}</h4>
|
||||
<Badge variant="secondary" className="text-xs">
|
||||
{section.type}
|
||||
{t(`portal.planTypes.${section.type}`)}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="whitespace-pre-wrap text-sm text-muted-foreground">{section.content}</p>
|
||||
@@ -264,7 +269,7 @@ export function PortalProjectClient({
|
||||
<div className="rounded-md bg-muted/50 px-3 py-1.5 text-sm font-medium text-muted-foreground">
|
||||
{t("portal.labels.remainingQuota")}:
|
||||
<span className="ml-1 text-foreground">
|
||||
{project.revision_quota !== null ? project.revision_quota : t("portal.labels.unlimited")}
|
||||
{project.revision_quota !== null ? number.format(project.revision_quota) : t("portal.labels.unlimited")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -23,6 +23,7 @@ export default async function PortalProjectsPage() {
|
||||
defaultLocale: locale.defaultLocale,
|
||||
translations: projectTranslations.get(project.id) ?? [],
|
||||
}));
|
||||
const number = new Intl.NumberFormat(locale.locale);
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex max-w-7xl flex-col gap-8 animate-in fade-in slide-in-from-bottom-4 duration-500">
|
||||
@@ -47,6 +48,9 @@ export default async function PortalProjectsPage() {
|
||||
{project.status === "completed" ? t("portal.status.project.completed") : project.status === "active" ? t("portal.status.project.active") : t("portal.status.project.waiting")}
|
||||
</Badge>
|
||||
</div>
|
||||
{project.description ? (
|
||||
<p className="line-clamp-2 text-sm text-muted-foreground">{project.description}</p>
|
||||
) : null}
|
||||
{project.dueDate && (
|
||||
<div className="flex items-center gap-1.5 text-sm text-muted-foreground">
|
||||
<Clock className="h-4 w-4" />
|
||||
@@ -57,7 +61,7 @@ export default async function PortalProjectsPage() {
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center justify-between text-xs font-medium">
|
||||
<span>{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}%` }} />
|
||||
|
||||
@@ -65,7 +65,7 @@ export default async function PortalRevisionsPage() {
|
||||
</div>
|
||||
<div className="flex items-center justify-end border-t border-border pt-4">
|
||||
<Link href={`/portal/projects/${revision.projectId}`} className="text-xs text-primary font-medium hover:underline">
|
||||
{t("portal.labels.project")} →
|
||||
{t("portal.labels.openProjectCta")}
|
||||
</Link>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
@@ -64,11 +64,14 @@ export default async function PortalTasksPage() {
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground bg-muted/30 p-2 rounded-md">
|
||||
<span className="font-medium truncate">{projectNames.get(task.projectId!)}</span>
|
||||
</div>
|
||||
{task.description ? (
|
||||
<p className="line-clamp-3 text-sm text-muted-foreground">{task.description}</p>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm text-muted-foreground border-t border-border pt-4">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<CalendarDays className="h-4 w-4" />
|
||||
<span>{date ? formatDate(date, locale.locale) : "-"}</span>
|
||||
<span>{date ? formatDate(date, locale.locale) : t("portal.labels.noDate")}</span>
|
||||
</div>
|
||||
{isDone ? <CheckCircle2 className="h-4 w-4 text-emerald-500" /> : <Clock className="h-4 w-4" />}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user