import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { listCalendarEvents } from "@/lib/appwrite/calendar-queries"; import { listCustomers } from "@/lib/appwrite/customer-queries"; import { requireTenant } from "@/lib/appwrite/tenant-guard"; import { CalendarClient } from "./components/calendar-client"; export const metadata: Metadata = { title: "İşletmem — Takvim", }; export default async function CalendarPage() { let ctx; try { ctx = await requireTenant(); } catch { redirect("/onboarding"); } const [events, customers] = await Promise.all([ listCalendarEvents(ctx.tenantId), listCustomers(ctx.tenantId), ]); const customerMap = new Map(customers.map((c) => [c.$id, c.name])); return (

{ctx.settings?.companyName ?? "Çalışma alanı"}

Takvim

Toplantılar, randevular ve önemli tarihler.

({ id: e.$id, title: e.title, description: e.description ?? "", start: e.start, end: e.end, allDay: Boolean(e.allDay), customerId: e.customerId ?? "", customerName: e.customerId ? customerMap.get(e.customerId) ?? "" : "", color: e.color ?? "", }))} customers={customers.map((c) => ({ id: c.$id, name: c.name }))} />
); }