feat: all core modules — properties, customers, searches, matches, presentations, activities, investors + public sunum page

- Server actions: property/customer/search/presentation/activity/investor CRUD
- Matching engine: matchPropertyToSearches + syncMatchesForSearch on search save
- UI: form sheets + table clients for all modules
- Public /sunum/[token] page (no auth) with property card grid + expiry check
- All pages force-dynamic for auth guard compatibility
This commit is contained in:
egecankomur
2026-05-05 12:03:48 +03:00
parent 2f17c342ca
commit 4ef0482732
34 changed files with 3174 additions and 36 deletions
@@ -0,0 +1,124 @@
"use client";
import { useState } from "react";
import { MoreHorizontal, Plus, Pencil, Trash2 } from "lucide-react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import {
Table, TableBody, TableCell, TableHead, TableHeader, TableRow,
} from "@/components/ui/table";
import {
DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { deleteCustomerAction } from "@/lib/appwrite/customer-actions";
import { CustomerFormSheet } from "./customer-form-sheet";
import type { Customer } from "@/lib/appwrite/schema";
import { CUSTOMER_TYPE_LABELS } from "@/lib/appwrite/schema";
interface CustomersClientProps {
initialCustomers: Customer[];
}
export function CustomersClient({ initialCustomers }: CustomersClientProps) {
const [customers, setCustomers] = useState(initialCustomers);
const [sheetOpen, setSheetOpen] = useState(false);
const [editing, setEditing] = useState<Customer | null>(null);
function openCreate() {
setEditing(null);
setSheetOpen(true);
}
function openEdit(c: Customer) {
setEditing(c);
setSheetOpen(true);
}
async function handleDelete(c: Customer) {
if (!confirm(`"${c.name}" silinsin mi?`)) return;
const result = await deleteCustomerAction(c.$id);
if (result.ok) {
setCustomers((prev) => prev.filter((x) => x.$id !== c.$id));
toast.success("Müşteri silindi.");
} else {
toast.error(result.error ?? "Silinemedi.");
}
}
return (
<div className="flex flex-col gap-4">
<div className="flex items-center justify-between">
<h1 className="text-2xl font-bold">Müşteriler</h1>
<Button onClick={openCreate} size="sm">
<Plus className="mr-1.5 size-4" />
Yeni Müşteri
</Button>
</div>
<div className="rounded-md border">
<Table>
<TableHeader>
<TableRow>
<TableHead>Ad Soyad</TableHead>
<TableHead>Tip</TableHead>
<TableHead>Telefon</TableHead>
<TableHead>Email</TableHead>
<TableHead />
</TableRow>
</TableHeader>
<TableBody>
{customers.length === 0 && (
<TableRow>
<TableCell colSpan={5} className="text-muted-foreground text-center py-10">
Henüz müşteri yok.
</TableCell>
</TableRow>
)}
{customers.map((c) => (
<TableRow key={c.$id}>
<TableCell className="font-medium">{c.name}</TableCell>
<TableCell>
<Badge variant="outline">
{CUSTOMER_TYPE_LABELS[c.type] ?? c.type}
</Badge>
</TableCell>
<TableCell className="text-muted-foreground">{c.phone ?? "—"}</TableCell>
<TableCell className="text-muted-foreground">{c.email ?? "—"}</TableCell>
<TableCell>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon" className="size-8">
<MoreHorizontal className="size-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => openEdit(c)}>
<Pencil className="mr-2 size-4" />
Düzenle
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => handleDelete(c)}
className="text-destructive focus:text-destructive"
>
<Trash2 className="mr-2 size-4" />
Sil
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
<CustomerFormSheet
open={sheetOpen}
onOpenChange={setSheetOpen}
customer={editing}
/>
</div>
);
}