first commit

This commit is contained in:
AyrisAI
2026-07-12 20:18:55 +03:00
commit cbc59222c2
65 changed files with 16871 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import { mockDb } from '@/lib/mockDb'
export default async function AdminCategoriesPage() {
const categories = await mockDb.getCategories()
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">kategoriler</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Sistemde listelenen işletmelerin sınıflandırıldığı ana kategoriler.
</p>
</div>
</div>
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm overflow-hidden max-w-4xl">
<table className="min-w-full divide-y divide-pine/8 text-sm">
<thead className="bg-stone-deep/40 text-shutter font-mono text-[10px] uppercase tracking-wider">
<tr>
<th className="px-6 py-4 text-left">ID</th>
<th className="px-6 py-4 text-left">Slug</th>
<th className="px-6 py-4 text-left">Adı (TR)</th>
<th className="px-6 py-4 text-left">Name (EN)</th>
<th className="px-6 py-4 text-left">Имя (RU)</th>
</tr>
</thead>
<tbody className="divide-y divide-dashed divide-pine/8 text-ink/85 font-medium">
{categories.map((cat) => (
<tr key={cat.id} className="hover:bg-stone/20 transition duration-150">
<td className="px-6 py-4 font-mono text-xs text-shutter">{cat.id}</td>
<td className="px-6 py-4 font-mono text-xs font-bold text-turquoise">{cat.slug}</td>
<td className="px-6 py-4 font-heading font-bold text-pine lowercase text-sm">{cat.nameTr}</td>
<td className="px-6 py-4 text-xs">{cat.nameEn}</td>
<td className="px-6 py-4 text-xs">{cat.nameRu}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)
}
+123
View File
@@ -0,0 +1,123 @@
'use client'
import { signOut } from 'next-auth/react'
import { Link, usePathname } from '@/i18n/routing'
import { LayoutDashboard, FileText, Inbox, ClipboardList, Map, LogOut, Menu, X } from 'lucide-react'
import { useState } from 'react'
export default function AdminLayout({ children }: { children: React.ReactNode }) {
const pathname = usePathname()
const [sidebarOpen, setSidebarOpen] = useState(false)
const navigation = [
{ name: 'Dashboard', href: '/admin', icon: LayoutDashboard },
{ name: 'Mekanlar', href: '/admin/listings', icon: ClipboardList },
{ name: 'Başvurular', href: '/admin/submissions', icon: FileText },
{ name: 'Mesajlar', href: '/admin/messages', icon: Inbox },
{ name: 'Kategoriler', href: '/admin/categories', icon: LayoutDashboard },
{ name: 'Mahalleler', href: '/admin/neighborhoods', icon: Map },
]
return (
<div className="min-h-screen bg-stone text-ink flex font-sans">
{/* Mobile sidebar backdrop */}
{sidebarOpen && (
<div
className="fixed inset-0 z-40 bg-pine/80 lg:hidden"
onClick={() => setSidebarOpen(false)}
/>
)}
{/* Sidebar */}
<div className={`
fixed inset-y-0 left-0 z-50 w-64 bg-pine border-r border-white/10
transform transition-transform duration-200 ease-in-out lg:translate-x-0 lg:static lg:inset-0
${sidebarOpen ? 'translate-x-0' : '-translate-x-full'}
`}>
<div className="h-full flex flex-col justify-between">
<div>
{/* Sidebar Brand Header */}
<div className="h-20 flex items-center px-6 border-b border-white/10 gap-3">
<Link href="/" className="flex items-center gap-2.5">
<div className="w-9 h-9 rounded-full border border-stone/30 flex items-center justify-center relative bg-paper shrink-0">
<div className="absolute inset-[2px] rounded-full border border-dashed border-turquoise/50" />
<span className="font-heading font-extrabold text-pine text-xs tracking-tighter">ML</span>
</div>
<div>
<h1 className="font-heading font-extrabold text-sm text-stone tracking-tight leading-none lowercase">
marmaris <span className="text-turquoise">local</span>
</h1>
<span className="text-[8px] font-mono text-shutter tracking-wider uppercase">backoffice</span>
</div>
</Link>
<button
className="ml-auto lg:hidden text-stone/70 hover:text-stone"
onClick={() => setSidebarOpen(false)}
>
<X className="h-5 w-5" />
</button>
</div>
{/* Navigation links */}
<nav className="px-3 py-6 space-y-1.5 overflow-y-auto">
{navigation.map((item) => {
const isActive = pathname === item.href || (item.href !== '/admin' && pathname.startsWith(item.href))
return (
<Link
key={item.name}
href={item.href}
onClick={() => setSidebarOpen(false)}
className={`
flex items-center px-4 py-3 text-xs font-semibold rounded-xl transition-all duration-150
${isActive
? 'bg-white/5 border-l-4 border-turquoise text-stone pl-3'
: 'text-stone/75 hover:bg-white/5 hover:text-stone'}
`}
>
<item.icon className={`mr-3 flex-shrink-0 h-4.5 w-4.5 ${isActive ? 'text-turquoise' : 'text-stone/50'}`} />
{item.name}
</Link>
)
})}
</nav>
</div>
{/* Logout Action */}
<div className="p-4 border-t border-white/10">
<button
onClick={() => signOut({ callbackUrl: '/' })}
className="flex w-full items-center px-4 py-3 text-xs font-semibold text-red-400 hover:text-red-300 rounded-xl hover:bg-red-950/20 transition-colors"
>
<LogOut className="mr-3 h-4.5 w-4.5 text-red-400/70" />
Çıkış Yap
</button>
</div>
</div>
</div>
{/* Main content */}
<div className="flex-1 flex flex-col min-w-0 overflow-hidden">
{/* Mobile Header Bar */}
<header className="h-16 flex items-center lg:hidden bg-pine border-b border-white/10 px-4 shrink-0 text-stone">
<button
onClick={() => setSidebarOpen(true)}
className="text-stone hover:text-turquoise focus:outline-none"
>
<Menu className="h-6 w-6" />
</button>
<div className="ml-4 flex items-center gap-2">
<div className="w-8 h-8 rounded-full border border-stone/20 flex items-center justify-center relative bg-paper shrink-0">
<span className="font-heading font-extrabold text-pine text-[10px] tracking-tighter">ML</span>
</div>
<span className="text-sm font-heading font-bold lowercase">marmaris local <span className="text-turquoise">backoffice</span></span>
</div>
</header>
{/* Page Area */}
<main className="flex-1 overflow-y-auto p-4 sm:p-6 lg:p-8">
{children}
</main>
</div>
</div>
)
}
@@ -0,0 +1,444 @@
'use client'
import { useState } from 'react'
import { useRouter } from 'next/navigation'
import { createOrUpdateListingAction } from '@/app/actions'
import { ArrowLeft, Save } from 'lucide-react'
import { Link } from '@/i18n/routing'
interface Option {
value: string
label: string
}
interface FormProps {
listing: any | null
categories: Option[]
neighborhoods: Option[]
}
export default function ListingForm({ listing, categories, neighborhoods }: FormProps) {
const router = useRouter()
const [activeTab, setActiveTab] = useState<'tr' | 'en' | 'ru'>('tr')
const [loading, setLoading] = useState(false)
const [error, setError] = useState('')
const [success, setSuccess] = useState(false)
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
setLoading(true)
setError('')
setSuccess(false)
const formData = new FormData(e.currentTarget)
if (listing) {
formData.append('id', listing.id)
}
try {
const res = await createOrUpdateListingAction(formData)
if (res.error) {
setError(res.error)
} else {
setSuccess(true)
setTimeout(() => {
router.push('/admin/listings')
router.refresh()
}, 1500)
}
} catch (err) {
setError('İşlem sırasında bir hata oluştu.')
} finally {
setLoading(false)
}
}
const initialImages = listing?.images || []
const img1 = initialImages[0]?.url || ''
const img2 = initialImages[1]?.url || ''
return (
<form onSubmit={handleSubmit} className="space-y-6">
{error && (
<div className="bg-bougainvillea/10 border border-bougainvillea/25 text-bougainvillea p-4 rounded-xl text-xs font-semibold">
{error}
</div>
)}
{success && (
<div className="bg-turquoise/10 border border-turquoise/25 text-turquoise p-4 rounded-xl text-xs font-bold">
Mekan başarıyla kaydedildi! Yönlendiriliyorsunuz...
</div>
)}
{/* Language tabs */}
<div className="border-b border-pine/8">
<div className="flex gap-2">
{(['tr', 'en', 'ru'] as const).map((lang) => {
const label = lang === 'tr' ? '🇹🇷 Türkçe' : lang === 'en' ? '🇬🇧 English' : '🇷🇺 Русский'
const isTabActive = activeTab === lang
return (
<button
key={lang}
type="button"
onClick={() => setActiveTab(lang)}
className={`py-3 px-4 font-heading font-bold text-xs border-b-2 transition lowercase ${
isTabActive
? 'border-turquoise text-turquoise'
: 'border-transparent text-shutter hover:text-pine'
}`}
>
{label}
</button>
)
})}
</div>
</div>
{/* Multilingual input fields */}
<div className="space-y-4">
{/* TR Tab */}
{activeTab === 'tr' && (
<div className="space-y-4">
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Mekan Adı (TR) *</label>
<input
type="text"
name="nameTr"
required
defaultValue={listing?.nameTr || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
placeholder="Örn: İskele Balık Ocakbaşı"
/>
</div>
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Açıklama (TR) *</label>
<textarea
name="descriptionTr"
required
rows={4}
defaultValue={listing?.descriptionTr || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
placeholder="Türkçe tanıtım metni..."
/>
</div>
</div>
)}
{/* EN Tab */}
{activeTab === 'en' && (
<div className="space-y-4">
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Mekan Adı (EN) *</label>
<input
type="text"
name="nameEn"
required
defaultValue={listing?.nameEn || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
placeholder="Örn: Iskele Fish & Grill"
/>
</div>
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Açıklama (EN) *</label>
<textarea
name="descriptionEn"
required
rows={4}
defaultValue={listing?.descriptionEn || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
placeholder="English description..."
/>
</div>
</div>
)}
{/* RU Tab */}
{activeTab === 'ru' && (
<div className="space-y-4">
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Mekan Adı (RU) *</label>
<input
type="text"
name="nameRu"
required
defaultValue={listing?.nameRu || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
placeholder="Örn: Рыбный Гриль Искеле"
/>
</div>
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Açıklama (RU) *</label>
<textarea
name="descriptionRu"
required
rows={4}
defaultValue={listing?.descriptionRu || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
placeholder="Russian description..."
/>
</div>
</div>
)}
</div>
<hr className="border-dashed border-pine/8" />
{/* Global fields */}
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
{/* Slug */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">URL Slug *</label>
<input
type="text"
name="slug"
required
defaultValue={listing?.slug || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink font-mono"
placeholder="iskele-balik-ocakbasi"
/>
</div>
{/* Categories */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Kategori *</label>
<select
name="categoryId"
required
defaultValue={listing?.categoryId || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink appearance-none"
>
<option value="">Kategori seçin...</option>
{categories.map((c) => (
<option key={c.value} value={c.value}>
{c.label}
</option>
))}
</select>
</div>
{/* Neighborhoods */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Mahalle/Bölge *</label>
<select
name="neighborhoodId"
required
defaultValue={listing?.neighborhoodId || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink appearance-none"
>
<option value="">Mahalle seçin...</option>
{neighborhoods.map((n) => (
<option key={n.value} value={n.value}>
{n.label}
</option>
))}
</select>
</div>
{/* Address */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Açık Adres *</label>
<input
type="text"
name="address"
required
defaultValue={listing?.address || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
placeholder="Yat Limanı No:12, Marmaris"
/>
</div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-4 gap-4">
{/* Phone */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Telefon</label>
<input
type="text"
name="phone"
defaultValue={listing?.phone || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink font-mono"
placeholder="+90 252..."
/>
</div>
{/* Whatsapp */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">WhatsApp</label>
<input
type="text"
name="whatsapp"
defaultValue={listing?.whatsapp || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink font-mono"
placeholder="+90 532..."
/>
</div>
{/* Website */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Web Sitesi</label>
<input
type="text"
name="website"
defaultValue={listing?.website || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink font-mono"
placeholder="https://..."
/>
</div>
{/* Instagram */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Instagram</label>
<input
type="text"
name="instagram"
defaultValue={listing?.instagram || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink font-mono"
placeholder="https://instagram.com/..."
/>
</div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-4 gap-4">
{/* Price range */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Fiyat Aralığı (1-3) *</label>
<select
name="priceRange"
required
defaultValue={listing?.priceRange || 2}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
>
<option value="1"> (Ekonomik)</option>
<option value="2"> (Orta)</option>
<option value="3"> (Lüks)</option>
</select>
</div>
{/* Rating */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Puan (0.0 - 5.0)</label>
<input
type="number"
name="rating"
step="0.1"
min="0"
max="5"
defaultValue={listing?.rating || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink font-mono"
placeholder="4.8"
/>
</div>
{/* Latitude */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Enlem (Lat)</label>
<input
type="number"
name="latitude"
step="0.0001"
defaultValue={listing?.latitude || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink font-mono"
placeholder="36.8524"
/>
</div>
{/* Longitude */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Boylam (Lng)</label>
<input
type="number"
name="longitude"
step="0.0001"
defaultValue={listing?.longitude || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink font-mono"
placeholder="28.2741"
/>
</div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
{/* Opening hours */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Çalışma Saatleri</label>
<input
type="text"
name="openingHours"
defaultValue={listing?.openingHours?.all || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
placeholder="Örn: 12:00 - 00:00"
/>
</div>
{/* Approved toggle */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Yerel Onaylı Mührü</label>
<select
name="isLocalApproved"
defaultValue={listing?.isLocalApproved ? 'true' : 'false'}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink"
>
<option value="false">Normal Mekan</option>
<option value="true">Yerel Onaylı (Mühürlü)</option>
</select>
</div>
</div>
{/* Image Upload fields */}
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4 border-t border-dashed border-pine/8 pt-6">
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Görsel 1 (Dosya Yükle)</label>
<input
type="file"
name="imageFile1"
accept="image/*"
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink file:mr-3 file:py-1 file:px-2.5 file:rounded-lg file:border-0 file:text-xs file:font-semibold file:bg-pine file:text-stone hover:file:opacity-90 cursor-pointer"
/>
{img1 && (
<div className="mt-2 text-xs flex items-center gap-2">
<span className="text-shutter/65">Mevcut Görsel:</span>
<a href={img1} target="_blank" rel="noopener noreferrer" className="text-turquoise hover:underline font-mono truncate max-w-xs">{img1}</a>
<input type="hidden" name="imageUrl1" value={img1} />
</div>
)}
</div>
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">Görsel 2 (Dosya Yükle)</label>
<input
type="file"
name="imageFile2"
accept="image/*"
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink file:mr-3 file:py-1 file:px-2.5 file:rounded-lg file:border-0 file:text-xs file:font-semibold file:bg-pine file:text-stone hover:file:opacity-90 cursor-pointer"
/>
{img2 && (
<div className="mt-2 text-xs flex items-center gap-2">
<span className="text-shutter/65">Mevcut Görsel:</span>
<a href={img2} target="_blank" rel="noopener noreferrer" className="text-turquoise hover:underline font-mono truncate max-w-xs">{img2}</a>
<input type="hidden" name="imageUrl2" value={img2} />
</div>
)}
</div>
</div>
<div className="flex gap-4 pt-4 border-t border-dashed border-pine/8">
<Link
href="/admin/listings"
className="inline-flex items-center gap-1.5 px-5 py-3 border border-pine/20 rounded-xl text-xs font-bold text-pine hover:bg-stone/30 transition duration-150"
>
<ArrowLeft className="w-4 h-4" />
İptal
</Link>
<button
type="submit"
disabled={loading}
className="inline-flex items-center gap-1.5 px-5 py-3 bg-turquoise hover:bg-turquoise/90 disabled:opacity-75 text-paper rounded-xl text-xs font-bold shadow-sm transition duration-150"
>
<Save className="w-4 h-4" />
{loading ? 'Kaydediliyor...' : 'Kaydet'}
</button>
</div>
</form>
)
}
+56
View File
@@ -0,0 +1,56 @@
import { mockDb } from '@/lib/mockDb'
import ListingForm from './ListingForm'
import { notFound } from 'next/navigation'
interface Props {
params: Promise<{ locale: string; id: string }>
}
export default async function AdminListingEditPage({ params }: Props) {
const { locale, id } = await params
const categories = await mockDb.getCategories()
const neighborhoods = await mockDb.getNeighborhoods()
let listing = null
if (id !== 'new') {
listing = await mockDb.getListingById(id)
if (!listing) {
notFound()
}
}
const categoryOptions = categories.map(c => ({
value: c.id,
label: c.nameTr
}))
const neighborhoodOptions = neighborhoods.map(n => ({
value: n.id,
label: n.nameTr
}))
return (
<div className="space-y-6 max-w-4xl">
<div>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">
{id === 'new' ? 'yeni mekan ekle' : 'mekanı düzenle'}
</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
{id === 'new'
? 'Rehbere eklenecek yeni işletme bilgilerini girin.'
: 'Mevcut mekan bilgilerini güncelleyin.'}
</p>
</div>
<div className="bg-paper border border-pine/8 rounded-3xl shadow-sm p-6 sm:p-8">
<ListingForm
listing={listing}
categories={categoryOptions}
neighborhoods={neighborhoodOptions}
/>
</div>
</div>
)
}
+115
View File
@@ -0,0 +1,115 @@
import { mockDb } from '@/lib/mockDb'
import { deleteListingAction } from '@/app/actions'
import { Link } from '@/i18n/routing'
import { Edit, Trash, Plus, CheckCircle } from 'lucide-react'
export default async function AdminListingsPage() {
const listings = await mockDb.getListings()
return (
<div className="space-y-6">
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">mekanlar</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Marmaris Local rehberinde kayıtlı olan restoran, apart otel ve yerel hizmetlerin listesi.
</p>
</div>
<Link
href="/admin/listings/new"
className="inline-flex items-center gap-1.5 bg-turquoise hover:bg-turquoise/90 text-paper text-xs font-bold py-3 px-5 rounded-xl shadow-sm transition active:scale-95 duration-150"
>
<Plus className="w-4 h-4" />
Yeni Mekan Ekle
</Link>
</div>
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm overflow-hidden">
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-pine/8 text-sm">
<thead className="bg-stone-deep/40 text-shutter font-mono text-[10px] uppercase tracking-wider">
<tr>
<th className="px-6 py-4 text-left">Görsel</th>
<th className="px-6 py-4 text-left">Mekan</th>
<th className="px-6 py-4 text-left">Kategori & Konum</th>
<th className="px-6 py-4 text-left">Fiyat & Puan</th>
<th className="px-6 py-4 text-left">Mühür</th>
<th className="px-6 py-4 text-right">İşlemler</th>
</tr>
</thead>
<tbody className="divide-y divide-dashed divide-pine/8 text-ink/80">
{listings.length === 0 ? (
<tr>
<td colSpan={6} className="px-6 py-12 text-center text-xs text-shutter font-medium">
Henüz kayıtlı mekan bulunmamaktadır.
</td>
</tr>
) : (
listings.map((l) => {
const mainImage = l.images && l.images.length > 0 ? l.images[0].url : 'https://images.unsplash.com/photo-1555396273-367ea4eb4db5?w=800&auto=format&fit=crop&q=80'
return (
<tr key={l.id} className="hover:bg-stone/20 transition duration-150">
<td className="px-6 py-4 whitespace-nowrap">
<div className="h-12 w-16 relative rounded-lg overflow-hidden bg-stone border border-pine/8">
<img src={mainImage} alt={l.nameTr} className="object-cover w-full h-full" />
</div>
</td>
<td className="px-6 py-4">
<div className="font-heading font-bold text-pine lowercase text-sm">{l.nameTr}</div>
<div className="text-xs text-shutter font-mono mt-1">/{l.slug}</div>
</td>
<td className="px-6 py-4 text-xs font-semibold">
<div className="text-pine">Kategori: {l.category?.nameTr}</div>
<div className="text-shutter mt-0.5">Bölge: {l.neighborhood?.nameTr}</div>
</td>
<td className="px-6 py-4 whitespace-nowrap font-mono text-xs">
<div className="text-pine font-semibold">Fiyat: {'₺'.repeat(l.priceRange)}</div>
{l.rating && <div className="text-gold font-bold mt-0.5"> {l.rating.toFixed(1)}</div>}
</td>
<td className="px-6 py-4 whitespace-nowrap">
{l.isLocalApproved ? (
<span className="inline-flex items-center gap-1 rounded-full bg-paper px-2.5 py-0.5 text-[10px] font-mono font-bold text-turquoise border border-turquoise/20 uppercase tracking-wider">
<CheckCircle className="w-3.5 h-3.5 fill-turquoise/5" />
Yerel Onaylı
</span>
) : (
<span className="inline-flex items-center gap-1 rounded-full bg-paper px-2.5 py-0.5 text-[10px] font-mono font-medium text-shutter/60 border border-pine/8 uppercase tracking-wider">
Normal
</span>
)}
</td>
<td className="px-6 py-4 text-right whitespace-nowrap">
<div className="flex justify-end gap-2">
<Link
href={`/admin/listings/${l.id}`}
className="p-1.5 bg-paper text-shutter hover:text-turquoise hover:bg-turquoise/5 rounded-lg border border-pine/10 hover:border-turquoise/25 transition shadow-sm"
title="Düzenle"
>
<Edit className="w-4 h-4" />
</Link>
<form action={async () => {
'use server'
await deleteListingAction(l.id)
}}>
<button
type="submit"
className="p-1.5 bg-paper text-shutter hover:text-bougainvillea hover:bg-bougainvillea/5 rounded-lg border border-pine/10 hover:border-bougainvillea/25 transition shadow-sm"
title="Sil"
>
<Trash className="w-4 h-4" />
</button>
</form>
</div>
</td>
</tr>
)
})
)}
</tbody>
</table>
</div>
</div>
</div>
)
}
+88
View File
@@ -0,0 +1,88 @@
import { mockDb } from '@/lib/mockDb'
import { markMessageReadAction } from '@/app/actions'
import { Check, MailOpen, Mail } from 'lucide-react'
export default async function AdminMessagesPage() {
const messages = await mockDb.getMessages()
return (
<div className="space-y-6">
<div>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">iletisim mesajları</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Kullanıcılar tarafından `/iletisim` formu üzerinden gönderilen genel mesajlar.
</p>
</div>
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm overflow-hidden">
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-pine/8 text-sm">
<thead className="bg-stone-deep/40 text-shutter font-mono text-[10px] uppercase tracking-wider">
<tr>
<th className="px-6 py-4 text-left">Tarih</th>
<th className="px-6 py-4 text-left">Gönderen</th>
<th className="px-6 py-4 text-left">Konu</th>
<th className="px-6 py-4 text-left">Mesaj</th>
<th className="px-6 py-4 text-right">İşlemler</th>
</tr>
</thead>
<tbody className="divide-y divide-dashed divide-pine/8 text-ink/80">
{messages.length === 0 ? (
<tr>
<td colSpan={5} className="px-6 py-12 text-center text-xs text-shutter font-medium">
Gelen iletişim mesajı bulunmamaktadır.
</td>
</tr>
) : (
messages.map((msg) => {
return (
<tr key={msg.id} className={`hover:bg-stone/20 transition duration-150 ${!msg.isRead ? 'bg-turquoise/5' : ''}`}>
<td className="px-6 py-4 whitespace-nowrap text-xs text-shutter font-mono">
{new Date(msg.createdAt).toLocaleString('tr-TR')}
</td>
<td className="px-6 py-4 whitespace-nowrap">
<div className="text-pine font-heading font-bold text-xs lowercase">{msg.name}</div>
<a href={`mailto:${msg.email}`} className="text-xs text-turquoise hover:underline">
{msg.email}
</a>
</td>
<td className="px-6 py-4 whitespace-nowrap">
<span className="inline-flex items-center rounded-md bg-paper px-2.5 py-0.5 text-[10px] font-mono font-bold text-shutter border border-pine/10 uppercase tracking-wider">
{msg.subject}
</span>
</td>
<td className="px-6 py-4 max-w-md">
<p className="text-xs break-words leading-relaxed whitespace-pre-line font-medium">{msg.message}</p>
</td>
<td className="px-6 py-4 text-right whitespace-nowrap">
{!msg.isRead ? (
<form action={async () => {
'use server'
await markMessageReadAction(msg.id)
}}>
<button
type="submit"
className="inline-flex items-center gap-1.5 px-3 py-1.5 bg-paper hover:bg-turquoise/5 text-turquoise rounded-lg border border-turquoise/20 text-xs font-bold transition shadow-sm"
>
<MailOpen className="w-3.5 h-3.5" />
Okundu İşaretle
</button>
</form>
) : (
<span className="text-shutter/60 inline-flex items-center gap-1 text-xs font-semibold">
<Check className="w-4 h-4 text-turquoise" />
Okundu
</span>
)}
</td>
</tr>
)
})
)}
</tbody>
</table>
</div>
</div>
</div>
)
}
+43
View File
@@ -0,0 +1,43 @@
import { mockDb } from '@/lib/mockDb'
export default async function AdminNeighborhoodsPage() {
const neighborhoods = await mockDb.getNeighborhoods()
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">mahalleler</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Marmaris Local rehberindeki mekanların filtrelendiği mahalle/bölgeler.
</p>
</div>
</div>
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm overflow-hidden max-w-4xl">
<table className="min-w-full divide-y divide-pine/8 text-sm">
<thead className="bg-stone-deep/40 text-shutter font-mono text-[10px] uppercase tracking-wider">
<tr>
<th className="px-6 py-4 text-left">ID</th>
<th className="px-6 py-4 text-left">Slug</th>
<th className="px-6 py-4 text-left">Adı (TR)</th>
<th className="px-6 py-4 text-left">Name (EN)</th>
<th className="px-6 py-4 text-left">Имя (RU)</th>
</tr>
</thead>
<tbody className="divide-y divide-dashed divide-pine/8 text-ink/85 font-medium">
{neighborhoods.map((neigh) => (
<tr key={neigh.id} className="hover:bg-stone/20 transition duration-150">
<td className="px-6 py-4 font-mono text-xs text-shutter">{neigh.id}</td>
<td className="px-6 py-4 font-mono text-xs font-bold text-turquoise">{neigh.slug}</td>
<td className="px-6 py-4 font-heading font-bold text-pine lowercase text-sm">{neigh.nameTr}</td>
<td className="px-6 py-4 text-xs">{neigh.nameEn}</td>
<td className="px-6 py-4 text-xs">{neigh.nameRu}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)
}
+126
View File
@@ -0,0 +1,126 @@
import { auth } from '@/lib/auth'
import { mockDb } from '@/lib/mockDb'
import { Link } from '@/i18n/routing'
import { FileText, Inbox, ClipboardList, Map, Clock } from 'lucide-react'
export default async function AdminDashboardPage() {
const session = await auth()
// Load stats
const listings = await mockDb.getListings()
const submissions = await mockDb.getSubmissions()
const messages = await mockDb.getMessages()
const categories = await mockDb.getCategories()
const neighborhoods = await mockDb.getNeighborhoods()
const pendingSubmissions = submissions.filter(s => s.status === 'PENDING')
const unreadMessages = messages.filter(m => !m.isRead)
const stats = [
{ name: 'Toplam Mekan', stat: listings.length.toString(), icon: ClipboardList, color: 'text-pine bg-stone-deep border-pine/8' },
{ name: 'Bekleyen Başvuru', stat: pendingSubmissions.length.toString(), icon: FileText, color: 'text-gold bg-paper border-gold/15' },
{ name: 'Okunmamış Mesaj', stat: unreadMessages.length.toString(), icon: Inbox, color: 'text-turquoise bg-stone-deep border-turquoise/15' },
{ name: 'Kategori / Bölge', stat: `${categories.length} / ${neighborhoods.length}`, icon: Map, color: 'text-shutter bg-paper border-shutter/15' },
]
return (
<div className="space-y-8">
<div>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">dashboard</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Hoş geldiniz, {session?.user?.name || session?.user?.email}. Marmaris Local için genel rehber durumu.
</p>
</div>
{/* Stats grid */}
<div className="grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4">
{stats.map((item) => (
<div
key={item.name}
className="bg-paper rounded-2xl border border-pine/8 p-5 shadow-sm flex items-center gap-4 hover:border-turquoise/30 transition-all duration-300"
>
<div className={`p-3.5 rounded-xl border ${item.color}`}>
<item.icon className="h-5 w-5" />
</div>
<div>
<dt className="truncate text-[10px] font-mono uppercase tracking-wider text-shutter">{item.name}</dt>
<dd className="mt-1 text-2xl font-heading font-extrabold text-pine">
{item.stat}
</dd>
</div>
</div>
))}
</div>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
{/* Recent Submissions */}
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm p-6 sm:p-8 space-y-6">
<div className="flex items-center justify-between border-b border-dashed border-pine/8 pb-4">
<h3 className="text-lg font-heading font-bold text-pine lowercase flex items-center gap-2">
<Clock className="w-5 h-5 text-gold" />
onay bekleyen başvurular
</h3>
<Link href="/admin/submissions" className="text-xs font-mono font-bold text-turquoise hover:underline uppercase tracking-wide">
tümünü gör
</Link>
</div>
<div className="divide-y divide-dashed divide-pine/8">
{pendingSubmissions.length === 0 ? (
<div className="py-8 text-center text-xs text-shutter font-medium">
Onay bekleyen yeni işletme başvurusu bulunmuyor.
</div>
) : (
pendingSubmissions.slice(0, 5).map((sub) => (
<div key={sub.id} className="py-4 flex items-center justify-between first:pt-0 last:pb-0">
<div className="space-y-1">
<h4 className="font-heading font-bold text-sm text-pine lowercase">{sub.businessName}</h4>
<p className="text-xs text-ink/65 font-medium">{sub.contactName} ({sub.contactEmail})</p>
</div>
<span className="inline-flex items-center rounded-full bg-paper px-3 py-1 text-[10px] font-mono font-bold text-gold border border-gold/20 uppercase">
Bekliyor
</span>
</div>
))
)}
</div>
</div>
{/* Recent Messages */}
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm p-6 sm:p-8 space-y-6">
<div className="flex items-center justify-between border-b border-dashed border-pine/8 pb-4">
<h3 className="text-lg font-heading font-bold text-pine lowercase flex items-center gap-2">
<Inbox className="w-5 h-5 text-turquoise" />
okunmamış mesajlar
</h3>
<Link href="/admin/messages" className="text-xs font-mono font-bold text-turquoise hover:underline uppercase tracking-wide">
tümünü gör
</Link>
</div>
<div className="divide-y divide-dashed divide-pine/8">
{unreadMessages.length === 0 ? (
<div className="py-8 text-center text-xs text-shutter font-medium">
Okunmamış yeni mesaj bulunmuyor.
</div>
) : (
unreadMessages.slice(0, 5).map((msg) => (
<div key={msg.id} className="py-4 flex items-center justify-between first:pt-0 last:pb-0">
<div className="space-y-1 pr-4 flex-1">
<h4 className="font-heading font-bold text-sm text-pine lowercase">{msg.name}</h4>
<p className="text-xs text-ink/70 font-medium line-clamp-1">{msg.message}</p>
</div>
<span className="text-[10px] text-shutter font-mono shrink-0">
{new Date(msg.createdAt).toLocaleDateString('tr-TR')}
</span>
</div>
))
)}
</div>
</div>
</div>
</div>
)
}
+118
View File
@@ -0,0 +1,118 @@
import { mockDb } from '@/lib/mockDb'
import { approveSubmissionAction, rejectSubmissionAction } from '@/app/actions'
import { Check, X } from 'lucide-react'
export default async function AdminSubmissionsPage() {
const submissions = await mockDb.getSubmissions()
return (
<div className="space-y-6">
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">işletme başvuruları</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Kullanıcılar tarafından `/isletme-ekle` formu üzerinden gönderilen ve onay bekleyen başvurular.
</p>
</div>
</div>
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm overflow-hidden">
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-pine/8 text-sm">
<thead className="bg-stone-deep/40 text-shutter font-mono text-[10px] uppercase tracking-wider">
<tr>
<th className="px-6 py-4 text-left">İşletme</th>
<th className="px-6 py-4 text-left">Konum & Kategori</th>
<th className="px-6 py-4 text-left">Gönderen</th>
<th className="px-6 py-4 text-left">Görsel</th>
<th className="px-6 py-4 text-left">Durum</th>
<th className="px-6 py-4 text-right">İşlemler</th>
</tr>
</thead>
<tbody className="divide-y divide-dashed divide-pine/8 text-ink/80">
{submissions.length === 0 ? (
<tr>
<td colSpan={6} className="px-6 py-12 text-center text-xs text-shutter font-medium">
Kayıtlı işletme başvurusu bulunmamaktadır.
</td>
</tr>
) : (
submissions.map((sub) => {
return (
<tr key={sub.id} className="hover:bg-stone/20 transition duration-150">
<td className="px-6 py-4">
<div className="font-heading font-bold text-pine lowercase text-sm">{sub.businessName}</div>
<div className="text-xs text-ink/70 mt-1 max-w-xs line-clamp-2 leading-relaxed">{sub.description}</div>
<div className="text-[11px] text-shutter mt-1.5">{sub.address}</div>
</td>
<td className="px-6 py-4 font-mono text-xs">
<div className="text-pine font-semibold">Kategori: {sub.categoryId}</div>
<div className="text-shutter mt-0.5">Bölge: {sub.neighborhoodId}</div>
</td>
<td className="px-6 py-4">
<div className="text-xs font-semibold text-pine">{sub.contactName}</div>
<a href={`mailto:${sub.contactEmail}`} className="text-xs text-turquoise hover:underline">
{sub.contactEmail}
</a>
{sub.phone && <div className="text-[11px] text-ink/65 font-mono mt-1">{sub.phone}</div>}
</td>
<td className="px-6 py-4">
{sub.imageUrl ? (
<div className="w-16 h-12 relative rounded-lg border border-pine/8 overflow-hidden">
<img src={sub.imageUrl} alt={sub.businessName} className="w-full h-full object-cover" />
</div>
) : (
<span className="text-[10px] font-mono text-shutter">Görsel Yok</span>
)}
</td>
<td className="px-6 py-4">
<span className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-[10px] font-mono font-bold border uppercase tracking-wider ${
sub.status === 'PENDING' ? 'bg-paper text-gold border-gold/20' :
sub.status === 'APPROVED' ? 'bg-paper text-turquoise border-turquoise/20' :
'bg-paper text-bougainvillea border-bougainvillea/20'
}`}>
{sub.status === 'PENDING' ? 'Bekliyor' : sub.status === 'APPROVED' ? 'Onaylandı' : 'Reddedildi'}
</span>
</td>
<td className="px-6 py-4 text-right">
{sub.status === 'PENDING' && (
<div className="flex justify-end gap-2">
<form action={async () => {
'use server'
await approveSubmissionAction(sub.id)
}}>
<button
type="submit"
className="p-1.5 bg-paper text-turquoise hover:bg-turquoise/5 rounded-lg border border-turquoise/20 transition shadow-sm"
title="Onayla ve Mekanlara Ekle"
>
<Check className="w-4 h-4" />
</button>
</form>
<form action={async () => {
'use server'
await rejectSubmissionAction(sub.id)
}}>
<button
type="submit"
className="p-1.5 bg-paper text-bougainvillea hover:bg-bougainvillea/5 rounded-lg border border-bougainvillea/20 transition shadow-sm"
title="Reddet"
>
<X className="w-4 h-4" />
</button>
</form>
</div>
)}
</td>
</tr>
)
})
)}
</tbody>
</table>
</div>
</div>
</div>
)
}