feat(i18n): localize core dashboard flows

This commit is contained in:
poyrazavsever
2026-07-21 12:48:59 +03:00
parent 206484f0eb
commit 8b3de350c7
15 changed files with 395 additions and 351 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ export default async function AnalyticsPage({
}) {
const context = await requireFreelancer();
const resolvedLocale = await resolveFreelancerLocale(context);
const payload = getClientI18nPayload(resolvedLocale.locale, ["analytics"]);
const payload = getClientI18nPayload(resolvedLocale.locale, ["analytics", "common"]);
const params = await searchParams;
const range = parseDashboardRange(params.range);
+5 -11
View File
@@ -123,15 +123,9 @@ export function CalendarClient({ events, clients, projects, tasks, activeLocales
<p className="text-sm text-muted-foreground">{t("common.itemsCount", { count: events.length })}</p>
</div>
<div className="flex gap-2">
<Button effect="shine" type="button" variant="secondary" onClick={() => shiftMonth(-1)}>
Önceki
</Button>
<Button effect="shine" type="button" variant="secondary" onClick={() => setMonthDate(new Date())}>
Bugün
</Button>
<Button effect="shine" type="button" variant="secondary" onClick={() => shiftMonth(1)}>
Sonraki
</Button>
<Button effect="shine" type="button" variant="secondary" onClick={() => shiftMonth(-1)}>{t("calendar.navigation.previous")}</Button>
<Button effect="shine" type="button" variant="secondary" onClick={() => setMonthDate(new Date())}>{t("calendar.navigation.today")}</Button>
<Button effect="shine" type="button" variant="secondary" onClick={() => shiftMonth(1)}>{t("calendar.navigation.next")}</Button>
</div>
</div>
@@ -210,7 +204,7 @@ export function CalendarClient({ events, clients, projects, tasks, activeLocales
<Card>
<CardContent className="space-y-3 p-4">
<h2 className="text-base font-semibold text-foreground">Yaklaşan etkinlikler</h2>
<h2 className="text-base font-semibold text-foreground">{t("calendar.upcoming")}</h2>
<EventList events={upcomingEvents} clients={clients} projects={projects} tasks={tasks} activeLocales={activeLocales} compact />
</CardContent>
</Card>
@@ -237,7 +231,7 @@ function EventList({
}) {
const t = useTranslations();
if (events.length === 0) {
return <p className="text-sm text-muted-foreground">Etkinlik yok.</p>;
return <p className="text-sm text-muted-foreground">{t("calendar.noEvents")}</p>;
}
return (
+2 -2
View File
@@ -20,7 +20,7 @@ function buildTranslations(rows: ContentTranslationRow[] | undefined) {
export default async function CalendarPage() {
const { context, actor, service } = await requireFreelancerBackend();
const resolvedLocale = await resolveFreelancerLocale(context);
const payload = getClientI18nPayload(resolvedLocale.locale, ["calendar"]);
const payload = getClientI18nPayload(resolvedLocale.locale, ["calendar", "common"]);
const i18n = new I18nService(getSqliteConnection().db);
const activeLocales = i18n.listLocales(actor).filter(l => l.status !== "archived").map(l => ({ code: l.code, name: l.nativeName }));
@@ -61,7 +61,7 @@ export default async function CalendarPage() {
.map(({ id, title }) => ({ id, title }));
return (
<I18nProvider payload={payload}>
<I18nProvider {...payload}>
<CalendarClient events={events} clients={clientOptions} projects={projectOptions} tasks={taskOptions} activeLocales={activeLocales} />
</I18nProvider>
);
+1 -1
View File
@@ -22,7 +22,7 @@ export async function addClientActivity(clientId: string, formData: FormData) {
service.addClientActivity(actor, {
clientId,
type,
title: defaultTitle || requiredText(formData.get("title"), "Aktivite başlığı zorunludur."),
title: defaultTitle || requiredText(formData.get("title"), "clients.detail.activityTitleRequired"),
content: defaultContent || cleanText(formData.get("content")),
activityDate: optionalDate(formData.get("activity_date")) ?? new Date(),
translations,
@@ -22,6 +22,7 @@ export type ClientDetailData = {
notes: string | null;
client_auth_id: string | null;
portal_locale: string;
translations?: Record<string, Record<string, string>>;
};
export type ClientActivity = {
@@ -38,10 +39,12 @@ export function ClientDetailClient({
client,
activities,
locales,
currentLocale,
}: {
client: ClientDetailData;
activities: ClientActivity[];
locales: Array<{ code: string; nativeName: string; name: string }>;
currentLocale: string;
}) {
const [isAddingActivity, setIsAddingActivity] = useState(false);
const [openDialog, setOpenDialog] = useState(false);
@@ -95,13 +98,13 @@ export function ClientDetailClient({
});
const data = await res.json();
if (!res.ok || data.error) {
throw new Error(data.error || "Kullanıcı oluşturulamadı.");
throw new Error(data.error || "clients.detail.portalInviteFailed");
}
setInvitationUrl(data.invitation.invitationUrl);
setPortalLocale(data.invitation.locale ?? locale);
toast.success("Güvenli portal daveti oluşturuldu.");
toast.success(t("clients.detail.portalInviteCreated"));
} catch (error: unknown) {
toast.error(error instanceof Error ? error.message : "Davet oluşturulamadı.");
toast.error(resolveTranslatedError(t, error, "clients.detail.portalInviteFailed"));
} finally {
setIsCreatingUser(false);
}
@@ -116,11 +119,11 @@ export function ClientDetailClient({
body: JSON.stringify({ locale: nextLocale }),
});
const data = await response.json();
if (!response.ok || data.error) throw new Error(data.error || "Portal dili güncellenemedi.");
toast.success("Portal dili güncellendi.");
if (!response.ok || data.error) throw new Error(data.error || "clients.detail.portalLocaleUpdateFailed");
toast.success(t("clients.detail.portalLocaleUpdated"));
} catch (error) {
setPortalLocale(client.portal_locale);
toast.error(error instanceof Error ? error.message : "Portal dili güncellenemedi.");
toast.error(resolveTranslatedError(t, error, "clients.detail.portalLocaleUpdateFailed"));
}
}
@@ -151,21 +154,21 @@ export function ClientDetailClient({
<DialogContent>
<form onSubmit={handleCreateUser}>
<DialogHeader>
<DialogTitle>Müşteri Portalına Davet Et</DialogTitle>
<DialogTitle>{t("clients.detail.invitePortal")}</DialogTitle>
<DialogDescription>
Müşterin bağlantıyı açıp kendi şifresini belirler. Davet 72 saat geçerlidir ve yalnızca bir kez kullanılabilir.
{t("clients.detail.portalInviteDescription")}
</DialogDescription>
</DialogHeader>
<div className="space-y-4 py-4">
<div className="space-y-2">
<Label htmlFor="email">{t("clients.detail.email")}</Label>
<Label htmlFor="email">{t("clients.form.email")}</Label>
<Input id="email" name="email" type="email" required defaultValue={client.email || ""} />
</div>
<div className="space-y-2">
<Label>{t("clients.detail.portalLocale")}</Label>
<Select name="locale" defaultValue={portalLocale}>
<SelectTrigger>
<SelectValue placeholder="Dil seç" />
<SelectValue placeholder={t("clients.detail.portalLocalePlaceholder")} />
</SelectTrigger>
<SelectContent>
{locales.map((locale) => (
@@ -178,31 +181,31 @@ export function ClientDetailClient({
</div>
{invitationUrl ? (
<div className="space-y-2">
<Label htmlFor="invitation-url">Davet bağlantısı</Label>
<Label htmlFor="invitation-url">{t("clients.detail.invitationUrl")}</Label>
<div className="flex gap-2">
<Input id="invitation-url" value={invitationUrl} readOnly />
<Button effect="shine"
type="button"
variant="secondary"
size="icon"
aria-label="Davet bağlantısını kopyala"
aria-label={t("clients.detail.copyInvitationUrl")}
onClick={async () => {
await navigator.clipboard.writeText(invitationUrl);
toast.success("Davet bağlantısı kopyalandı.");
toast.success(t("clients.detail.invitationUrlCopied"));
}}
>
<Copy className="h-4 w-4" />
</Button>
</div>
<p className="text-xs text-muted-foreground">Bağlantı yalnızca bu ekranda düz metin olarak gösterilir.</p>
<p className="text-xs text-muted-foreground">{t("clients.detail.invitationUrlHelp")}</p>
</div>
) : null}
</div>
<DialogFooter>
<Button effect="shine" type="button" variant="secondary" onClick={() => setCreateUserOpen(false)}>İptal</Button>
<Button effect="shine" type="button" variant="secondary" onClick={() => setCreateUserOpen(false)}>{t("clients.form.cancel")}</Button>
<Button variant="default" effect="shine" type="submit" disabled={isCreatingUser || Boolean(invitationUrl)}>
{isCreatingUser && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
Davet Oluştur
{t("clients.detail.createInvitation")}
</Button>
</DialogFooter>
</form>
@@ -216,7 +219,7 @@ export function ClientDetailClient({
</Badge>
<Select value={portalLocale} onValueChange={handlePortalLocaleChange}>
<SelectTrigger className="h-9 w-36">
<SelectValue placeholder="Portal dili" />
<SelectValue placeholder={t("clients.detail.portalLocalePlaceholder")} />
</SelectTrigger>
<SelectContent>
{locales.map((locale) => (
@@ -259,7 +262,7 @@ export function ClientDetailClient({
</div>
) : null}
{!client.email && !client.phone && !client.website && (
<p className="text-muted-foreground italic">İletişim bilgisi girilmemiş.</p>
<p className="text-muted-foreground italic">{t("clients.detail.noContact")}</p>
)}
</div>
</CardContent>
@@ -271,7 +274,7 @@ export function ClientDetailClient({
{client.notes ? (
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{client.notes}</p>
) : (
<p className="text-sm text-muted-foreground italic">Müşteriye ait genel not bulunmuyor.</p>
<p className="text-sm text-muted-foreground italic">{t("clients.detail.noNotes")}</p>
)}
</CardContent>
</Card>
@@ -282,7 +285,7 @@ export function ClientDetailClient({
<Card>
<CardContent className="p-5">
<div className="flex items-center justify-between mb-6">
<h3 className="font-semibold text-foreground">Aktivite Geçmişi</h3>
<h3 className="font-semibold text-foreground">{t("clients.detail.activityHistory")}</h3>
<Dialog open={openDialog} onOpenChange={setOpenDialog}>
<DialogTrigger asChild>
@@ -308,10 +311,6 @@ export function ClientDetailClient({
</SelectContent>
</Select>
</div>
<div className="grid gap-2">
<Label>Başlık</Label>
<Input name="title" required placeholder="Aktivite özeti" />
</div>
<div className="grid gap-2">
<Label>{t("clients.detail.activityDate")}</Label>
<Input name="activity_date" type="datetime-local" required defaultValue={new Date().toISOString().slice(0, 16)} />
@@ -362,14 +361,14 @@ export function ClientDetailClient({
<Card className="w-[calc(100%-4rem)] md:w-[calc(50%-2.5rem)] hover:border-primary/50 transition-colors">
<CardContent className="p-4">
<div className="flex justify-between items-start mb-2">
<h4 className="font-semibold text-foreground">{activity.translations?.[locales[0].code]?.title ?? activity.title}</h4>
<h4 className="font-semibold text-foreground">{activity.translations?.[currentLocale]?.title ?? activity.title}</h4>
{getActivityBadge(activity.type)}
</div>
<time className="text-xs text-muted-foreground block mb-2 font-medium">
{format(new Date(activity.activity_date), "d MMM yyyy, HH:mm", { locale: getDocumentDateFnsLocale() })}
</time>
{(activity.translations?.[locales[0].code]?.content ?? activity.content) && (
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{activity.translations?.[locales[0].code]?.content ?? activity.content}</p>
{(activity.translations?.[currentLocale]?.content ?? activity.content) && (
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{activity.translations?.[currentLocale]?.content ?? activity.content}</p>
)}
</CardContent>
</Card>
@@ -384,3 +383,13 @@ export function ClientDetailClient({
</div>
);
}
function resolveTranslatedError(
t: ReturnType<typeof useTranslations>,
error: unknown,
fallbackKey: string,
) {
if (!(error instanceof Error)) return t(fallbackKey);
if (/^clients\./.test(error.message)) return t(error.message);
return error.message || t(fallbackKey);
}
+5 -5
View File
@@ -27,12 +27,12 @@ export default async function ClientDetailPage({ params }: { params: Promise<{ i
const defaultLocale = i18n.getSettings(actor).defaultLocale;
const resolvedLocale = await resolveFreelancerLocale(context);
const payload = getClientI18nPayload(resolvedLocale.locale, ["clients"]);
const payload = getClientI18nPayload(resolvedLocale.locale, ["clients", "common"]);
let data: { client: ClientDetailData; activities: ClientActivity[] };
try {
const row = service.getClient(actor, id);
const clientTranslations = service.contentTranslations.list("client", id);
const clientTranslationsMap = service.contentTranslations.listBatch("client", [id]);
const client: ClientDetailData = {
id: row.id,
@@ -46,7 +46,7 @@ export default async function ClientDetailPage({ params }: { params: Promise<{ i
notes: row.notes,
client_auth_id: row.authUserId,
portal_locale: row.portalLocale ?? defaultLocale,
translations: buildTranslations(clientTranslations),
translations: buildTranslations(clientTranslationsMap.get(id) ?? []),
};
const rawActivities = service.listClientActivities(actor, id);
@@ -69,8 +69,8 @@ export default async function ClientDetailPage({ params }: { params: Promise<{ i
}
return (
<I18nProvider payload={payload}>
<ClientDetailClient client={data.client} activities={data.activities} locales={locales} />
<I18nProvider {...payload}>
<ClientDetailClient client={data.client} activities={data.activities} locales={locales} currentLocale={resolvedLocale.locale} />
</I18nProvider>
);
}
+3 -4
View File
@@ -621,15 +621,14 @@ function PhoneInput({ id, name, defaultValue }: { id: string; name: string; defa
}
function EmptyState({ hasQuery }: { hasQuery: boolean }) {
const t = useTranslations();
return (
<div className="flex min-h-72 flex-col items-center justify-center rounded-sm border border-dashed border-border bg-muted/20 p-8 text-center">
<Users className="h-10 w-10 text-muted-foreground" />
<h3 className="mt-4 text-lg font-semibold text-foreground">
{hasQuery ? "Aramana uygun müşteri yok" : "Henüz müşteri eklenmedi"}
{hasQuery ? t("clients.empty.noMatchTitle") : t("clients.empty.noClientTitle")}
</h3>
<p className="mt-2 max-w-md text-sm text-muted-foreground">
İlk müşterini ekleyerek potansiyel satışlarını takip etmeye başla.
</p>
<p className="mt-2 max-w-md text-sm text-muted-foreground">{t("clients.empty.noClientDesc")}</p>
</div>
);
}
+2 -2
View File
@@ -20,7 +20,7 @@ function buildTranslations(rows: ContentTranslationRow[] | undefined) {
export default async function ClientsPage() {
const { context, actor, service } = await requireFreelancerBackend();
const resolvedLocale = await resolveFreelancerLocale(context);
const payload = getClientI18nPayload(resolvedLocale.locale, ["clients"]);
const payload = getClientI18nPayload(resolvedLocale.locale, ["clients", "common"]);
const i18n = new I18nService(getSqliteConnection().db);
const activeLocales = i18n.listLocales(actor).filter(l => l.status !== "archived").map(l => ({ code: l.code, name: l.nativeName }));
@@ -78,7 +78,7 @@ export default async function ClientsPage() {
});
return (
<I18nProvider payload={payload}>
<I18nProvider {...payload}>
<ClientsClient
clients={clients}
totalRevenue={clients.reduce((sum, client) => sum + client.revenueTotal, 0)}
+1 -1
View File
@@ -15,7 +15,7 @@ export default async function DashboardPage({
}) {
const context = await requireFreelancer();
const resolvedLocale = await resolveFreelancerLocale(context);
const payload = getClientI18nPayload(resolvedLocale.locale, ["dashboard"]);
const payload = getClientI18nPayload(resolvedLocale.locale, ["dashboard", "common"]);
const params = await searchParams;
const range = parseDashboardRange(params.range);
+17 -10
View File
@@ -12,11 +12,14 @@ import { DomainError } from "@/server/domain/errors";
import { ContentTranslationService, type ContentTranslationRow } from "@/server/i18n/content";
import { resolveFreelancerLocale } from "@/server/i18n/resolver";
import { requireFreelancerBackend } from "@/server/web/freelancer";
import { getClientI18nPayload } from "@/server/i18n/translator";
import { I18nProvider } from "@/components/i18n/i18n-provider";
export default async function ProjectDetailPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const locale = await resolveFreelancerLocale();
const { actor, service } = await requireFreelancerBackend();
const { context, actor, service } = await requireFreelancerBackend();
const locale = await resolveFreelancerLocale(context);
const payload = getClientI18nPayload(locale.locale, ["projects", "tasks", "common"]);
const content = new ContentTranslationService(getSqliteConnection().db);
const localization = content.getLocalizationContext(actor);
@@ -120,15 +123,19 @@ export default async function ProjectDetailPage({ params }: { params: Promise<{
throw error;
}
const i18nPayload = await getClientI18nPayload(locale.locale, ["projects", "tasks", "common"]);
return (
<ProjectDetailClient
project={data.project}
sections={data.sections}
tasks={data.tasks}
financeTransactions={data.financeTransactions}
revisions={data.revisions}
localization={localization}
/>
<I18nProvider {...i18nPayload}>
<ProjectDetailClient
project={data.project}
sections={data.sections}
tasks={data.tasks}
financeTransactions={data.financeTransactions}
revisions={data.revisions}
localization={localization}
/>
</I18nProvider>
);
}
@@ -12,6 +12,7 @@ import {
updateTaskStatusRecord,
} from "@/app/(dashboard)/tasks/actions";
import { LocalizedFields, type LocalizedFieldLocale, type LocalizedFieldValues } from "@/components/i18n/localized-fields";
import { useTranslations } from "@/components/i18n/i18n-provider";
import { PendingLink } from "@/components/ui/pending-link";
import { PendingSubmitButton } from "@/components/ui/pending-submit-button";
import { contentTranslationRegistry } from "@/lib/i18n/content";
@@ -132,19 +133,6 @@ type ProjectDetailClientProps = {
};
};
const typeLabels = {
client_project: "Müşteri projesi",
side_project: "Side project",
};
const statusLabels = {
planning: "Planlama",
active: "Aktif",
paused: "Duraklatıldı",
completed: "Tamamlandı",
cancelled: "İptal edildi",
};
const statusClasses = {
planning: "border-blue-200 bg-blue-50 text-blue-700",
active: "border-emerald-200 bg-emerald-50 text-emerald-700",
@@ -160,18 +148,18 @@ const priorityClasses = {
urgent: "border-rose-200 bg-rose-50 text-rose-700",
};
const sectionLabels: Record<ProjectPlanningSectionItem["category"], string> = {
overview: "Genel bakış",
problem: "Çözdüğü problem",
goal: "Amaç",
audience: "Hedef kitle",
scope: "Kapsam",
design_system: "Design system",
color_palette: "Renk paleti",
typography: "Tipografi",
assets: "Görsel varlıklar",
notes: "Notlar",
};
const sectionCategoryOptions: ProjectPlanningSectionItem["category"][] = [
"overview",
"problem",
"goal",
"audience",
"scope",
"design_system",
"color_palette",
"typography",
"assets",
"notes",
];
const planningCategories: ProjectPlanningSectionItem["category"][] = [
"overview",
@@ -197,6 +185,7 @@ export function ProjectDetailClient({
revisions,
localization,
}: ProjectDetailClientProps) {
const t = useTranslations();
const [activeTab, setActiveTab] = useState<"planning" | "design" | "tasks" | "finance" | "revisions">(
"planning",
);
@@ -221,7 +210,7 @@ export function ProjectDetailClient({
<Button size="sm" effect="shine" asChild variant="secondary" className="gap-2 px-0 text-muted-foreground">
<PendingLink href="/projects" className="flex items-center gap-2" showSpinner>
<ArrowLeft className="h-4 w-4" />
Projelere dön
{t("projects.detail.backToProjects")}
</PendingLink>
</Button>
<div>
@@ -230,7 +219,7 @@ export function ProjectDetailClient({
{project.name}
</h1>
<Badge className={statusClasses[project.status]}>
{statusLabels[project.status]}
{t(`projects.status.${project.status}`)}
</Badge>
</div>
</div>
@@ -246,9 +235,9 @@ export function ProjectDetailClient({
variant="secondary"
className="gap-2"
idleIcon={<CheckCircle2 className="h-4 w-4" />}
pendingChildren="Tamamlanıyor"
pendingChildren={t("projects.detail.completing")}
>
Tamamla
{t("projects.detail.complete")}
</PendingSubmitButton>
</form>
) : null}
@@ -271,27 +260,27 @@ export function ProjectDetailClient({
</div>
) : (
<div className="flex aspect-[16/7] items-center justify-center rounded-t-sm border-b border-dashed border-border bg-muted/30 text-muted-foreground">
Kapak görseli yok
{t("projects.card.noCover")}
</div>
)}
<div className="grid gap-4 p-5 md:grid-cols-2">
<InfoItem label="Tür" value={typeLabels[project.type]} icon={FolderKanban} />
<InfoItem label={t("projects.detail.type")} value={t(`projects.types.${project.type}`)} icon={FolderKanban} />
<InfoItem
label="Müşteri"
value={project.clientName || "Bağımsız side project"}
label={t("projects.detail.client")}
value={project.clientName || t("projects.detail.independent")}
icon={Target}
/>
<InfoItem
label="Deadline"
value={project.due_date ? formatDate(project.due_date) : "Deadline yok"}
label={t("projects.detail.deadline")}
value={project.due_date ? formatDate(project.due_date) : t("projects.detail.noDeadline")}
icon={CalendarDays}
/>
<InfoItem
label="Bütçe"
label={t("projects.detail.budget")}
value={
project.budget_amount
? formatCurrency(project.budget_amount, project.currency)
: "Bütçe yok"
: t("projects.detail.noBudget")
}
icon={Wallet}
/>
@@ -300,10 +289,10 @@ export function ProjectDetailClient({
</Card>
<div className="grid gap-4">
<StatCard label="İlerleme" value={`${project.progress}%`} icon={Target} />
<StatCard label="Görev" value={`${doneTaskCount}/${tasks.length}`} icon={ClipboardList} />
<StatCard label={t("projects.detail.progressLabel")} value={`${project.progress}%`} icon={Target} />
<StatCard label={t("projects.detail.taskLabel")} value={`${doneTaskCount}/${tasks.length}`} icon={ClipboardList} />
<StatCard
label="Net finans"
label={t("projects.detail.netFinance")}
value={formatCurrency(incomeTotal - expenseTotal, project.currency)}
icon={Wallet}
/>
@@ -312,19 +301,19 @@ export function ProjectDetailClient({
<div className="flex flex-wrap gap-2 rounded-sm border border-border p-1">
<TabButton active={activeTab === "planning"} onClick={() => setActiveTab("planning")}>
Planlama
{t("projects.detail.planning")}
</TabButton>
<TabButton active={activeTab === "design"} onClick={() => setActiveTab("design")}>
Design system
{t("projects.detail.designSystem")}
</TabButton>
<TabButton active={activeTab === "tasks"} onClick={() => setActiveTab("tasks")}>
Görevler
{t("projects.detail.tasks")}
</TabButton>
<TabButton active={activeTab === "finance"} onClick={() => setActiveTab("finance")}>
Finans
{t("projects.detail.finance")}
</TabButton>
<TabButton active={activeTab === "revisions"} onClick={() => setActiveTab("revisions")}>
Revizyonlar
{t("projects.detail.revisions")}
{revisions.filter(r => r.status === 'pending').length > 0 && (
<Badge variant="secondary" className="ml-2 px-1 py-0 h-4 text-[10px]">
{revisions.filter(r => r.status === 'pending').length}
@@ -336,8 +325,8 @@ export function ProjectDetailClient({
{activeTab === "planning" ? (
<SectionGrid
projectId={project.id}
title="Planlama alanları"
description="Problem, amaç, hedef kitle, kapsam ve proje notlarını burada tut."
title={t("projects.detail.planningTitle")}
description={t("projects.detail.planningDesc")}
sections={planningSections}
defaultCategory="overview"
localization={localization}
@@ -347,8 +336,8 @@ export function ProjectDetailClient({
{activeTab === "design" ? (
<SectionGrid
projectId={project.id}
title="Design system"
description="Renk paleti, tipografi, görsel dil ve asset notlarını proje kaynağına bağla."
title={t("projects.detail.designTitle")}
description={t("projects.detail.designDesc")}
sections={designSections}
defaultCategory="design_system"
localization={localization}
@@ -371,6 +360,7 @@ function RevisionsPanel({
projectId: string;
revisions: ProjectRevisionItem[];
}) {
const t = useTranslations();
const [isUpdating, setIsUpdating] = useState(false);
async function handleStatusChange(
@@ -395,9 +385,9 @@ function RevisionsPanel({
return (
<Card>
<CardContent className="space-y-4 p-5">
<h2 className="text-lg font-semibold">Müşteri Revizyon Talepleri</h2>
<h2 className="text-lg font-semibold">{t("projects.detail.revisionsTitle")}</h2>
{revisions.length === 0 ? (
<p className="text-muted-foreground text-sm">Bu proje için henüz bir revizyon talebi oluşturulmamış.</p>
<p className="text-muted-foreground text-sm">{t("projects.detail.revisionsEmpty")}</p>
) : (
<div className="space-y-4">
{revisions.map(rev => (
@@ -420,10 +410,10 @@ function RevisionsPanel({
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="pending">Bekliyor</SelectItem>
<SelectItem value="in_progress">İşleniyor</SelectItem>
<SelectItem value="completed">Tamamlandı</SelectItem>
<SelectItem value="rejected">Reddedildi</SelectItem>
<SelectItem value="pending">{t("projects.status.pending")}</SelectItem>
<SelectItem value="in_progress">{t("projects.status.in_progress")}</SelectItem>
<SelectItem value="completed">{t("projects.status.completed")}</SelectItem>
<SelectItem value="rejected">{t("projects.status.rejected")}</SelectItem>
</SelectContent>
</Select>
</div>
@@ -452,6 +442,7 @@ function SectionGrid({
defaultCategory: ProjectPlanningSectionItem["category"];
localization: ProjectDetailClientProps["localization"];
}) {
const t = useTranslations();
return (
<Card>
<CardContent className="space-y-4 p-5">
@@ -472,10 +463,9 @@ function SectionGrid({
) : (
<div className="flex min-h-52 flex-col items-center justify-center rounded-sm border border-dashed border-border bg-muted/20 p-8 text-center">
<FileText className="h-9 w-9 text-muted-foreground" />
<h3 className="mt-4 text-base font-semibold text-foreground">Henüz kayıt yok</h3>
<h3 className="mt-4 text-base font-semibold text-foreground">{t("projects.detail.noRecords")}</h3>
<p className="mt-1 max-w-md text-sm text-muted-foreground">
Bu proje için ilk planlama veya design system alanını ekleyerek proje bilgisini
görevlerden bağımsız hale getir.
{t("projects.detail.noRecordsDesc")}
</p>
</div>
)}
@@ -491,12 +481,13 @@ function PlanningSectionCard({
section: ProjectPlanningSectionItem;
localization: ProjectDetailClientProps["localization"];
}) {
const t = useTranslations();
return (
<Card className="transition-colors hover:border-primary/30">
<CardContent className="flex h-full flex-col gap-4 p-4">
<div className="flex items-start justify-between gap-3">
<div className="min-w-0">
<Badge>{sectionLabels[section.category]}</Badge>
<Badge>{t(`projects.sections.${section.category}`)}</Badge>
<h3 className="mt-3 text-base font-semibold text-foreground">{section.title}</h3>
</div>
<div className="flex gap-2">
@@ -508,13 +499,13 @@ function PlanningSectionCard({
variant="secondary"
className="px-3 text-rose-600"
idleIcon={<Trash2 className="h-4 w-4" />}
aria-label="Sil"
aria-label={t("projects.detail.delete")}
/>
</form>
</div>
</div>
<p className="whitespace-pre-wrap text-sm leading-6 text-muted-foreground">
{section.content || "İçerik eklenmedi."}
{section.content || t("projects.detail.noContent")}
</p>
</CardContent>
</Card>
@@ -534,6 +525,7 @@ function SectionDialog({
section?: ProjectPlanningSectionItem;
localization: ProjectDetailClientProps["localization"];
}) {
const t = useTranslations();
const [open, setOpen] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const action =
@@ -560,7 +552,7 @@ function SectionDialog({
className="gap-2 px-3"
>
{mode === "create" ? <Plus className="h-4 w-4" /> : <Pencil className="h-4 w-4" />}
{mode === "create" ? "Alan ekle" : null}
{mode === "create" ? t("projects.detail.addPlan") : null}
</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-xl">
@@ -569,24 +561,24 @@ function SectionDialog({
{section ? <input type="hidden" name="id" value={section.id} /> : null}
<DialogHeader>
<DialogTitle>
{mode === "create" ? "Planlama alanı ekle" : "Planlama alanını düzenle"}
{mode === "create" ? t("projects.detail.planCreateTitle") : t("projects.detail.planEditTitle")}
</DialogTitle>
<DialogDescription>
Projenin görev dışı bilgisini yapılandırılmış alanlarda sakla.
{t("projects.detail.planDesc")}
</DialogDescription>
</DialogHeader>
<div className="grid gap-4">
<div className="grid gap-2">
<Label>Kategori</Label>
<Label>{t("projects.detail.category")}</Label>
<Select name="category" defaultValue={section?.category || defaultCategory || "overview"}>
<SelectTrigger>
<SelectValue placeholder="Kategori seç" />
<SelectValue placeholder={t("projects.detail.categorySelect")} />
</SelectTrigger>
<SelectContent>
{Object.entries(sectionLabels).map(([value, label]) => (
{sectionCategoryOptions.map((value) => (
<SelectItem key={value} value={value}>
{label}
{t(`projects.sections.${value}`)}
</SelectItem>
))}
</SelectContent>
@@ -596,7 +588,13 @@ function SectionDialog({
idPrefix={`section-${section?.id || "new"}`}
defaultLocale={localization.defaultLocale}
locales={localization.locales}
fields={contentTranslationRegistry.planning_section}
fields={contentTranslationRegistry.planning_section.map((field) => ({
...field,
label: t(`projects.detail.planFields.${field.name}`),
placeholder: "placeholder" in field && typeof field.placeholder === "string"
? t(`projects.detail.planPlaceholders.${field.name}`)
: undefined,
}))}
values={section?.translations}
fallbackValues={{
title: section?.title,
@@ -604,7 +602,7 @@ function SectionDialog({
}}
/>
<div className="grid gap-2">
<Label htmlFor={`section-order-${section?.id || "new"}`}>Sıra</Label>
<Label htmlFor={`section-order-${section?.id || "new"}`}>{t("projects.detail.sortOrder")}</Label>
<Input
id={`section-order-${section?.id || "new"}`}
name="sort_order"
@@ -616,7 +614,7 @@ function SectionDialog({
<DialogFooter>
<Button variant="default" effect="shine" type="submit" disabled={isSubmitting} className="gap-2">
{isSubmitting ? "Kaydediliyor" : "Kaydet"}
{isSubmitting ? t("projects.detail.saving") : t("projects.detail.save")}
</Button>
</DialogFooter>
</form>
@@ -636,6 +634,7 @@ function TaskPanel({
tasks: ProjectDetailTaskItem[];
localization: ProjectDetailClientProps["localization"];
}) {
const t = useTranslations();
const [view, setView] = useState<"list" | "kanban">("list");
const [statusOverrides, setStatusOverrides] = useState<
Partial<Record<string, ProjectDetailTaskItem["status"]>>
@@ -665,7 +664,7 @@ function TaskPanel({
toast.error(
error instanceof Error
? error.message
: "Görev durumu güncellenemedi.",
: t("projects.detail.taskUpdateFailed"),
);
})
.finally(() => {
@@ -693,9 +692,9 @@ function TaskPanel({
<CardContent className="space-y-4 p-5">
<div className="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
<div>
<h2 className="text-lg font-semibold text-foreground">Proje görevleri</h2>
<h2 className="text-lg font-semibold text-foreground">{t("projects.detail.tasksTitle")}</h2>
<p className="mt-1 text-sm text-muted-foreground">
Bu proje ile bağlantılı görevler aynı task modülünden beslenir.
{t("projects.detail.tasksDesc")}
</p>
</div>
<div className="flex flex-col gap-2 sm:flex-row">
@@ -707,7 +706,7 @@ function TaskPanel({
onClick={() => setView("list")}
>
<LayoutList className="h-4 w-4" />
Liste
{t("projects.detail.list")}
</Button>
<Button size="sm" effect="shine"
type="button"
@@ -716,7 +715,7 @@ function TaskPanel({
onClick={() => setView("kanban")}
>
<KanbanSquare className="h-4 w-4" />
Kanban
{t("projects.detail.kanban")}
</Button>
</div>
<ProjectTaskDialog projectId={projectId} clientId={clientId} localization={localization} />
@@ -726,10 +725,10 @@ function TaskPanel({
{localTasks.length > 0 && view === "list" ? (
<div className="overflow-hidden rounded-sm border border-border">
<div className="hidden grid-cols-[1.5fr_0.8fr_0.8fr_0.8fr] gap-4 border-b border-border bg-muted/40 px-4 py-3 text-xs font-medium uppercase text-muted-foreground lg:grid">
<span>Görev</span>
<span>Öncelik</span>
<span>Son tarih</span>
<span className="text-right">İşlem</span>
<span>{t("projects.detail.colTask")}</span>
<span>{t("projects.detail.colPriority")}</span>
<span>{t("projects.detail.colDue")}</span>
<span className="text-right">{t("projects.detail.colAction")}</span>
</div>
<div className="divide-y divide-border">
{localTasks.map((task) => (
@@ -749,22 +748,18 @@ function TaskPanel({
{task.title}
</div>
{task.is_public_to_client && (
<Badge variant="outline" className="h-5 px-1.5 text-[10px] text-emerald-600 border-emerald-200 bg-emerald-50">Müşteriye Açık</Badge>
<Badge variant="outline" className="h-5 px-1.5 text-[10px] text-emerald-600 border-emerald-200 bg-emerald-50">{t("projects.detail.taskPublic")}</Badge>
)}
</div>
<div className="text-sm text-muted-foreground">
{task.status === "done"
? "Tamamlandı"
: task.status === "in_progress"
? "Devam ediyor"
: "Yapılacak"}
{t(`projects.status.${task.status}`)}
</div>
</div>
<div>
<Badge className={priorityClasses[task.priority]}>{task.priority}</Badge>
<Badge className={priorityClasses[task.priority]}>{t(`tasks.priority.${task.priority}`)}</Badge>
</div>
<div className="text-sm text-muted-foreground">
{task.due_at ? formatDateTime(task.due_at) : "Yok"}
{task.due_at ? formatDateTime(task.due_at) : t("projects.detail.taskNone")}
</div>
<div className="flex justify-start lg:justify-end">
{task.status !== "done" ? (
@@ -781,7 +776,7 @@ function TaskPanel({
) : (
<CheckCircle2 className="h-4 w-4" />
)}
{pendingTaskIds.has(task.id) ? "Tamamlanıyor" : "Tamamla"}
{pendingTaskIds.has(task.id) ? t("projects.detail.completing") : t("projects.detail.complete")}
</Button>
) : null}
</div>
@@ -800,7 +795,7 @@ function TaskPanel({
) : null}
{localTasks.length === 0 ? (
<EmptyPanel icon={ClipboardList} title="Bu projeye bağlı görev yok" />
<EmptyPanel icon={ClipboardList} title={t("projects.detail.noTasks")} />
) : null}
</CardContent>
</Card>
@@ -816,6 +811,7 @@ function ProjectTaskKanban({
pendingTaskIds: Set<string>;
onTaskStatusChange: (taskId: string, status: ProjectDetailTaskItem["status"]) => void;
}) {
const t = useTranslations();
const columns = ["todo", "in_progress", "done"] as const;
const [draggedTaskId, setDraggedTaskId] = useState<string | null>(null);
@@ -850,7 +846,7 @@ function ProjectTaskKanban({
>
<div className="mb-3 flex items-center justify-between">
<h3 className="text-sm font-semibold text-foreground">
{getTaskStatusLabel(status)}
{t(`projects.status.${status}`)}
</h3>
<Badge>{columnTasks.length}</Badge>
</div>
@@ -871,11 +867,11 @@ function ProjectTaskKanban({
<div>
<div className="font-medium text-foreground">{task.title}</div>
<div className="text-sm text-muted-foreground">
{task.due_at ? formatDateTime(task.due_at) : "Son tarih yok"}
{task.due_at ? formatDateTime(task.due_at) : t("projects.detail.noDeadline")}
</div>
</div>
<div className="flex items-center justify-between gap-2">
<Badge className={priorityClasses[task.priority]}>{task.priority}</Badge>
<Badge className={priorityClasses[task.priority]}>{t(`tasks.priority.${task.priority}`)}</Badge>
{task.status !== "done" ? (
<Button
size="icon-sm"
@@ -884,8 +880,8 @@ function ProjectTaskKanban({
variant="secondary"
disabled={pendingTaskIds.has(task.id)}
aria-busy={pendingTaskIds.has(task.id)}
title="Tamamla"
aria-label="Tamamla"
title={t("projects.detail.complete")}
aria-label={t("projects.detail.complete")}
onClick={() => onTaskStatusChange(task.id, "done")}
>
{pendingTaskIds.has(task.id) ? (
@@ -908,6 +904,7 @@ function ProjectTaskKanban({
}
function ProjectSettingsDialog({ project }: { project: ProjectDetail }) {
const t = useTranslations();
const [open, setOpen] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const [progressType, setProgressType] = useState<"manual" | "auto">(project.progress_type);
@@ -932,35 +929,35 @@ function ProjectSettingsDialog({ project }: { project: ProjectDetail }) {
<DialogTrigger asChild>
<Button effect="shine" variant="secondary" className="gap-2 px-3">
<Settings2 className="h-4 w-4" />
<span className="hidden sm:inline">Ayarlar</span>
<span className="hidden sm:inline">{t("projects.detail.settings")}</span>
</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
<form action={handleSubmit} className="space-y-5">
<DialogHeader>
<DialogTitle>Proje ayarları</DialogTitle>
<DialogTitle>{t("projects.detail.settingsTitle")}</DialogTitle>
<DialogDescription>
İlerleme hesaplama yöntemi ve revizyon kotasını belirle.
{t("projects.detail.settingsDesc")}
</DialogDescription>
</DialogHeader>
<div className="grid gap-4">
<div className="grid gap-2">
<Label>İlerleme Hesaplama</Label>
<Label>{t("projects.detail.progressType")}</Label>
<Select value={progressType} onValueChange={(val: "manual" | "auto") => setProgressType(val)}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="manual">Manuel (Elle girilir)</SelectItem>
<SelectItem value="auto">Otomatik (Görevlere göre)</SelectItem>
<SelectItem value="manual">{t("projects.detail.progressManual")}</SelectItem>
<SelectItem value="auto">{t("projects.detail.progressAuto")}</SelectItem>
</SelectContent>
</Select>
</div>
{progressType === "manual" && (
<div className="grid gap-2">
<Label>İlerleme Durumu (%)</Label>
<Label>{t("projects.detail.progressValue")}</Label>
<div className="flex items-center gap-4">
<input
type="range"
@@ -975,24 +972,24 @@ function ProjectSettingsDialog({ project }: { project: ProjectDetail }) {
</div>
)}
{progressType === "auto" && (
<p className="text-xs text-muted-foreground">İlerleme yüzdesi &quot;Görevler&quot; sekmesindeki görevlerin tamamlanma durumuna göre otomatik hesaplanacaktır.</p>
<p className="text-xs text-muted-foreground">{t("projects.detail.progressAutoHint")}</p>
)}
<div className="grid gap-2">
<Label>Müşteri Revizyon Kotası</Label>
<Label>{t("projects.detail.revisionQuota")}</Label>
<Input
type="number"
min="0"
value={revisionQuota}
onChange={(e) => setRevisionQuota(Number(e.target.value))}
/>
<p className="text-xs text-muted-foreground">Müşterinin portal üzerinden talep edebileceği toplam revizyon hakkı.</p>
<p className="text-xs text-muted-foreground">{t("projects.detail.revisionQuotaHint")}</p>
</div>
</div>
<DialogFooter>
<Button variant="default" effect="shine" type="submit" disabled={isSubmitting}>
{isSubmitting ? "Kaydediliyor..." : "Kaydet"}
{isSubmitting ? t("projects.detail.saving") : t("projects.detail.save")}
</Button>
</DialogFooter>
</form>
@@ -1011,6 +1008,7 @@ function ProjectTaskDialog({
clientId: string | null;
localization: ProjectDetailClientProps["localization"];
}) {
const t = useTranslations();
const [open, setOpen] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -1030,7 +1028,7 @@ function ProjectTaskDialog({
<DialogTrigger asChild>
<Button variant="default" effect="shine" className="gap-2 px-3">
<Plus className="h-4 w-4" />
Görev ekle
{t("projects.detail.addTask")}
</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-2xl">
@@ -1038,9 +1036,9 @@ function ProjectTaskDialog({
<input type="hidden" name="project_id" value={projectId} />
{clientId ? <input type="hidden" name="client_id" value={clientId} /> : null}
<DialogHeader>
<DialogTitle>Projeye görev ekle</DialogTitle>
<DialogTitle>{t("projects.detail.addTaskTitle")}</DialogTitle>
<DialogDescription>
Yeni görev bu proje ile ilişkilendirilerek görev modülüne kaydedilir.
{t("projects.detail.addTaskDesc")}
</DialogDescription>
</DialogHeader>
@@ -1049,33 +1047,39 @@ function ProjectTaskDialog({
idPrefix="project-task"
defaultLocale={localization.defaultLocale}
locales={localization.locales}
fields={contentTranslationRegistry.task}
fields={contentTranslationRegistry.task.map((field) => ({
...field,
label: t(`tasks.fields.${field.name}`),
placeholder: "placeholder" in field && typeof field.placeholder === "string"
? t(`tasks.placeholders.${field.name}`)
: undefined,
}))}
/>
<div className="grid gap-4 md:grid-cols-2">
<div className="grid gap-2">
<Label>Durum</Label>
<Label>{t("projects.form.status")}</Label>
<Select name="status" defaultValue="todo">
<SelectTrigger>
<SelectValue placeholder="Durum seç" />
<SelectValue placeholder={t("projects.form.statusPlaceholder")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="todo">Yapılacak</SelectItem>
<SelectItem value="in_progress">Devam ediyor</SelectItem>
<SelectItem value="done">Tamamlandı</SelectItem>
<SelectItem value="todo">{t("projects.status.todo")}</SelectItem>
<SelectItem value="in_progress">{t("projects.status.in_progress")}</SelectItem>
<SelectItem value="done">{t("projects.status.done")}</SelectItem>
</SelectContent>
</Select>
</div>
<div className="grid gap-2">
<Label>Öncelik</Label>
<Label>{t("projects.detail.colPriority")}</Label>
<Select name="priority" defaultValue="medium">
<SelectTrigger>
<SelectValue placeholder="Öncelik seç" />
<SelectValue placeholder={t("tasks.form.priorityPlaceholder")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="low">Düşük</SelectItem>
<SelectItem value="medium">Orta</SelectItem>
<SelectItem value="high">Yüksek</SelectItem>
<SelectItem value="urgent">Acil</SelectItem>
<SelectItem value="low">{t("tasks.priority.low")}</SelectItem>
<SelectItem value="medium">{t("tasks.priority.medium")}</SelectItem>
<SelectItem value="high">{t("tasks.priority.high")}</SelectItem>
<SelectItem value="urgent">{t("tasks.priority.urgent")}</SelectItem>
</SelectContent>
</Select>
</div>
@@ -1093,37 +1097,37 @@ function ProjectTaskDialog({
htmlFor="is_public_to_client"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
Müşteri Portalında Göster
{t("projects.detail.publicToClient")}
</label>
<p className="text-[13px] text-muted-foreground">
Eğer müşteri hesabı varsa, bu görev müşteri portalındaki proje detayında da görünür olur.
{t("projects.detail.publicToClientHint")}
</p>
</div>
</div>
<div className="grid gap-5 md:grid-cols-3">
<div className="grid gap-2">
<Label htmlFor="project-task-due">Son tarih</Label>
<Label htmlFor="project-task-due">{t("projects.detail.colDue")}</Label>
<Input id="project-task-due" name="due_at" type="datetime-local" />
</div>
<div className="grid gap-2">
<Label htmlFor="project-task-estimated">Tahmini süre</Label>
<Label htmlFor="project-task-estimated">{t("projects.detail.estimatedTime")}</Label>
<Input
id="project-task-estimated"
name="estimated_minutes"
type="number"
min="0"
placeholder="Dakika"
placeholder={t("projects.detail.minutes")}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="project-task-actual">Gerçekleşen süre</Label>
<Label htmlFor="project-task-actual">{t("projects.detail.actualTime")}</Label>
<Input
id="project-task-actual"
name="actual_minutes"
type="number"
min="0"
placeholder="Dakika"
placeholder={t("projects.detail.minutes")}
/>
</div>
</div>
@@ -1132,7 +1136,7 @@ function ProjectTaskDialog({
<DialogFooter>
<Button variant="default" effect="shine" type="submit" disabled={isSubmitting} className="gap-2">
<Plus className="h-4 w-4" />
{isSubmitting ? "Kaydediliyor" : "Görevi ekle"}
{isSubmitting ? t("projects.detail.saving") : t("projects.detail.submitTask")}
</Button>
</DialogFooter>
</form>
@@ -1142,13 +1146,14 @@ function ProjectTaskDialog({
}
function FinancePanel({ transactions }: { transactions: ProjectFinanceItem[] }) {
const t = useTranslations();
return (
<Card>
<CardContent className="space-y-4 p-5">
<div>
<h2 className="text-lg font-semibold text-foreground">Finans bağlantıları</h2>
<h2 className="text-lg font-semibold text-foreground">{t("projects.detail.financeTitle")}</h2>
<p className="mt-1 text-sm text-muted-foreground">
Bu projeye bağlanan gelir ve gider kayıtları.
{t("projects.detail.financeDesc")}
</p>
</div>
@@ -1158,7 +1163,7 @@ function FinancePanel({ transactions }: { transactions: ProjectFinanceItem[] })
<div key={transaction.id} className="flex flex-col gap-2 p-4 md:flex-row md:items-center md:justify-between">
<div>
<div className="font-medium text-foreground">
{transaction.category || (transaction.type === "income" ? "Gelir" : "Gider")}
{transaction.category || (transaction.type === "income" ? t("projects.detail.income") : t("projects.detail.expense"))}
</div>
<div className="text-sm text-muted-foreground">
{formatDate(transaction.transaction_date)} · {transaction.payment_status}
@@ -1178,7 +1183,7 @@ function FinancePanel({ transactions }: { transactions: ProjectFinanceItem[] })
))}
</div>
) : (
<EmptyPanel icon={Wallet} title="Bu projeye bağlı finans kaydı yok" />
<EmptyPanel icon={Wallet} title={t("projects.detail.noFinance")} />
)}
</CardContent>
</Card>
@@ -1284,11 +1289,7 @@ function formatDateTime(value: string) {
}).format(new Date(value));
}
function getTaskStatusLabel(status: ProjectDetailTaskItem["status"]) {
if (status === "done") return "Tamamlandı";
if (status === "in_progress") return "Devam ediyor";
return "Yapılacak";
}
// Removed function since it's localized inline now or no longer needed
function formatCurrency(value: number, currency: string) {
return new Intl.NumberFormat(getDocumentIntlLocale(), {
+12 -3
View File
@@ -3,10 +3,13 @@ import { getSqliteConnection } from "@/server/db/client";
import { ContentTranslationService, type ContentTranslationRow } from "@/server/i18n/content";
import { resolveFreelancerLocale } from "@/server/i18n/resolver";
import { requireFreelancerBackend } from "@/server/web/freelancer";
import { getClientI18nPayload } from "@/server/i18n/translator";
import { I18nProvider } from "@/components/i18n/i18n-provider";
export default async function ProjectsPage() {
const locale = await resolveFreelancerLocale();
const { actor, service } = await requireFreelancerBackend();
const { context, actor, service } = await requireFreelancerBackend();
const locale = await resolveFreelancerLocale(context);
const payload = getClientI18nPayload(locale.locale, ["projects", "common"]);
const content = new ContentTranslationService(getSqliteConnection().db);
const localization = content.getLocalizationContext(actor);
const projectRows = service.listProjects(actor);
@@ -58,7 +61,13 @@ export default async function ProjectsPage() {
.sort((a, b) => a.name.localeCompare(b.name, locale.locale))
.map(({ id, name }) => ({ id, name }));
return <ProjectsClient projects={projects} clients={clients} localization={localization} />;
const i18nPayload = await getClientI18nPayload(locale.locale, ["projects", "tasks", "common"]);
return (
<I18nProvider {...i18nPayload}>
<ProjectsClient projects={projects} clients={clients} localization={localization} />
</I18nProvider>
);
}
function toLocalizedValues(rows: ContentTranslationRow[]) {
+94 -85
View File
@@ -73,18 +73,18 @@ export type ProjectListItem = {
translations?: LocalizedFieldValues;
};
const typeLabels = {
client_project: "Müşteri projesi",
side_project: "Side project",
};
const typeLabels = (t: any) => ({
client_project: t("projects.types.client"),
side_project: t("projects.types.side"),
});
const statusLabels = {
planning: "Planlama",
active: "Aktif",
paused: "Duraklatıldı",
completed: "Tamamlandı",
cancelled: "İptal edildi",
};
const statusLabels = (t: any) => ({
planning: t("projects.status.planning"),
active: t("projects.status.active"),
paused: t("projects.status.paused"),
completed: t("projects.status.completed"),
cancelled: t("projects.status.cancelled"),
});
const statusClasses = {
planning: "border-blue-200 bg-blue-50 text-blue-700",
@@ -108,9 +108,11 @@ export function ProjectsClient({ projects, clients, localization }: ProjectsClie
const [query, setQuery] = useState("");
const [view, setView] = useState<"grid" | "list">("grid");
const normalizedQuery = query.trim().toLowerCase();
const types = typeLabels(t);
const filteredProjects = normalizedQuery
? projects.filter((project) =>
[project.name, project.description, project.clientName, typeLabels[project.type]]
[project.name, project.description, project.clientName, types[project.type]]
.filter(Boolean)
.some((value) => value!.toLowerCase().includes(normalizedQuery)),
)
@@ -140,7 +142,7 @@ export function ProjectsClient({ projects, clients, localization }: ProjectsClie
<div className="grid gap-3 md:grid-cols-4">
<StatCard label={t("projects.stats.active")} value={activeCount.toString()} icon={FolderKanban} tone="green" />
<StatCard label="Side project" value={sideProjectCount.toString()} icon={Target} tone="blue" />
<StatCard label={t("projects.stats.side")} value={sideProjectCount.toString()} icon={Target} tone="blue" />
<StatCard label={t("projects.stats.progress")} value={`${averageProgress}%`} icon={CheckCircle2} tone="amber" />
<StatCard label={t("projects.stats.budget")} value={formatCurrency(totalBudget)} icon={Wallet} tone="red" />
</div>
@@ -149,16 +151,16 @@ export function ProjectsClient({ projects, clients, localization }: ProjectsClie
<CardContent className="space-y-4 p-4">
<div className="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
<div>
<h2 className="text-base font-semibold text-foreground">Proje listesi</h2>
<h2 className="text-base font-semibold text-foreground">{t("projects.list.title")}</h2>
<p className="text-sm text-muted-foreground">
{filteredProjects.length} kayıt görüntüleniyor.
{t("projects.list.count", { count: filteredProjects.length })}
</p>
</div>
<div className="flex flex-col gap-2 sm:flex-row">
<Input
value={query}
onChange={(event) => setQuery(event.target.value)}
placeholder="Proje, müşteri veya açıklama ara"
placeholder={t("projects.list.search")}
className="sm:w-80"
/>
<div className="flex rounded-sm border border-border p-1">
@@ -169,7 +171,7 @@ export function ProjectsClient({ projects, clients, localization }: ProjectsClie
onClick={() => setView("grid")}
>
<LayoutGrid className="h-4 w-4" />
Kart
{t("projects.list.grid")}
</Button>
<Button size="sm" effect="shine"
type="button"
@@ -178,7 +180,7 @@ export function ProjectsClient({ projects, clients, localization }: ProjectsClie
onClick={() => setView("list")}
>
<List className="h-4 w-4" />
Liste
{t("projects.list.list")}
</Button>
</div>
</div>
@@ -195,11 +197,11 @@ export function ProjectsClient({ projects, clients, localization }: ProjectsClie
<div className="overflow-x-auto rounded-sm border border-border">
<div className="min-w-[800px]">
<div className="grid grid-cols-[1.5fr_1fr_1fr_0.8fr_1fr] gap-4 border-b border-border bg-muted/40 px-4 py-3 text-xs font-medium uppercase text-muted-foreground">
<span>Proje</span>
<span>Tür</span>
<span>Durum</span>
<span>İlerleme</span>
<span className="text-right">İşlem</span>
<span>{t("projects.list.columns.project")}</span>
<span>{t("projects.list.columns.type")}</span>
<span>{t("projects.list.columns.status")}</span>
<span className="text-center">{t("projects.list.columns.budgetDeadline")}</span>
<span className="sr-only">İşlemler</span>
</div>
<div className="divide-y divide-border">
{filteredProjects.map((project) => (
@@ -227,6 +229,7 @@ function ProjectCard({
clients: ProjectClientOption[];
localization: ProjectsClientProps["localization"];
}) {
const t = useTranslations();
const router = useRouter();
const [isNavigating, startNavigation] = useTransition();
const detailHref = `/projects/${project.id}`;
@@ -273,10 +276,12 @@ function ProjectCard({
<div className="min-w-0">
<h3 className="truncate text-lg font-semibold text-foreground">{project.name}</h3>
<p className="mt-1 line-clamp-2 text-sm text-muted-foreground">
{project.description || "Açıklama eklenmedi."}
{project.description || t("projects.card.noDescription")}
</p>
</div>
<Badge className={statusClasses[project.status]}>{statusLabels[project.status]}</Badge>
<Badge variant="outline" className={statusClasses[project.status]}>
{statusLabels(t)[project.status]}
</Badge>
</div>
<ProjectMeta project={project} />
@@ -284,7 +289,7 @@ function ProjectCard({
<div className="mt-auto flex items-center justify-between gap-2 border-t border-border pt-4">
<div className="text-xs text-muted-foreground">
{project.doneTaskCount}/{project.taskCount} görev tamamlandı
{t("projects.card.taskProgress", { done: project.doneTaskCount, total: project.taskCount })}
</div>
<ProjectActions project={project} clients={clients} localization={localization} showDetail={false} />
</div>
@@ -294,6 +299,7 @@ function ProjectCard({
}
function ProjectCover({ project }: { project: ProjectListItem }) {
const t = useTranslations();
if (project.coverImageUrl) {
return (
<div className="relative aspect-video overflow-hidden rounded-sm border border-border bg-muted">
@@ -311,7 +317,7 @@ function ProjectCover({ project }: { project: ProjectListItem }) {
return (
<div className="flex aspect-video items-center justify-center rounded-sm border border-dashed border-border bg-muted/30 text-sm text-muted-foreground">
Kapak görseli yok
{t("projects.card.noCover")}
</div>
);
}
@@ -325,17 +331,18 @@ function ProjectRow({
clients: ProjectClientOption[];
localization: ProjectsClientProps["localization"];
}) {
const t = useTranslations();
return (
<div className="grid gap-4 px-4 py-4 grid-cols-[1.5fr_1fr_1fr_0.8fr_1fr] items-center">
<div className="min-w-0">
<div className="font-medium text-foreground">{project.name}</div>
<div className="truncate text-sm text-muted-foreground">
{project.clientName || "Bağımsız side project"}
{project.clientName || t("projects.card.noClient")}
</div>
</div>
<div className="text-sm text-muted-foreground">{typeLabels[project.type]}</div>
<div className="text-sm text-muted-foreground">{typeLabels(t)[project.type]}</div>
<div>
<Badge className={statusClasses[project.status]}>{statusLabels[project.status]}</Badge>
<Badge variant="outline" className={statusClasses[project.status]}>{statusLabels(t)[project.status]}</Badge>
</div>
<div>
<ProgressBar progress={project.progress} compact />
@@ -348,15 +355,16 @@ function ProjectRow({
}
function ProjectMeta({ project }: { project: ProjectListItem }) {
const t = useTranslations();
return (
<div className="grid gap-2 text-sm text-muted-foreground">
<div>{typeLabels[project.type]}</div>
<div>{project.clientName || "Müşteri bağlantısı yok"}</div>
<div>{typeLabels(t)[project.type]}</div>
<div>{project.clientName || t("projects.card.noClient")}</div>
<div className="flex items-center gap-2">
<CalendarDays className="h-4 w-4" />
{project.due_date ? formatDate(project.due_date) : "Deadline yok"}
{project.due_date ? formatDate(project.due_date) : t("projects.card.noDeadline")}
</div>
<div>{project.budget_amount ? formatCurrency(project.budget_amount) : "Bütçe yok"}</div>
<div>{project.budget_amount ? formatCurrency(project.budget_amount) : t("projects.card.noBudget")}</div>
</div>
);
}
@@ -372,6 +380,7 @@ function ProjectActions({
localization: ProjectsClientProps["localization"];
showDetail: boolean;
}) {
const t = useTranslations();
return (
<div
className="flex gap-2"
@@ -384,8 +393,8 @@ function ProjectActions({
effect="shine"
asChild
variant="secondary"
title="Detaya git"
aria-label="Detaya git"
title={t("projects.actions.detail")}
aria-label={t("projects.actions.detail")}
>
<PendingLink href={`/projects/${project.id}`} className="flex h-full w-full items-center justify-center" showSpinner>
<Eye className="h-4 w-4" />
@@ -399,8 +408,8 @@ function ProjectActions({
<PendingSubmitButton
size="icon"
variant="secondary"
title="Tamamla"
aria-label="Tamamla"
title={t("projects.actions.complete")}
aria-label={t("projects.actions.complete")}
idleIcon={<CheckCircle2 className="h-4 w-4" />}
>
</PendingSubmitButton>
@@ -423,6 +432,7 @@ function ProjectDialog({
localization: ProjectsClientProps["localization"];
iconOnly?: boolean;
}) {
const t = useTranslations();
const [open, setOpen] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const [projectType, setProjectType] = useState(project?.type || "client_project");
@@ -434,12 +444,12 @@ function ProjectDialog({
try {
await action(formData);
setOpen(false);
toast.success(mode === "create" ? "Proje eklendi." : "Proje güncellendi.");
toast.success(mode === "create" ? t("projects.messages.created") : t("projects.messages.updated"));
} catch (error) {
toast.error(
error instanceof Error
? error.message
: "Proje kaydedilirken beklenmeyen bir hata oluştu.",
: t("projects.errors.saveFailed"),
);
} finally {
setIsSubmitting(false);
@@ -453,20 +463,20 @@ function ProjectDialog({
variant={mode === "create" ? "default" : "secondary"}
size={iconOnly ? "icon" : "default"}
className={iconOnly ? undefined : "min-w-24 gap-2 px-3"}
title={mode === "create" ? "Proje ekle" : "Düzenle"}
aria-label={mode === "create" ? "Proje ekle" : "Düzenle"}
title={mode === "create" ? t("projects.actions.add") : t("projects.actions.edit")}
aria-label={mode === "create" ? t("projects.actions.add") : t("projects.actions.edit")}
>
{mode === "create" ? <Plus className="h-4 w-4" /> : <Pencil className="h-4 w-4" />}
{iconOnly ? null : mode === "create" ? "Proje ekle" : "Düzenle"}
{iconOnly ? null : mode === "create" ? t("projects.actions.add") : t("projects.actions.edit")}
</Button>
</DialogTrigger>
<DialogContent className="flex max-h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] flex-col overflow-hidden p-0 sm:max-h-[min(680px,calc(100dvh-4rem))] sm:max-w-2xl data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95">
<form action={handleSubmit} className="flex min-h-0 flex-1 flex-col overflow-hidden">
{project ? <input type="hidden" name="id" value={project.id} /> : null}
<DialogHeader className="shrink-0 px-5 pb-4 pt-5 pr-12">
<DialogTitle>{mode === "create" ? "Yeni proje" : "Projeyi düzenle"}</DialogTitle>
<DialogTitle>{mode === "create" ? t("projects.form.createTitle") : t("projects.form.editTitle")}</DialogTitle>
<DialogDescription>
Müşteri projelerini ve kişisel side projectleri aynı modelde takip et.
{t("projects.form.description")}
</DialogDescription>
</DialogHeader>
@@ -484,10 +494,10 @@ function ProjectDialog({
<Button variant="default" effect="shine" type="submit" disabled={isSubmitting} className="w-full gap-2 sm:w-auto">
{mode === "create" ? <Plus className="h-4 w-4" /> : <Pencil className="h-4 w-4" />}
{isSubmitting
? "Kaydediliyor"
? t("projects.form.submitting")
: mode === "create"
? "Projeyi ekle"
: "Değişiklikleri kaydet"}
? t("projects.form.submitCreate")
: t("projects.form.submitEdit")}
</Button>
</DialogFooter>
</form>
@@ -497,6 +507,7 @@ function ProjectDialog({
}
function CoverImageInput({ project }: { project?: ProjectListItem }) {
const t = useTranslations();
const inputId = `cover-${project?.id || "new"}`;
const [previewUrl, setPreviewUrl] = useState(project?.coverImageUrl || "");
@@ -528,7 +539,7 @@ function CoverImageInput({ project }: { project?: ProjectListItem }) {
return (
<div className="grid gap-3">
<Label htmlFor={inputId}>Kapak görseli</Label>
<Label htmlFor={inputId}>{t("projects.form.coverImage")}</Label>
<label
htmlFor={inputId}
className="group relative flex aspect-16/7 cursor-pointer items-center justify-center overflow-hidden rounded-sm border border-dashed border-border bg-muted/20 transition-colors hover:border-primary/50 hover:bg-primary/5"
@@ -548,15 +559,15 @@ function CoverImageInput({ project }: { project?: ProjectListItem }) {
<ImageIcon className="h-6 w-6" />
</div>
<div className="text-center">
<div className="text-sm font-medium">Kapak görseli seç</div>
<div className="text-xs">PNG, JPG, WebP veya GIF</div>
<div className="text-sm font-medium">{t("projects.form.coverImageSelect")}</div>
<div className="text-xs">{t("projects.form.coverImageFormat")}</div>
</div>
</div>
)}
{previewUrl ? (
<div className="absolute inset-x-0 bottom-0 bg-background/90 px-3 py-2 text-xs text-muted-foreground backdrop-blur">
Görseli değiştirmek için tıkla.
{t("projects.form.coverImageChange")}
</div>
) : null}
</label>
@@ -585,6 +596,7 @@ function ProjectFormFields({
projectType: ProjectListItem["type"];
onProjectTypeChange: (value: ProjectListItem["type"]) => void;
}) {
const t = useTranslations();
return (
<div className="grid gap-4">
<CoverImageInput project={project} />
@@ -593,7 +605,7 @@ function ProjectFormFields({
idPrefix={`project-${project?.id || "new"}`}
defaultLocale={localization.defaultLocale}
locales={localization.locales}
fields={contentTranslationRegistry.project}
fields={contentTranslationRegistry.project.map((f: any) => ({ ...f, label: (t as any)(`projects.fields.${f.name}`) || f.label, placeholder: f.placeholder ? (t as any)(`projects.placeholders.${f.name}`) || f.placeholder : undefined }))}
values={project?.translations}
fallbackValues={{
name: project?.name,
@@ -604,30 +616,30 @@ function ProjectFormFields({
<div className="grid gap-4 md:grid-cols-2">
<div className="grid gap-2">
<Label>Tür</Label>
<Label>{t("projects.form.type")}</Label>
<Select
name="type"
value={projectType}
onValueChange={(value) => onProjectTypeChange(value as ProjectListItem["type"])}
>
<SelectTrigger>
<SelectValue placeholder="Tür seç" />
<SelectValue placeholder={t("projects.form.typePlaceholder")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="client_project">Müşteri projesi</SelectItem>
<SelectItem value="side_project">Side project</SelectItem>
<SelectItem value="client_project">{t("projects.types.client")}</SelectItem>
<SelectItem value="side_project">{t("projects.types.side")}</SelectItem>
</SelectContent>
</Select>
</div>
<div className="grid gap-2">
<Label>Müşteri</Label>
<Label>{t("projects.form.client")}</Label>
<Select
name="client_id"
defaultValue={project?.client_id || ""}
disabled={projectType === "side_project"}
>
<SelectTrigger>
<SelectValue placeholder="Müşteri seç" />
<SelectValue placeholder={t("projects.form.clientPlaceholder")} />
</SelectTrigger>
<SelectContent>
{clients.map((client) => (
@@ -642,33 +654,33 @@ function ProjectFormFields({
<div className="grid gap-4 md:grid-cols-3">
<div className="grid gap-2">
<Label>Durum</Label>
<Label>{t("projects.form.status")}</Label>
<Select name="status" defaultValue={project?.status || "planning"}>
<SelectTrigger>
<SelectValue placeholder="Durum seç" />
<SelectValue placeholder={t("projects.form.statusPlaceholder")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="planning">Planlama</SelectItem>
<SelectItem value="active">Aktif</SelectItem>
<SelectItem value="paused">Duraklatıldı</SelectItem>
<SelectItem value="completed">Tamamlandı</SelectItem>
<SelectItem value="cancelled">İptal edildi</SelectItem>
<SelectItem value="planning">{t("projects.status.planning")}</SelectItem>
<SelectItem value="active">{t("projects.status.active")}</SelectItem>
<SelectItem value="paused">{t("projects.status.paused")}</SelectItem>
<SelectItem value="completed">{t("projects.status.completed")}</SelectItem>
<SelectItem value="cancelled">{t("projects.status.cancelled")}</SelectItem>
</SelectContent>
</Select>
</div>
<div className="grid gap-2">
<Label htmlFor={`start-${project?.id || "new"}`}>Başlangıç</Label>
<Label htmlFor={`start-${project?.id || "new"}`}>{t("projects.form.startDate")}</Label>
<Input id={`start-${project?.id || "new"}`} name="start_date" type="date" defaultValue={project?.start_date || ""} />
</div>
<div className="grid gap-2">
<Label htmlFor={`due-${project?.id || "new"}`}>Deadline</Label>
<Label htmlFor={`due-${project?.id || "new"}`}>{t("projects.form.dueDate")}</Label>
<Input id={`due-${project?.id || "new"}`} name="due_date" type="date" defaultValue={project?.due_date || ""} />
</div>
</div>
<div className="grid gap-4 md:grid-cols-3">
<div className="grid gap-2">
<Label htmlFor={`budget-${project?.id || "new"}`}>Bütçe / beklenen gelir</Label>
<Label htmlFor={`budget-${project?.id || "new"}`}>{t("projects.form.budget")}</Label>
<Input
id={`budget-${project?.id || "new"}`}
name="budget_amount"
@@ -680,11 +692,11 @@ function ProjectFormFields({
/>
</div>
<div className="grid gap-2">
<Label htmlFor={`currency-${project?.id || "new"}`}>Para birimi</Label>
<Label htmlFor={`currency-${project?.id || "new"}`}>{t("projects.form.currency")}</Label>
<Input id={`currency-${project?.id || "new"}`} name="currency" defaultValue={project?.currency || "USD"} maxLength={3} />
</div>
<div className="grid gap-2">
<Label htmlFor={`progress-${project?.id || "new"}`}>İlerleme (%)</Label>
<Label htmlFor={`progress-${project?.id || "new"}`}>{t("projects.form.progress")}</Label>
<div className="flex items-center gap-3">
<Input
id={`progress-${project?.id || "new"}`}
@@ -710,11 +722,12 @@ function ProjectFormFields({
}
function ProgressBar({ progress, compact = false }: { progress: number; compact?: boolean }) {
const t = useTranslations();
return (
<div className="space-y-2">
{!compact ? (
<div className="flex justify-between text-xs text-muted-foreground">
<span>İlerleme</span>
<span>{t("projects.card.progress")}</span>
<span>{progress}%</span>
</div>
) : null}
@@ -729,17 +742,14 @@ function ProgressBar({ progress, compact = false }: { progress: number; compact?
}
function EmptyState({ hasQuery }: { hasQuery: boolean }) {
const t = useTranslations();
return (
<div className="flex min-h-72 flex-col items-center justify-center rounded-sm border border-dashed border-border bg-muted/20 p-8 text-center">
<FolderKanban className="h-10 w-10 text-muted-foreground" />
<h3 className="mt-4 text-lg font-semibold text-foreground">
{hasQuery ? "Aramana uygun proje yok" : "Henüz proje eklenmedi"}
</h3>
<p className="mt-2 max-w-md text-sm text-muted-foreground">
{hasQuery
? "Arama metnini sadeleştirerek tekrar deneyebilirsin."
: "İlk müşteri projen veya side project kaydınla operasyon akışını kurmaya başlayabilirsin."}
</p>
<div className="flex flex-col items-center justify-center gap-2 rounded-sm border border-dashed border-border py-12 text-center">
<FolderKanban className="h-8 w-8 text-muted-foreground/50" />
<div className="text-sm font-medium text-foreground">{t("projects.empty.title")}</div>
<div className="max-w-xs text-xs text-muted-foreground">
{t("projects.empty.description")}
</div>
</div>
);
}
@@ -761,6 +771,7 @@ function formatCurrency(value: number) {
}
function AIProjectRiskDialog({ projectId }: { projectId?: string }) {
const t = useTranslations();
const [open, setOpen] = useState(false);
const [loading, setLoading] = useState(false);
const [result, setResult] = useState<string | null>(null);
@@ -793,9 +804,7 @@ function AIProjectRiskDialog({ projectId }: { projectId?: string }) {
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button effect="shine" variant="secondary" className="gap-2">
<Brain className="h-4 w-4" />
AI Risk Analizi
</Button>
<Brain className="h-4 w-4" />{t("projects.actions.ai")}</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-2xl max-h-[80vh] overflow-y-auto">
<DialogHeader>
+9 -1
View File
@@ -3,6 +3,8 @@ import { getSqliteConnection } from "@/server/db/client";
import { ContentTranslationService, type ContentTranslationRow } from "@/server/i18n/content";
import { resolveFreelancerLocale } from "@/server/i18n/resolver";
import { requireFreelancerBackend } from "@/server/web/freelancer";
import { getClientI18nPayload } from "@/server/i18n/translator";
import { I18nProvider } from "@/components/i18n/i18n-provider";
export default async function TasksPage() {
const locale = await resolveFreelancerLocale();
@@ -55,7 +57,13 @@ export default async function TasksPage() {
.filter((project) => project.status !== "cancelled")
.map(({ id, name, clientId }) => ({ id, name, client_id: clientId }));
return <TasksClient tasks={tasks} clients={clients} projects={projects} localization={localization} />;
const i18nPayload = await getClientI18nPayload(locale.locale, ["tasks", "projects", "common"]);
return (
<I18nProvider {...i18nPayload}>
<TasksClient tasks={tasks} clients={clients} projects={projects} localization={localization} />
</I18nProvider>
);
}
function toLocalizedValues(rows: ContentTranslationRow[]) {
+68 -60
View File
@@ -126,7 +126,7 @@ export function TasksClient({ tasks, clients, projects, localization }: TasksCli
toast.error(
error instanceof Error
? error.message
: "Görev durumu güncellenemedi.",
: t("tasks.messages.updateFailed") || "Görev durumu güncellenemedi.",
);
})
.finally(() => {
@@ -211,35 +211,35 @@ export function TasksClient({ tasks, clients, projects, localization }: TasksCli
</div>
<div className="grid gap-3 md:grid-cols-4">
<StatCard label="Toplam görev" value={localTasks.length.toString()} />
<StatCard label="Tamamlanan" value={doneCount.toString()} />
<StatCard label="Geciken" value={overdueCount.toString()} />
<StatCard label="Acil" value={urgentCount.toString()} />
<StatCard label={t("tasks.stats.total")} value={localTasks.length.toString()} />
<StatCard label={t("tasks.stats.completed")} value={doneCount.toString()} />
<StatCard label={t("tasks.stats.overdue")} value={overdueCount.toString()} />
<StatCard label={t("tasks.stats.urgent")} value={urgentCount.toString()} />
</div>
<Card>
<CardContent className="space-y-4 p-4">
<div className="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
<div>
<h2 className="text-base font-semibold text-foreground">Görev listesi</h2>
<h2 className="text-base font-semibold text-foreground">{t("tasks.list.title")}</h2>
<p className="text-sm text-muted-foreground">
{filteredTasks.length} kayıt görüntüleniyor.
{t("tasks.list.showing", { count: filteredTasks.length.toString() })}
</p>
</div>
<div className="flex flex-col gap-2 sm:flex-row">
<Input
value={query}
onChange={(event) => setQuery(event.target.value)}
placeholder="Görev, proje veya müşteri ara"
placeholder={t("tasks.list.search")}
className="sm:w-80"
/>
<Select value={projectFilter} onValueChange={setProjectFilter}>
<SelectTrigger className="sm:w-56">
<SelectValue placeholder="Proje filtrele" />
<SelectValue placeholder={t("tasks.list.filterProject")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="__all">Tüm projeler</SelectItem>
<SelectItem value="__none">Projesiz görevler</SelectItem>
<SelectItem value="__all">{t("tasks.list.allProjects")}</SelectItem>
<SelectItem value="__none">{t("tasks.list.noProject")}</SelectItem>
{projects.map((project) => (
<SelectItem key={project.id} value={project.id}>
{project.name}
@@ -255,7 +255,7 @@ export function TasksClient({ tasks, clients, projects, localization }: TasksCli
onClick={() => setView("list")}
>
<LayoutList className="h-4 w-4" />
Liste
{t("tasks.list.viewList")}
</Button>
<Button size="sm" effect="shine"
type="button"
@@ -264,7 +264,7 @@ export function TasksClient({ tasks, clients, projects, localization }: TasksCli
onClick={() => setView("kanban")}
>
<KanbanSquare className="h-4 w-4" />
Kanban
{t("tasks.list.viewKanban")}
</Button>
</div>
</div>
@@ -318,15 +318,16 @@ function TaskList({
onTaskDelete: (taskId: string) => void;
onTaskStatusChange: (taskId: string, status: TaskListItem["status"]) => void;
}) {
const t = useTranslations();
return (
<div className="overflow-x-auto rounded-sm border border-border">
<div className="min-w-[800px]">
<div className="grid grid-cols-[1.5fr_1fr_1fr_0.8fr_1fr] gap-4 border-b border-border bg-muted/40 px-4 py-3 text-xs font-medium uppercase text-muted-foreground">
<span>Görev</span>
<span>Bağlantı</span>
<span>Öncelik</span>
<span>Son tarih</span>
<span className="text-right">İşlem</span>
<span>{t("tasks.col.task")}</span>
<span>{t("tasks.col.relation")}</span>
<span>{t("tasks.col.priority")}</span>
<span>{t("tasks.col.due")}</span>
<span className="text-right">{t("tasks.col.action")}</span>
</div>
<div className="divide-y divide-border">
{tasks.map((task) => (
@@ -364,6 +365,7 @@ function TaskRow({
onTaskDelete: (taskId: string) => void;
onTaskStatusChange: (taskId: string, status: TaskListItem["status"]) => void;
}) {
const t = useTranslations();
return (
<div className="grid gap-4 px-4 py-4 grid-cols-[1.5fr_1fr_1fr_0.8fr_1fr] items-center">
<div className="min-w-0">
@@ -371,20 +373,20 @@ function TaskRow({
{task.title}
</div>
<div className="truncate text-sm text-muted-foreground">
{statusLabels[task.status]}
{t(`tasks.status.${task.status}`)}
</div>
</div>
<div className="text-sm text-muted-foreground">
<div>{task.projectName || "Proje yok"}</div>
<div>{task.clientName || "Müşteri yok"}</div>
<div>{task.projectName || t("tasks.row.noProject")}</div>
<div>{task.clientName || t("tasks.row.noClient")}</div>
</div>
<div>
<Badge className={priorityClasses[task.priority]}>
{priorityLabels[task.priority]}
{t(`tasks.priority.${task.priority}`)}
</Badge>
</div>
<div className={isOverdue(task) ? "text-sm font-medium text-rose-600" : "text-sm text-muted-foreground"}>
{task.due_at ? formatDateTime(task.due_at) : "Yok"}
{task.due_at ? formatDateTime(task.due_at) : t("tasks.row.noDue")}
</div>
<TaskActions
task={task}
@@ -416,6 +418,7 @@ function TaskKanban({
onTaskDelete: (taskId: string) => void;
onTaskStatusChange: (taskId: string, status: TaskListItem["status"]) => void;
}) {
const t = useTranslations();
const columns = ["todo", "in_progress", "done"] as const;
const [draggedTaskId, setDraggedTaskId] = useState<string | null>(null);
@@ -449,7 +452,7 @@ function TaskKanban({
onDrop={() => handleDrop(status)}
>
<div className="mb-3 flex items-center justify-between">
<h3 className="text-sm font-semibold text-foreground">{statusLabels[status]}</h3>
<h3 className="text-sm font-semibold text-foreground">{t(`tasks.status.${status}`)}</h3>
<Badge>{columnTasks.length}</Badge>
</div>
<div className="space-y-3">
@@ -469,12 +472,12 @@ function TaskKanban({
<div>
<div className="font-medium text-foreground">{task.title}</div>
<div className="text-sm text-muted-foreground">
{task.projectName || task.clientName || "Bağlantı yok"}
{task.projectName || task.clientName || t("tasks.col.relation")}
</div>
</div>
<div className="flex items-center justify-between gap-2">
<Badge className={priorityClasses[task.priority]}>
{priorityLabels[task.priority]}
{t(`tasks.priority.${task.priority}`)}
</Badge>
<TaskActions
task={task}
@@ -517,6 +520,7 @@ function TaskActions({
onTaskDelete: (taskId: string) => void;
onTaskStatusChange: (taskId: string, status: TaskListItem["status"]) => void;
}) {
const t = useTranslations();
return (
<div className={compact ? "flex justify-end gap-1" : "flex justify-start gap-2 lg:justify-end"}>
<TaskDialog mode="edit" task={task} clients={clients} projects={projects} localization={localization} />
@@ -534,7 +538,7 @@ function TaskActions({
) : (
<CheckCircle2 className="h-4 w-4" />
)}
{!compact ? (isPending ? "Tamamlanıyor" : "Tamamla") : null}
{!compact ? (isPending ? t("projects.detail.completing") : t("projects.detail.complete")) : null}
</Button>
) : null}
<Button effect="shine"
@@ -568,6 +572,7 @@ function TaskDialog({
projects: TaskRelationOption[];
localization: TasksClientProps["localization"];
}) {
const t = useTranslations();
const [open, setOpen] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const action = mode === "create" ? createTaskRecord : updateTaskRecord;
@@ -578,12 +583,12 @@ function TaskDialog({
try {
await action(formData);
setOpen(false);
toast.success(mode === "create" ? "Görev eklendi." : "Görev güncellendi.");
toast.success(mode === "create" ? t("tasks.messages.added") : t("tasks.messages.updated"));
} catch (error) {
toast.error(
error instanceof Error
? error.message
: "Görev kaydedilirken beklenmeyen bir hata oluştu.",
: t("tasks.messages.saveFailed"),
);
} finally {
setIsSubmitting(false);
@@ -598,16 +603,16 @@ function TaskDialog({
className="min-w-24 gap-2 px-3"
>
{mode === "create" ? <Plus className="h-4 w-4" /> : <Pencil className="h-4 w-4" />}
{mode === "create" ? "Görev ekle" : "Düzenle"}
{mode === "create" ? t("tasks.form.add") : t("tasks.form.edit")}
</Button>
</DialogTrigger>
<DialogContent className="flex max-h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] flex-col overflow-hidden p-0 sm:max-h-[min(680px,calc(100dvh-4rem))] sm:max-w-xl data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95">
<form action={handleSubmit} className="flex min-h-0 flex-1 flex-col overflow-hidden">
{task ? <input type="hidden" name="id" value={task.id} /> : null}
<DialogHeader className="shrink-0 px-5 pb-4 pt-5 pr-12">
<DialogTitle>{mode === "create" ? "Yeni görev" : "Görevi düzenle"}</DialogTitle>
<DialogTitle>{mode === "create" ? t("tasks.form.createTitle") : t("tasks.form.editTitle")}</DialogTitle>
<DialogDescription>
Görevi proje, müşteri, öncelik ve son tarih bilgileriyle kaydet.
{t("tasks.form.desc")}
</DialogDescription>
</DialogHeader>
@@ -619,10 +624,10 @@ function TaskDialog({
<Button variant="default" effect="shine" type="submit" disabled={isSubmitting} className="w-full gap-2 sm:w-auto">
{mode === "create" ? <Plus className="h-4 w-4" /> : <Pencil className="h-4 w-4" />}
{isSubmitting
? "Kaydediliyor"
? t("tasks.form.saving")
: mode === "create"
? "Görevi ekle"
: "Değişiklikleri kaydet"}
? t("tasks.form.submitAdd")
: t("tasks.form.submitEdit")}
</Button>
</DialogFooter>
</form>
@@ -642,6 +647,7 @@ function TaskFormFields({
projects: TaskRelationOption[];
localization: TasksClientProps["localization"];
}) {
const t = useTranslations();
const [clientId, setClientId] = useState(task?.client_id || "__none");
const [projectId, setProjectId] = useState(task?.project_id || "__none");
const selectedProject =
@@ -681,7 +687,7 @@ function TaskFormFields({
idPrefix={`task-${task?.id || "new"}`}
defaultLocale={localization.defaultLocale}
locales={localization.locales}
fields={contentTranslationRegistry.task}
fields={contentTranslationRegistry.task.map((f: any) => ({ ...f, label: (t as any)(`tasks.fields.${f.name}`) || f.label, placeholder: f.placeholder ? (t as any)(`tasks.placeholders.${f.name}`) || f.placeholder : undefined }))}
values={task?.translations}
fallbackValues={{
title: task?.title,
@@ -690,22 +696,22 @@ function TaskFormFields({
/>
<div className="grid gap-4 md:grid-cols-2">
<SelectField name="status" label="Durum" defaultValue={task?.status || "todo"}>
<SelectItem value="todo">Yapılacak</SelectItem>
<SelectItem value="in_progress">Devam ediyor</SelectItem>
<SelectItem value="done">Tamamlandı</SelectItem>
<SelectField name="status" label={t("tasks.form.status")} defaultValue={task?.status || "todo"}>
<SelectItem value="todo">{t("tasks.status.todo")}</SelectItem>
<SelectItem value="in_progress">{t("tasks.status.in_progress")}</SelectItem>
<SelectItem value="done">{t("tasks.status.done")}</SelectItem>
</SelectField>
<SelectField name="priority" label="Öncelik" defaultValue={task?.priority || "medium"}>
<SelectItem value="low">Düşük</SelectItem>
<SelectItem value="medium">Orta</SelectItem>
<SelectItem value="high">Yüksek</SelectItem>
<SelectItem value="urgent">Acil</SelectItem>
<SelectField name="priority" label={t("tasks.form.priority")} defaultValue={task?.priority || "medium"}>
<SelectItem value="low">{t("tasks.priority.low")}</SelectItem>
<SelectItem value="medium">{t("tasks.priority.medium")}</SelectItem>
<SelectItem value="high">{t("tasks.priority.high")}</SelectItem>
<SelectItem value="urgent">{t("tasks.priority.urgent")}</SelectItem>
</SelectField>
</div>
<div className="grid gap-4 md:grid-cols-2">
<div className="grid gap-2">
<Label>Müşteri</Label>
<Label>{t("tasks.form.client")}</Label>
{shouldLockClient ? <input type="hidden" name="client_id" value={clientId} /> : null}
<Select
name="client_id"
@@ -714,10 +720,10 @@ function TaskFormFields({
disabled={shouldLockClient}
>
<SelectTrigger>
<SelectValue placeholder="Müşteri seç" />
<SelectValue placeholder={t("tasks.form.selectClient")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="__none">Müşteri yok</SelectItem>
<SelectItem value="__none">{t("tasks.form.noClient")}</SelectItem>
{clients.map((client) => (
<SelectItem key={client.id} value={client.id}>
{client.name}
@@ -727,13 +733,13 @@ function TaskFormFields({
</Select>
</div>
<div className="grid gap-2">
<Label>Proje</Label>
<Label>{t("tasks.form.project")}</Label>
<Select name="project_id" value={projectId} onValueChange={handleProjectChange}>
<SelectTrigger>
<SelectValue placeholder="Proje seç" />
<SelectValue placeholder={t("tasks.form.selectProject")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="__none">Proje yok</SelectItem>
<SelectItem value="__none">{t("tasks.form.noProject")}</SelectItem>
{filteredProjects.map((project) => (
<SelectItem key={project.id} value={project.id}>
{project.name}
@@ -746,7 +752,7 @@ function TaskFormFields({
<div className="grid gap-4 md:grid-cols-3">
<div className="grid gap-2">
<Label htmlFor={`due-${task?.id || "new"}`}>Son tarih</Label>
<Label htmlFor={`due-${task?.id || "new"}`}>{t("tasks.form.due")}</Label>
<Input
id={`due-${task?.id || "new"}`}
name="due_at"
@@ -755,25 +761,25 @@ function TaskFormFields({
/>
</div>
<div className="grid gap-2">
<Label htmlFor={`estimated-${task?.id || "new"}`}>Tahmini süre</Label>
<Label htmlFor={`estimated-${task?.id || "new"}`}>{t("tasks.form.estimated")}</Label>
<Input
id={`estimated-${task?.id || "new"}`}
name="estimated_minutes"
type="number"
min="0"
defaultValue={task?.estimated_minutes ?? ""}
placeholder="Dakika"
placeholder={t("tasks.form.minutes")}
/>
</div>
<div className="grid gap-2">
<Label htmlFor={`actual-${task?.id || "new"}`}>Gerçekleşen süre</Label>
<Label htmlFor={`actual-${task?.id || "new"}`}>{t("tasks.form.actual")}</Label>
<Input
id={`actual-${task?.id || "new"}`}
name="actual_minutes"
type="number"
min="0"
defaultValue={task?.actual_minutes ?? ""}
placeholder="Dakika"
placeholder={t("tasks.form.minutes")}
/>
</div>
</div>
@@ -792,12 +798,13 @@ function SelectField({
defaultValue: string;
children: React.ReactNode;
}) {
const t = useTranslations();
return (
<div className="grid gap-2">
<Label>{label}</Label>
<Select name={name} defaultValue={defaultValue}>
<SelectTrigger>
<SelectValue placeholder={`${label} seç`} />
<SelectValue placeholder={t("tasks.form.select", { label })} />
</SelectTrigger>
<SelectContent>{children}</SelectContent>
</Select>
@@ -822,16 +829,17 @@ function StatCard({ label, value }: { label: string; value: string }) {
}
function EmptyState({ hasQuery }: { hasQuery: boolean }) {
const t = useTranslations();
return (
<div className="flex min-h-72 flex-col items-center justify-center rounded-sm border border-dashed border-border bg-muted/20 p-8 text-center">
<CheckCircle2 className="h-10 w-10 text-muted-foreground" />
<h3 className="mt-4 text-lg font-semibold text-foreground">
{hasQuery ? "Aramana uygun görev yok" : "Henüz görev eklenmedi"}
{hasQuery ? t("tasks.empty.noMatchTitle") : t("tasks.empty.noTaskTitle")}
</h3>
<p className="mt-2 max-w-md text-sm text-muted-foreground">
{hasQuery
? "Arama metnini sadeleştirerek tekrar deneyebilirsin."
: "İlk görevini ekleyerek proje ve müşteri operasyonunu takip etmeye başlayabilirsin."}
? t("tasks.empty.noMatchDesc")
: t("tasks.empty.noTaskDesc")}
</p>
</div>
);