'use client'
import { useState } from 'react'
import Link from 'next/link'
import { Plus, Search, Layers, Key, ArrowUpRight, Clock, Sparkles, SlidersHorizontal, ShieldCheck, Zap } from 'lucide-react'
import { App } from '@/types'
import { AppIcon } from './AppIcon'
interface DashboardApp extends App {
config_count?: number | string
}
interface Props {
initialApps: DashboardApp[]
totalConfigsCount: number
totalAuditCount: number
}
export function DashboardClient({ initialApps, totalConfigsCount, totalAuditCount }: Props) {
const [search, setSearch] = useState('')
const filteredApps = initialApps.filter(app =>
app.name.toLowerCase().includes(search.toLowerCase()) ||
app.slug.toLowerCase().includes(search.toLowerCase()) ||
(app.description && app.description.toLowerCase().includes(search.toLowerCase()))
)
return (
{/* Hero / Stat cards */}
{/* Stat 1 */}
{initialApps.length}
Aktif Servis
{/* Stat 2 */}
{totalConfigsCount}
Değer Tanımlı
{/* Stat 3 */}
{/* Stat 4 */}
{totalAuditCount}
Audit Kaydı
{/* Action Header & Search */}
{/* App Cards Grid */}
{filteredApps.length === 0 ? (
{search ? 'Eşleşen uygulama bulunamadı' : 'Henüz hiç uygulama eklenmemiş'}
{search
? `"${search}" aramasıyla eşleşen bir sonuç yok. Başka bir anahtar kelime deneyin.`
: 'ConfigVault ile mobil ve web uygulamalarınızın ortam değişkenlerini dinamik olarak yönetmeye başlamak için ilk uygulamanızı ekleyin.'}
{!search && (
İlk Uygulamayı Oluştur
)}
) : (
{filteredApps.map(app => (
))}
)}
)
}
function AppCard({ app }: { app: DashboardApp }) {
const formattedDate = new Date(app.updated_at).toLocaleDateString('tr-TR', {
day: 'numeric',
month: 'short',
year: 'numeric',
})
// Color theme generator based on app name initial
const initial = app.name.charAt(0).toUpperCase()
const gradients = [
'from-emerald-500 to-teal-700',
'from-cyan-500 to-blue-700',
'from-indigo-500 to-purple-700',
'from-amber-500 to-orange-700',
'from-rose-500 to-pink-700',
]
const gradientIndex = (initial.charCodeAt(0) || 0) % gradients.length
const bgGradient = gradients[gradientIndex]
return (
{/* Ambient background hover flare */}
{/* Top bar: Avatar & Arrow */}
{/* Title & Slug */}
{app.name}
slug:
{app.slug}
{/* Description */}
{app.description || Açıklama girilmemiş }
{/* Bottom meta details */}
{Number(app.config_count) || 0} config kaydı
{formattedDate}
{/* Env tag pills */}
prod
stage
dev
)
}