-
-
-
- {format(new Date(rev.created_at), "d MMM yyyy, HH:mm", { locale: tr })}
-
-
- {rev.status === 'pending' ? 'Bekliyor' :
- rev.status === 'in_progress' ? 'İşleniyor' :
- rev.status === 'completed' ? 'Tamamlandı' : 'Reddedildi'}
-
+ ) : revisions.map((revision) => (
+
+
+
+
+
+
+ {format(revision.createdAt, "d MMM yyyy, HH:mm", { locale: tr })}
-
-
- Proje:
-
- {getProjectName(rev.project_id)}
-
-
-
-
- {rev.description}
-
+
+ {revision.status === "pending" ? "Bekliyor" : revision.status === "in_progress" ? "İşleniyor" : revision.status === "completed" ? "Tamamlandı" : "Reddedildi"}
+
-
-
-
- Projeye Git →
-
+
+ Proje:
+
+ {projectNames.get(revision.projectId)}
+
-
-
- ))
- )}
+
{revision.description}
+
+
+
+ Projeye Git →
+
+
+
+
+ ))}
);
diff --git a/app/portal/tasks/page.tsx b/app/portal/tasks/page.tsx
index 249880b..f6ec381 100644
--- a/app/portal/tasks/page.tsx
+++ b/app/portal/tasks/page.tsx
@@ -1,59 +1,16 @@
-import { createClient } from "@/lib/supabase/server";
import { Card, CardContent, Badge } from "poyraz-ui/atoms";
import { CheckCircle2, Clock, CalendarDays, KanbanSquare } from "lucide-react";
-import Link from "next/link";
import { format } from "date-fns";
import { tr } from "date-fns/locale";
-
-type PortalTaskRow = {
- id: string;
- title: string;
- status: string;
- project_id: string;
- created_at: string;
- date: string | null;
- priority: string | null;
-};
+import { requirePortalBackend } from "@/server/web/portal";
export default async function PortalTasksPage() {
- const supabase = await createClient();
- const { data: { user } } = await supabase.auth.getUser();
-
- if (!user) return null;
-
- const { data: clientData } = await supabase
- .from("clients")
- .select("id")
- .eq("client_auth_id", user.id)
- .single();
-
- if (!clientData) {
- return (
-
-
Hesabınız Henüz Aktif Değil
-
- );
- }
-
- const { data: projectsData } = await supabase
- .from("projects")
- .select("id, name")
- .eq("client_id", clientData.id);
-
- const projectIds = projectsData?.map(p => p.id) || [];
-
- let tasks: PortalTaskRow[] = [];
- if (projectIds.length > 0) {
- const { data: tasksData } = await supabase
- .from("tasks")
- .select("id, title, status, project_id, created_at, date, priority")
- .in("project_id", projectIds)
- .eq("is_public_to_client", true)
- .order("created_at", { ascending: false });
- tasks = tasksData || [];
- }
-
- const getProjectName = (id: string) => projectsData?.find(p => p.id === id)?.name || "Bilinmeyen Proje";
+ const { actor, service } = await requirePortalBackend();
+ const projects = service.listProjects(actor);
+ const projectNames = new Map(projects.map((project) => [project.id, project.name]));
+ const tasks = service.listTasks(actor)
+ .filter((task) => task.projectId && projectNames.has(task.projectId) && task.status !== "cancelled")
+ .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
return (
@@ -68,40 +25,36 @@ export default async function PortalTasksPage() {
Henüz sizinle paylaşılan bir görev bulunmuyor.
- ) : (
- tasks.map(task => (
+ ) : tasks.map((task) => {
+ const isDone = task.status === "done";
+ const date = task.dueAt?.toISOString() ?? task.scheduledDate;
+ return (
-
+
{task.title}
-
- {task.status === 'todo' ? 'Bekliyor' : task.status === 'in_progress' ? 'İşleniyor' : 'Tamamlandı'}
+
+ {task.status === "todo" ? "Bekliyor" : task.status === "in_progress" ? "İşleniyor" : "Tamamlandı"}
-
- {getProjectName(task.project_id)}
+ {projectNames.get(task.projectId!)}
-
- {task.date ? format(new Date(task.date), 'd MMM yyyy', { locale: tr }) : 'Tarih yok'}
+ {date ? format(new Date(date), "d MMM yyyy", { locale: tr }) : "Tarih yok"}
- {task.status === 'completed' || task.status === 'done' ? (
-
- ) : (
-
- )}
+ {isDone ?
:
}
- ))
- )}
+ );
+ })}