Update application features and add scripts (core changes)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { auth } from '@/lib/auth'
|
||||
import { AdminSidebar } from '@/components/admin/AdminSidebar'
|
||||
import { AdminHeader } from '@/components/admin/AdminHeader'
|
||||
import { SessionProvider } from 'next-auth/react'
|
||||
|
||||
export default async function AdminLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await auth()
|
||||
|
||||
return (
|
||||
<SessionProvider session={session}>
|
||||
<div className="flex h-screen bg-[#F8FAFC] dark:bg-gray-950 overflow-hidden">
|
||||
<AdminSidebar />
|
||||
<div className="flex-1 flex flex-col min-w-0 overflow-hidden relative">
|
||||
<AdminHeader
|
||||
userEmail={session?.user?.email}
|
||||
userName={session?.user?.name}
|
||||
/>
|
||||
<main className="flex-1 overflow-y-auto p-4 sm:p-6 lg:p-8 bg-gray-50/50 dark:bg-gray-900/50">
|
||||
<div className="mx-auto max-w-7xl">
|
||||
{children}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</SessionProvider>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
'use client'
|
||||
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { Users, Activity, UserPlus, Zap } from 'lucide-react'
|
||||
import { motion } from 'framer-motion'
|
||||
import { useSession } from 'next-auth/react'
|
||||
|
||||
export default function AdminDashboardPage() {
|
||||
const { data: session } = useSession()
|
||||
|
||||
const stats = [
|
||||
{ name: 'Toplam Kullanıcı', stat: '1,245', icon: Users, color: 'text-blue-600 dark:text-blue-400' },
|
||||
{ name: 'Aktif Oturumlar', stat: '42', icon: Activity, color: 'text-green-600 dark:text-green-400' },
|
||||
{ name: 'Yeni Kayıtlar', stat: '8', icon: UserPlus, color: 'text-orange-600 dark:text-orange-400' },
|
||||
{ name: 'Sistem Durumu', stat: 'Online', icon: Zap, color: 'text-indigo-600 dark:text-indigo-400' },
|
||||
]
|
||||
|
||||
const container = {
|
||||
hidden: { opacity: 0 },
|
||||
show: {
|
||||
opacity: 1,
|
||||
transition: {
|
||||
staggerChildren: 0.1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const item = {
|
||||
hidden: { opacity: 0, y: 20 },
|
||||
show: { opacity: 1, y: 0 }
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: -20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.4 }}
|
||||
>
|
||||
<h2 className="text-3xl font-bold tracking-tight text-gray-900 dark:text-white">Dashboard</h2>
|
||||
<p className="text-gray-500 dark:text-gray-400 mt-2">
|
||||
Hoş geldiniz, {session?.user?.name || session?.user?.email || 'Admin'}. İşte projenizin genel görünümü.
|
||||
</p>
|
||||
</motion.div>
|
||||
|
||||
<motion.div
|
||||
variants={container}
|
||||
initial="hidden"
|
||||
animate="show"
|
||||
className="grid gap-4 md:grid-cols-2 lg:grid-cols-4"
|
||||
>
|
||||
{stats.map((stat, i) => (
|
||||
<motion.div key={stat.name} variants={item}>
|
||||
<Card className="border-gray-200 dark:border-gray-800 shadow-sm transition-all hover:shadow-md dark:bg-gray-950/50 backdrop-blur-sm">
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium text-gray-500 dark:text-gray-400">
|
||||
{stat.name}
|
||||
</CardTitle>
|
||||
<stat.icon className={`h-4 w-4 ${stat.color}`} />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold text-gray-900 dark:text-white">{stat.stat}</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</motion.div>
|
||||
))}
|
||||
</motion.div>
|
||||
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.4, delay: 0.4 }}
|
||||
>
|
||||
<Card className="border-gray-200 dark:border-gray-800 shadow-sm dark:bg-gray-950/50 backdrop-blur-sm">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg text-gray-900 dark:text-white">Son Aktiviteler</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="py-4 text-sm text-gray-500 dark:text-gray-400 text-center border-2 border-dashed rounded-lg border-gray-200 dark:border-gray-800">
|
||||
Henüz aktivite kaydı bulunmuyor.
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</motion.div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { RoomForm } from '@/components/admin/RoomForm'
|
||||
import { ArrowLeft } from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
import { db } from '@/lib/db'
|
||||
import { notFound } from 'next/navigation'
|
||||
|
||||
export default async function EditRoomPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params
|
||||
const room = await db.room.findUnique({
|
||||
where: { id }
|
||||
})
|
||||
|
||||
if (!room) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center space-x-4">
|
||||
<Link href="/admin/rooms" className="text-gray-500 hover:text-gray-900 dark:hover:text-white transition-colors">
|
||||
<ArrowLeft className="h-6 w-6" />
|
||||
</Link>
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Odayı Düzenle</h2>
|
||||
<p className="text-gray-500 dark:text-gray-400 mt-2">
|
||||
Oda bilgilerini güncellemek için aşağıdaki formu kullanın.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<RoomForm initialData={room} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { RoomForm } from '@/components/admin/RoomForm'
|
||||
import { ArrowLeft } from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
|
||||
export default function CreateRoomPage() {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center space-x-4">
|
||||
<Link href="/admin/rooms" className="text-gray-500 hover:text-gray-900 dark:hover:text-white transition-colors">
|
||||
<ArrowLeft className="h-6 w-6" />
|
||||
</Link>
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Yeni Oda Ekle</h2>
|
||||
<p className="text-gray-500 dark:text-gray-400 mt-2">
|
||||
Sisteme yeni bir oda eklemek için aşağıdaki formu doldurun.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<RoomForm />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import { db } from '@/lib/db'
|
||||
import Link from 'next/link'
|
||||
import { Plus, Edit, Trash2, MoreHorizontal } from 'lucide-react'
|
||||
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,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuGroup,
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
|
||||
export default async function AdminRoomsPage() {
|
||||
const rooms = await db.room.findMany({
|
||||
orderBy: { createdAt: 'desc' }
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||
<div>
|
||||
<h2 className="text-3xl font-bold tracking-tight text-gray-900 dark:text-white">Odalar</h2>
|
||||
<p className="text-gray-500 dark:text-gray-400 mt-2">
|
||||
Sistemdeki tüm odaları buradan yönetebilirsiniz.
|
||||
</p>
|
||||
</div>
|
||||
<Link href="/admin/rooms/create">
|
||||
<Button className="w-full sm:w-auto">
|
||||
<Plus className="mr-2 h-4 w-4" /> Yeni Oda Ekle
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="bg-white dark:bg-gray-950/50 border border-gray-200 dark:border-gray-800 rounded-lg shadow-sm backdrop-blur-sm">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow className="hover:bg-transparent">
|
||||
<TableHead className="w-24">Resimler</TableHead>
|
||||
<TableHead>Ad (TR)</TableHead>
|
||||
<TableHead>Tip</TableHead>
|
||||
<TableHead>Kapasite</TableHead>
|
||||
<TableHead>Fiyat</TableHead>
|
||||
<TableHead>Durum</TableHead>
|
||||
<TableHead className="text-right">İşlemler</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{rooms.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={7} className="h-24 text-center text-gray-500">
|
||||
Henüz oda bulunmuyor.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : (
|
||||
rooms.map((room) => (
|
||||
<TableRow key={room.id} className="group">
|
||||
<TableCell>
|
||||
<div className="flex flex-col gap-2">
|
||||
{room.imageUrl ? (
|
||||
<img
|
||||
src={room.imageUrl}
|
||||
alt={room.nameTr}
|
||||
className="h-10 w-16 rounded-md object-cover border border-gray-200 dark:border-gray-800"
|
||||
/>
|
||||
) : (
|
||||
<div className="h-10 w-16 rounded-md bg-gray-100 dark:bg-gray-800 flex items-center justify-center border border-gray-200 dark:border-gray-800">
|
||||
<span className="text-[10px] text-gray-400 dark:text-gray-500">Yok</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{room.images && room.images.length > 0 && (
|
||||
<div className="flex gap-1">
|
||||
{room.images.slice(0, 3).map((img, i) => (
|
||||
<img key={i} src={img} alt="galeri" className="h-6 w-8 rounded object-cover border border-gray-200 dark:border-gray-800" />
|
||||
))}
|
||||
{room.images.length > 3 && (
|
||||
<div className="h-6 w-8 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center text-[10px] font-medium border border-gray-200 dark:border-gray-800 text-gray-600 dark:text-gray-300">
|
||||
+{room.images.length - 3}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="font-medium text-gray-900 dark:text-white">
|
||||
{room.nameTr}
|
||||
</TableCell>
|
||||
<TableCell className="text-gray-500 dark:text-gray-400">
|
||||
{room.type === 'STUDIO_1_0' ? 'Stüdyo (1+0)' : 'Süit (1+1)'}
|
||||
</TableCell>
|
||||
<TableCell className="text-gray-500 dark:text-gray-400">
|
||||
{room.capacity} Kişi
|
||||
</TableCell>
|
||||
<TableCell className="text-gray-500 dark:text-gray-400">
|
||||
{room.price ? `₺${room.price}` : '-'}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{room.available ? (
|
||||
<Badge variant="outline" className="bg-green-50 text-green-700 border-green-200 dark:bg-green-950/30 dark:text-green-400 dark:border-green-900">
|
||||
Müsait
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="outline" className="bg-red-50 text-red-700 border-red-200 dark:bg-red-950/30 dark:text-red-400 dark:border-red-900">
|
||||
Kapalı
|
||||
</Badge>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger render={<Button variant="ghost" className="h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity focus:opacity-100" />}>
|
||||
<span className="sr-only">Menüyü aç</span>
|
||||
<MoreHorizontal className="h-4 w-4" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-[160px]">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuLabel>İşlemler</DropdownMenuLabel>
|
||||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem render={<Link href={`/admin/rooms/${room.id}/edit`} />}>
|
||||
<Edit className="mr-2 h-4 w-4 text-blue-600 dark:text-blue-400" />
|
||||
Düzenle
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem render={<form action={async () => {
|
||||
'use server'
|
||||
const { deleteRoom } = await import('@/lib/actions/room')
|
||||
await deleteRoom(room.id)
|
||||
}} />}>
|
||||
<button type="submit" className="w-full flex items-center cursor-pointer text-red-600 dark:text-red-400 focus:text-red-600">
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
Sil
|
||||
</button>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user