+
+
+
+
+
@@ -269,6 +334,7 @@ export function TasksBoard({ tasks: initialTasks, customers, teamMembers }: Prop
onEdit={() => {}}
onDelete={() => {}}
isOverlay
+ currentUserId={currentUserId}
/>
)}
diff --git a/src/app/(dashboard)/tasks/components/types.ts b/src/app/(dashboard)/tasks/components/types.ts
index 3a45594..45755e6 100644
--- a/src/app/(dashboard)/tasks/components/types.ts
+++ b/src/app/(dashboard)/tasks/components/types.ts
@@ -18,6 +18,15 @@ export type TaskRow = {
export type Customer = { id: string; name: string };
export type TeamMember = { id: string; name: string };
+export type TaskFilter = "all" | "mine" | "unassigned" | "mine_or_unassigned";
+
+export const FILTER_LABEL: Record
= {
+ all: "Hepsi",
+ mine: "Bana atanmış",
+ unassigned: "Atanmamış",
+ mine_or_unassigned: "Bana atanmış + Atanmamış",
+};
+
export const COLUMNS: { key: TaskStatus; title: string }[] = [
{ key: "backlog", title: "Beklemede" },
{ key: "todo", title: "Yapılacak" },
diff --git a/src/app/(dashboard)/tasks/page.tsx b/src/app/(dashboard)/tasks/page.tsx
index b3f568e..d616e8a 100644
--- a/src/app/(dashboard)/tasks/page.tsx
+++ b/src/app/(dashboard)/tasks/page.tsx
@@ -6,12 +6,19 @@ import { listTasks } from "@/lib/appwrite/task-queries";
import { requireTenant } from "@/lib/appwrite/tenant-guard";
import { createAdminClient } from "@/lib/appwrite/server";
import { TasksBoard } from "./components/tasks-board";
+import type { TaskFilter } from "./components/types";
export const metadata: Metadata = {
title: "İşletmem — Görevler",
};
-export default async function TasksPage() {
+const ALLOWED_FILTERS: TaskFilter[] = ["all", "mine", "unassigned", "mine_or_unassigned"];
+
+export default async function TasksPage({
+ searchParams,
+}: {
+ searchParams: Promise<{ view?: string }>;
+}) {
let ctx;
try {
ctx = await requireTenant();
@@ -19,11 +26,35 @@ export default async function TasksPage() {
redirect("/onboarding");
}
- const [tasks, customers] = await Promise.all([
+ const sp = await searchParams;
+ const filter: TaskFilter =
+ (ALLOWED_FILTERS as string[]).includes(sp.view ?? "")
+ ? (sp.view as TaskFilter)
+ : "mine_or_unassigned";
+
+ const [allTasks, customers] = await Promise.all([
listTasks(ctx.tenantId),
listCustomers(ctx.tenantId),
]);
+ const tasks = allTasks.filter((t) => {
+ const assignee = t.assigneeId ?? "";
+ if (filter === "mine") return assignee === ctx.user.id;
+ if (filter === "unassigned") return !assignee;
+ if (filter === "mine_or_unassigned")
+ return !assignee || assignee === ctx.user.id;
+ return true;
+ });
+
+ const filterCounts = {
+ total: allTasks.length,
+ mine: allTasks.filter((t) => t.assigneeId === ctx.user.id).length,
+ unassigned: allTasks.filter((t) => !t.assigneeId).length,
+ mineOrUnassigned: allTasks.filter(
+ (t) => !t.assigneeId || t.assigneeId === ctx.user.id,
+ ).length,
+ };
+
let teamMembers: { id: string; name: string }[] = [];
try {
const { teams } = createAdminClient();
@@ -45,7 +76,8 @@ export default async function TasksPage() {
{ctx.settings?.companyName ?? "Çalışma alanı"}
Görevler
- Sürükle-bırak ile durumları değiştirin, ekibinizle iş takibini kolaylaştırın.
+ Sürükle-bırak ile durumları değiştirin. Üstteki filtreden başkalarına atanmış
+ görevleri de görebilirsiniz.
@@ -65,6 +97,9 @@ export default async function TasksPage() {
}))}
customers={customers.map((c) => ({ id: c.$id, name: c.name }))}
teamMembers={teamMembers}
+ currentUserId={ctx.user.id}
+ filter={filter}
+ filterCounts={filterCounts}
/>
);
diff --git a/src/lib/appwrite/dashboard-queries.ts b/src/lib/appwrite/dashboard-queries.ts
index 832f70e..72d1ae8 100644
--- a/src/lib/appwrite/dashboard-queries.ts
+++ b/src/lib/appwrite/dashboard-queries.ts
@@ -47,7 +47,10 @@ function monthLabel(d: Date): string {
return MONTH_SHORT[d.getMonth()];
}
-export async function getDashboardData(tenantId: string): Promise