Site Yönetimi,Kullanıcı Girişi,Karanlık mod özellikleri db bağlantıları.

This commit is contained in:
2026-01-08 23:56:28 +03:00
parent 6e02336827
commit ddf28e1892
40 changed files with 2545 additions and 96 deletions

View File

@@ -1,126 +1,126 @@
import { createClient } from "@/lib/supabase-server"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { DollarSign, ShoppingCart, Users, CreditCard } from "lucide-react"
import { DollarSign, ShoppingCart, Users, CreditCard, Package } from "lucide-react"
import Link from "next/link"
import { Button } from "@/components/ui/button"
export default async function DashboardPage() {
const supabase = createClient()
// Fetch real data
const { data: products } = await supabase
.from("products")
.select("*")
.order("created_at", { ascending: false })
const totalProducts = products?.length || 0
const totalValue = products?.reduce((acc, product) => acc + (Number(product.price) || 0), 0) || 0
const recentProducts = products?.slice(0, 5) || []
// Calculate unique categories
const categories = new Set(products?.map(p => p.category)).size
export default function DashboardPage() {
return (
<div className="flex-1 space-y-4">
<div className="flex-1 space-y-4 p-8 pt-6">
<div className="flex items-center justify-between space-y-2">
<h2 className="text-3xl font-bold tracking-tight">Genel Bakış</h2>
<div className="flex items-center space-x-2">
<Link href="/dashboard/products/new">
<Button>Ürün Ekle</Button>
</Link>
</div>
</div>
{/* Stats Grid */}
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Toplam Gelir</CardTitle>
<CardTitle className="text-sm font-medium">Toplam Ürün Değeri</CardTitle>
<DollarSign className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">45,231.89</div>
<p className="text-xs text-muted-foreground">+20.1% geçen aya göre</p>
<div className="text-2xl font-bold">{totalValue.toLocaleString('tr-TR', { minimumFractionDigits: 2 })}</div>
<p className="text-xs text-muted-foreground">Stoktaki toplam varlık</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Abonelikler</CardTitle>
<CardTitle className="text-sm font-medium">Toplam Ürün</CardTitle>
<Package className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{totalProducts}</div>
<p className="text-xs text-muted-foreground">Kayıtlı ürün sayısı</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Kategoriler</CardTitle>
<ShoppingCart className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{categories}</div>
<p className="text-xs text-muted-foreground">Aktif kategori</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Son Güncelleme</CardTitle>
<Users className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+2350</div>
<p className="text-xs text-muted-foreground">+180.1% geçen aya göre</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Satışlar</CardTitle>
<CreditCard className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+12,234</div>
<p className="text-xs text-muted-foreground">+19% geçen aya göre</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Aktif Şimdi</CardTitle>
<Users className="h-4 w-4 text-muted-foreground" />
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">+573</div>
<p className="text-xs text-muted-foreground">+201 son bir saatte</p>
<div className="text-2xl font-bold">Şimdi</div>
<p className="text-xs text-muted-foreground">Canlı veri akışı</p>
</CardContent>
</Card>
</div>
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-7">
{/* Recent Sales / Activity */}
<Card className="col-span-4">
<CardHeader>
<CardTitle>Son Hareketler</CardTitle>
<CardTitle>Son Eklenen Ürünler</CardTitle>
<CardDescription>
Bu ay 265+ satış yaptınız.
En son eklenen {recentProducts.length} ürün.
</CardDescription>
</CardHeader>
<CardContent>
{/* Mock List */}
<div className="space-y-8">
<div className="flex items-center">
<div className="h-9 w-9 rounded-full bg-slate-100 flex items-center justify-center">
<span className="font-bold text-xs">OM</span>
{recentProducts.map((product) => (
<div key={product.id} className="flex items-center">
<div className="h-9 w-9 rounded-full bg-slate-100 flex items-center justify-center">
<span className="font-bold text-xs">{product.name.substring(0, 2).toUpperCase()}</span>
</div>
<div className="ml-4 space-y-1">
<p className="text-sm font-medium leading-none">{product.name}</p>
<p className="text-sm text-muted-foreground">{product.category}</p>
</div>
<div className="ml-auto font-medium">{Number(product.price).toLocaleString('tr-TR')}</div>
</div>
<div className="ml-4 space-y-1">
<p className="text-sm font-medium leading-none">Ozan Mehmet</p>
<p className="text-sm text-muted-foreground">ozan@email.com</p>
</div>
<div className="ml-auto font-medium">+1,999.00</div>
</div>
<div className="flex items-center">
<div className="h-9 w-9 rounded-full bg-slate-100 flex items-center justify-center">
<span className="font-bold text-xs"></span>
</div>
<div className="ml-4 space-y-1">
<p className="text-sm font-medium leading-none">Ayşe Özdemir</p>
<p className="text-sm text-muted-foreground">ayse@email.com</p>
</div>
<div className="ml-auto font-medium">+39.00</div>
</div>
<div className="flex items-center">
<div className="h-9 w-9 rounded-full bg-slate-100 flex items-center justify-center">
<span className="font-bold text-xs">MK</span>
</div>
<div className="ml-4 space-y-1">
<p className="text-sm font-medium leading-none">Mehmet Kaya</p>
<p className="text-sm text-muted-foreground">mehmet@email.com</p>
</div>
<div className="ml-auto font-medium">+299.00</div>
</div>
))}
{recentProducts.length === 0 && (
<div className="text-center py-4 text-muted-foreground">Henüz ürün yok.</div>
)}
</div>
</CardContent>
</Card>
{/* Recent Products or Other Info */}
{/* Placeholder for future features or quick actions */}
<Card className="col-span-3">
<CardHeader>
<CardTitle>Son Eklenen Ürünler</CardTitle>
<CardTitle>Hızlı İşlemler</CardTitle>
<CardDescription>
Stoğa yeni giren ürünler.
Yönetim paneli kısayolları.
</CardDescription>
</CardHeader>
<CardContent>
<div className="space-y-4">
<div className="flex justify-between items-center bg-slate-50 p-2 rounded">
<span className="text-sm font-medium">Çelik Kasa EV-100</span>
<span className="text-xs bg-green-100 text-green-700 px-2 py-1 rounded">Stokta</span>
</div>
<div className="flex justify-between items-center bg-slate-50 p-2 rounded">
<span className="text-sm font-medium">Ofis Tipi XYZ</span>
<span className="text-xs bg-yellow-100 text-yellow-700 px-2 py-1 rounded">Azaldı</span>
</div>
<div className="flex justify-between items-center bg-slate-50 p-2 rounded">
<span className="text-sm font-medium">Otel Kasası H-20</span>
<span className="text-xs bg-green-100 text-green-700 px-2 py-1 rounded">Stokta</span>
</div>
<div className="flex flex-col space-y-2">
<Link href="/dashboard/products/new">
<Button variant="outline" className="w-full justify-start">
<PlusIcon className="mr-2 h-4 w-4" /> Yeni Ürün Ekle
</Button>
</Link>
<Button variant="outline" className="w-full justify-start" disabled>
<ShoppingCart className="mr-2 h-4 w-4" /> Siparişleri Yönet (Yakında)
</Button>
</div>
</CardContent>
</Card>
@@ -128,3 +128,23 @@ export default function DashboardPage() {
</div>
)
}
function PlusIcon(props: any) {
return (
<svg
{...props}
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M5 12h14" />
<path d="M12 5v14" />
</svg>
)
}