diff --git a/src/app/dashboard/settings/logs/page.tsx b/src/app/dashboard/settings/logs/page.tsx new file mode 100644 index 0000000..40a5086 --- /dev/null +++ b/src/app/dashboard/settings/logs/page.tsx @@ -0,0 +1,106 @@ +import { createClient } from "@/lib/supabase/server" +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table" +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import { Badge } from "@/components/ui/badge" +import { format } from "date-fns" +import { tr } from "date-fns/locale" + +export default async function AuditLogsPage() { + const supabase = await createClient() + + const { data: logs } = await supabase + .from('audit_logs') + .select(` + *, + profiles:user_id (full_name, role) + `) + .order('created_at', { ascending: false }) + .limit(50) + + const getActionBadge = (action: string) => { + if (action.includes('create')) return Oluşturma + if (action.includes('update')) return Güncelleme + if (action.includes('delete')) return Silme + if (action.includes('payment')) return Ödeme + return {action} + } + + const formatActionText = (action: string, entityType: string) => { + switch (action) { + case 'create_reservation': return 'Yeni rezervasyon oluşturdu' + case 'update_reservation_status': return 'Rezervasyon durumunu güncelledi' + case 'add_payment': return 'Ödeme ekledi' + default: return `${entityType} üzerinde ${action} işlemi` + } + } + + return ( +
+
+

İşlem Geçmişi

+

Sistem üzerindeki son aktiviteler.

+
+ + + + Son İşlemler + + + + + + Kullanıcı + İşlem + Detay + Tarih + + + + {logs?.length === 0 ? ( + + + Kayıt bulunamadı. + + + ) : ( + logs?.map((log) => ( + + +
+
+ {log.profiles?.full_name?.substring(0, 2).toUpperCase() || 'US'} +
+ {log.profiles?.full_name || 'Bilinmeyen Kullanıcı'} +
+
+ +
+ {getActionBadge(log.action)} + + {formatActionText(log.action, log.entity_type)} + +
+
+ + {JSON.stringify(log.details)} + + + {format(new Date(log.created_at), 'd MMM yyyy HH:mm', { locale: tr })} + +
+ )) + )} +
+
+
+
+
+ ) +} diff --git a/src/app/dashboard/settings/page.tsx b/src/app/dashboard/settings/page.tsx index 884f492..c760c23 100644 --- a/src/app/dashboard/settings/page.tsx +++ b/src/app/dashboard/settings/page.tsx @@ -1,7 +1,7 @@ import Link from "next/link" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" -import { Utensils, Users } from "lucide-react" +import { Utensils, Users, Activity } from "lucide-react" export default function SettingsPage() { return ( @@ -33,6 +33,19 @@ export default function SettingsPage() { + + + + + + İşlem Geçmişi + + + Sistem üzerindeki tüm aktiviteleri görüntüleyin. + + + + )