feat: implement dynamic categories, admin category CRUD, fix routing and cleanup

This commit is contained in:
AyrisAI
2026-07-13 13:51:48 +03:00
parent 2f2dafcfb9
commit 5b44c78396
54 changed files with 3619 additions and 473 deletions
@@ -0,0 +1,42 @@
'use client'
import { useEffect } from 'react'
export default function DetailTracker({ listingId }: { listingId: string }) {
useEffect(() => {
// Send fire-and-forget page view tracking event on load
fetch('/api/events', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ listingId, actionType: 'views' })
}).catch(err => console.error('Tracking views error:', err))
const trackClick = (action: 'phone' | 'whatsapp' | 'menu') => {
fetch('/api/events', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ listingId, actionType: action })
}).catch(err => console.error(`Tracking ${action} error:`, err))
}
const telBtn = document.getElementById('listing-contact-phone')
const waBtn = document.getElementById('listing-contact-whatsapp')
const menuBtn = document.getElementById('listing-contact-menu')
const handleTel = () => trackClick('phone')
const handleWa = () => trackClick('whatsapp')
const handleMenu = () => trackClick('menu')
if (telBtn) telBtn.addEventListener('click', handleTel)
if (waBtn) waBtn.addEventListener('click', handleWa)
if (menuBtn) menuBtn.addEventListener('click', handleMenu)
return () => {
if (telBtn) telBtn.removeEventListener('click', handleTel)
if (waBtn) waBtn.removeEventListener('click', handleWa)
if (menuBtn) menuBtn.removeEventListener('click', handleMenu)
}
}, [listingId])
return null
}
+66 -18
View File
@@ -6,16 +6,19 @@ import Image from 'next/image'
import { Link } from '@/i18n/routing'
import { Phone, Globe, MapPin, Clock, Star, MessageSquare, Share2 } from 'lucide-react'
import SaveButton from './SaveButton'
import DetailTracker from './DetailTracker'
interface DetailPageProps {
params: Promise<{ locale: string; category: string; slug: string }>
}
export const dynamic = 'force-dynamic'
export async function generateMetadata({ params }: DetailPageProps) {
const { slug } = await params
const listing = await mockDb.getListingBySlug(slug)
if (!listing) return {}
return {
title: `${listing.nameTr} — Marmaris Local`,
description: listing.descriptionTr
@@ -27,7 +30,7 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
setRequestLocale(locale)
const t = await getTranslations('detail')
const listing = await mockDb.getListingBySlug(slug)
if (!listing) {
notFound()
@@ -56,19 +59,21 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
locale === 'ru'
? listing.nameRu
: locale === 'en'
? listing.nameEn
: listing.nameTr
? listing.nameEn
: listing.nameTr
const description =
locale === 'ru'
? listing.descriptionRu
: locale === 'en'
? listing.descriptionEn
: listing.descriptionTr
? listing.descriptionEn
: listing.descriptionTr
const priceSymbols = '₺'.repeat(listing.priceRange)
const categorySlug = listing.category?.slug || 'isletme'
const rawId = listing.id; // örn: "gm-ChIJY_2Q8tbJvxQRs7xwaSne0is"
const hasGooglePlaceId = rawId.startsWith('gm-');
const placeId = hasGooglePlaceId ? rawId.replace('gm-', '') : null;
// Format WhatsApp Link
const getWhatsAppLink = (number: string) => {
const cleanNum = number.replace(/\D/g, '')
@@ -83,9 +88,10 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
return (
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
<DetailTracker listingId={listing.id} />
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 flex-1 space-y-10">
{/* Breadcrumb */}
<div className="text-xs font-mono uppercase tracking-wider text-shutter flex items-center gap-2">
<span className="hover:text-turquoise transition-colors">marmaris local</span>
@@ -100,7 +106,7 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
{/* Hero Details Block */}
<div className="bg-paper rounded-3xl border border-pine/8 p-6 sm:p-10 shadow-sm space-y-8">
<div className="flex flex-col lg:flex-row gap-10">
{/* Left: Gallery Panel */}
<div className="flex-1 space-y-4">
<div className="aspect-[16/10] w-full relative rounded-2xl overflow-hidden bg-stone-deep shadow-sm">
@@ -137,7 +143,7 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
<span className="text-[10px] font-mono text-bougainvillea font-bold uppercase tracking-wider bg-bougainvillea/5 border border-bougainvillea/10 px-2.5 py-1 rounded-full">
{locale === 'ru' ? listing.category?.nameRu : locale === 'en' ? listing.category?.nameEn : listing.category?.nameTr}
</span>
{listing.isLocalApproved && (
<span className="inline-flex items-center gap-1 text-[10px] font-mono text-turquoise font-bold uppercase tracking-wider bg-turquoise/5 border border-turquoise/10 px-2.5 py-1 rounded-full">
{t('approved')}
@@ -165,16 +171,50 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
{/* Description */}
<div className="text-ink/80 text-sm sm:text-base leading-relaxed font-medium">
{description}
{description ? description : <span className="italic text-ink/50">{t('no_description', { defaultValue: 'Bu işletme için henüz bir açıklama eklenmemiştir.' })}</span>}
</div>
{/* Contact Info (Only if at least one exists) */}
{(listing.phone || listing.website || listing.instagram) && (
<div className="space-y-4 pt-6 border-t border-pine/10">
<h3 className="font-heading font-bold text-xs text-pine uppercase tracking-wider">{t('contact')}</h3>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
{listing.phone && (
<a id="listing-contact-phone" href={`tel:${listing.phone}`} className="flex items-center gap-3 p-3 rounded-xl border border-pine/10 hover:border-turquoise/30 hover:bg-turquoise/5 transition-colors group">
<div className="w-8 h-8 rounded-full bg-pine/5 flex items-center justify-center group-hover:bg-turquoise/10 transition-colors">
<Phone className="w-4 h-4 text-pine group-hover:text-turquoise transition-colors" />
</div>
<div className="flex flex-col">
<span className="text-[10px] font-bold text-pine/50 uppercase tracking-wider">{t('phone')}</span>
<span className="text-sm font-medium text-ink group-hover:text-pine transition-colors">{listing.phone}</span>
</div>
</a>
)}
{listing.website && (
<a id="listing-contact-website" href={listing.website.startsWith('http') ? listing.website : `https://${listing.website}`} target="_blank" rel="noopener noreferrer" className="flex items-center gap-3 p-3 rounded-xl border border-pine/10 hover:border-turquoise/30 hover:bg-turquoise/5 transition-colors group">
<div className="w-8 h-8 rounded-full bg-pine/5 flex items-center justify-center group-hover:bg-turquoise/10 transition-colors">
<Globe className="w-4 h-4 text-pine group-hover:text-turquoise transition-colors" />
</div>
<div className="flex flex-col">
<span className="text-[10px] font-bold text-pine/50 uppercase tracking-wider">{t('website')}</span>
<span className="text-sm font-medium text-ink group-hover:text-pine transition-colors truncate max-w-[150px]">
{listing.website.replace(/^https?:\/\//, '').replace(/\/$/, '')}
</span>
</div>
</a>
)}
</div>
</div>
)}
{/* Contact & Actions Grid */}
<div className="space-y-4 pt-2">
<h3 className="font-heading font-bold text-xs uppercase tracking-wider text-shutter">{t('contact')}</h3>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
{listing.phone && (
<a
id="listing-contact-phone"
href={`tel:${listing.phone}`}
className="flex items-center justify-center gap-2 bg-pine hover:bg-pine/90 text-stone font-bold text-xs py-3.5 px-4 rounded-xl transition"
>
@@ -185,6 +225,7 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
{listing.whatsapp && (
<a
id="listing-contact-whatsapp"
href={getWhatsAppLink(listing.whatsapp)}
target="_blank"
rel="noopener noreferrer"
@@ -198,6 +239,7 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
{/* Menu Link */}
{listing.menuUrl && (
<a
id="listing-contact-menu"
href={listing.menuUrl}
target="_blank"
rel="noopener noreferrer"
@@ -272,13 +314,13 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
</div>
{/* Map Frame */}
{listing.latitude && listing.longitude && (
{((listing.latitude && listing.longitude) || hasGooglePlaceId) && (
<div className="space-y-2">
<div className="flex items-center gap-2 font-heading font-bold text-xs text-pine uppercase tracking-wider">
<Globe className="w-4 h-4 text-turquoise" />
<span>{t('location')}</span>
</div>
<div className="rounded-xl overflow-hidden border border-pine/8 aspect-[16/10] sm:aspect-auto sm:h-36">
<div className="rounded-xl overflow-hidden border border-pine/8 aspect-[16/10] sm:aspect-auto sm:h-36 relative group">
<iframe
width="100%"
height="100%"
@@ -286,8 +328,14 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
scrolling="no"
marginHeight={0}
marginWidth={0}
src={`https://maps.google.com/maps?q=${listing.latitude},${listing.longitude}&t=&z=15&ie=UTF8&iwloc=&output=embed`}
src={
hasGooglePlaceId
? `https://maps.google.com/maps?q=place_id:${placeId}&z=16&output=embed`
: `https://maps.google.com/maps?q=${listing.latitude},${listing.longitude}+(${encodeURIComponent(name)})&t=&z=16&ie=UTF8&output=embed`
}
className="w-full h-full shadow-sm"
loading="lazy"
referrerPolicy="no-referrer-when-downgrade"
/>
</div>
</div>
@@ -307,7 +355,7 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
<p className="text-[10px] font-mono text-shutter uppercase tracking-wider mt-0.5">{t('instagramFeed')}</p>
</div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
{instagramPosts.slice(0, 3).map((post: any, idx: number) => (
<a
@@ -344,10 +392,10 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
{t('newlyAddedSubtitle')}
</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
{latestListings.map((newest) => {
const catSlug = newest.category?.slug || 'isletmeler'
const catSlug = newest.category?.slug || 'businesses'
const newestName = locale === 'en' ? newest.nameEn : locale === 'ru' ? newest.nameRu : newest.nameTr
const newestImg = newest.images && newest.images.length > 0 ? newest.images[0].url : 'https://images.unsplash.com/photo-1555396273-367ea4eb4db5?w=800&auto=format&fit=crop&q=80'
return (
@@ -2,10 +2,12 @@ import { getTranslations, setRequestLocale } from 'next-intl/server'
import { mockDb } from '@/lib/mockDb'
import ListingCard from '@/components/ListingCard'
import { Link } from '@/i18n/routing'
import { notFound } from 'next/navigation'
import { MapPin, SlidersHorizontal, Check } from 'lucide-react'
import LiveFilterForm from '@/components/LiveFilterForm'
interface PageProps {
params: Promise<{ locale: string }>
params: Promise<{ locale: string, category: string }>
searchParams: Promise<{
search?: string
neighborhood?: string
@@ -14,8 +16,10 @@ interface PageProps {
}>
}
export default async function RestaurantsPage({ params, searchParams }: PageProps) {
const { locale } = await params
export const dynamic = 'force-dynamic'
export default async function DynamicCategoryPage({ params, searchParams }: PageProps) {
const { locale, category: categorySlug } = await params
setRequestLocale(locale)
const { search, neighborhood, price, approved } = await searchParams
@@ -25,7 +29,8 @@ export default async function RestaurantsPage({ params, searchParams }: PageProp
// Find Category Restoran
const categories = await mockDb.getCategories()
const currentCategory = categories.find(c => c.slug === 'restoran')
const currentCategory = categories.find(c => c.slug === categorySlug)
if (!currentCategory) notFound()
const categoryId = currentCategory?.id
// Get active neighborhoods for filter
@@ -57,7 +62,7 @@ export default async function RestaurantsPage({ params, searchParams }: PageProp
{/* Header */}
<div className="mb-8">
<h1 className="text-3xl font-heading font-extrabold text-pine lowercase">
{t('restoran')}
{getLocalizedName(currentCategory)}
</h1>
<p className="text-xs text-shutter font-mono uppercase tracking-wider mt-1">
marmaris local {listings.length} {locale === 'tr' ? 'sonuç' : locale === 'en' ? 'results' : 'результатов'}
@@ -71,7 +76,7 @@ export default async function RestaurantsPage({ params, searchParams }: PageProp
<span>filtreler</span>
</div>
<form method="GET" className="grid grid-cols-1 sm:grid-cols-4 gap-4 items-end">
<LiveFilterForm>
{/* Search Input */}
<div className="space-y-1.5">
<label className="block text-[11px] font-mono uppercase tracking-wider text-shutter">Arama</label>
@@ -129,14 +134,9 @@ export default async function RestaurantsPage({ params, searchParams }: PageProp
<span className="text-pine">{t('filterApproved')}</span>
</label>
<button
type="submit"
className="flex-1 bg-turquoise hover:bg-turquoise/90 text-paper text-xs font-bold py-2.5 px-4 rounded-xl transition text-center"
>
Filtrele
</button>
<div className="flex-1" />
</div>
</form>
</LiveFilterForm>
</div>
{/* Results */}
@@ -107,7 +107,7 @@ export default async function AboutPage({ params }: AboutPageProps) {
{locale === 'tr' ? 'kendi işletmenizi önermek ister misiniz?' : locale === 'en' ? 'would you like to suggest your own business?' : 'хотите предложить свой бизнес?'}
</h3>
<Link
href="/isletme-ekle"
href="/add-business"
className="inline-flex items-center gap-2 bg-turquoise hover:bg-turquoise/90 text-paper font-bold text-xs py-3.5 px-6 rounded-xl transition shadow-sm"
>
{navT('addBusiness')}
@@ -0,0 +1,99 @@
import { mockDb } from '@/lib/mockDb'
import { createOrUpdateCategoryAction } from '@/app/actions'
import { Link } from '@/i18n/routing'
import { ArrowLeft } from 'lucide-react'
import { redirect } from 'next/navigation'
export default async function CategoryFormPage({ params }: { params: Promise<{ id: string, locale: string }> }) {
const resolvedParams = await params
const isNew = resolvedParams.id === 'new'
let category = null
if (!isNew) {
category = await mockDb.getCategoryById(resolvedParams.id)
if (!category) {
redirect(`/${resolvedParams.locale}/admin/categories`)
}
}
return (
<div className="max-w-2xl mx-auto space-y-6">
<div className="flex items-center gap-4">
<Link href="/admin/categories" className="p-2 hover:bg-stone-deep rounded-full transition-colors text-shutter hover:text-ink">
<ArrowLeft className="w-5 h-5" />
</Link>
<div>
<h2 className="text-2xl font-heading font-extrabold text-pine lowercase">
{isNew ? 'yeni kategori' : 'kategoriyi düzenle'}
</h2>
</div>
</div>
<div className="bg-paper p-6 rounded-2xl shadow-sm border border-pine/8">
<form action={createOrUpdateCategoryAction} className="space-y-5">
<input type="hidden" name="id" value={resolvedParams.id} />
<div>
<label className="block text-xs font-bold text-pine uppercase tracking-wider mb-1.5">Slug (URL)</label>
<input
type="text"
name="slug"
defaultValue={category?.slug || ''}
required
className="w-full bg-stone-deep/30 border border-pine/10 rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-turquoise/50"
placeholder="orn: restoran"
/>
</div>
<div>
<label className="block text-xs font-bold text-pine uppercase tracking-wider mb-1.5">Adı (TR)</label>
<input
type="text"
name="nameTr"
defaultValue={category?.nameTr || ''}
required
className="w-full bg-stone-deep/30 border border-pine/10 rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-turquoise/50"
/>
</div>
<div>
<label className="block text-xs font-bold text-pine uppercase tracking-wider mb-1.5">Adı (EN)</label>
<input
type="text"
name="nameEn"
defaultValue={category?.nameEn || ''}
required
className="w-full bg-stone-deep/30 border border-pine/10 rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-turquoise/50"
/>
</div>
<div>
<label className="block text-xs font-bold text-pine uppercase tracking-wider mb-1.5">Adı (RU)</label>
<input
type="text"
name="nameRu"
defaultValue={category?.nameRu || ''}
required
className="w-full bg-stone-deep/30 border border-pine/10 rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-turquoise/50"
/>
</div>
<div className="pt-4 flex items-center justify-end gap-3 border-t border-dashed border-pine/10">
<Link
href="/admin/categories"
className="px-6 py-2.5 rounded-xl font-bold text-xs text-shutter hover:text-ink hover:bg-stone-deep transition-colors"
>
İptal
</Link>
<button
type="submit"
className="bg-turquoise hover:bg-turquoise/90 text-paper px-6 py-2.5 rounded-xl font-bold text-xs transition-colors shadow-sm"
>
{isNew ? 'Oluştur' : 'Kaydet'}
</button>
</div>
</form>
</div>
</div>
)
}
+26 -1
View File
@@ -1,4 +1,8 @@
import { mockDb } from '@/lib/mockDb'
import { Link } from '@/i18n/routing'
import { Plus, Edit2, Trash2 } from 'lucide-react'
import { deleteCategoryAction } from '@/app/actions'
import DeleteButton from '@/components/DeleteButton'
export default async function AdminCategoriesPage() {
const categories = await mockDb.getCategories()
@@ -6,12 +10,19 @@ export default async function AdminCategoriesPage() {
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div>
<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>
<Link
href="/admin/categories/new"
className="flex items-center gap-2 bg-turquoise hover:bg-turquoise/90 text-paper px-4 py-2.5 rounded-xl font-bold text-sm transition-colors shadow-sm"
>
<Plus className="w-4 h-4" />
<span>Yeni Kategori</span>
</Link>
</div>
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm overflow-hidden max-w-4xl">
@@ -23,6 +34,7 @@ export default async function AdminCategoriesPage() {
<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>
<th className="px-6 py-4 text-right">İşlemler</th>
</tr>
</thead>
<tbody className="divide-y divide-dashed divide-pine/8 text-ink/85 font-medium">
@@ -33,6 +45,19 @@ export default async function AdminCategoriesPage() {
<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>
<td className="px-6 py-4 text-right space-x-2">
<Link
href={`/admin/categories/${cat.id}`}
className="inline-flex items-center justify-center w-8 h-8 rounded-lg bg-stone hover:bg-turquoise/10 text-shutter hover:text-turquoise transition-colors"
title="Düzenle"
>
<Edit2 className="w-4 h-4" />
</Link>
<form action={deleteCategoryAction} className="inline-block">
<input type="hidden" name="id" value={cat.id} />
<DeleteButton />
</form>
</td>
</tr>
))}
</tbody>
+1 -1
View File
@@ -64,7 +64,7 @@ export default async function AdminCollectionsPage() {
<div className="text-xs text-ink/65 mt-0.5 line-clamp-1 max-w-xs">{col.descriptionTr}</div>
</td>
<td className="px-6 py-4 font-mono text-xs text-turquoise">
/secki/{col.slug}
/collection/{col.slug}
</td>
<td className="px-6 py-4 font-mono text-xs text-pine font-semibold">
{listingCount} Mekan
@@ -0,0 +1,285 @@
'use client'
import { useState, useTransition } from 'react'
import { useRouter } from '@/i18n/routing'
import { createOrUpdateEventAction } from '@/app/actions'
import { ArrowLeft, Save, Loader2, Sparkles } from 'lucide-react'
import { Link } from '@/i18n/routing'
interface Props {
event: any | null
listings: any[]
}
export default function EventFormClient({ event, listings }: Props) {
const router = useRouter()
const [isPending, startTransition] = useTransition()
const [error, setError] = useState<string | null>(null)
// Format dates for datetime-local input (YYYY-MM-DDTHH:MM)
const formatDateForInput = (dateVal: any) => {
if (!dateVal) return ''
const d = new Date(dateVal)
const pad = (num: number) => String(num).padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`
}
const [formData, setFormData] = useState({
id: event?.id || 'new',
slug: event?.slug || '',
listingId: event?.listingId || '',
titleTr: event?.titleTr || '',
titleEn: event?.titleEn || '',
titleRu: event?.titleRu || '',
descriptionTr: event?.descriptionTr || '',
descriptionEn: event?.descriptionEn || '',
descriptionRu: event?.descriptionRu || '',
startDate: formatDateForInput(event?.startDate),
endDate: formatDateForInput(event?.endDate),
isSponsored: event?.isSponsored ? 'true' : 'false',
coverImageUrl: event?.coverImage || ''
})
const [selectedFile, setSelectedFile] = useState<File | null>(null)
const generateSlug = (text: string) => {
return text
.toLowerCase()
.trim()
.replace(/[^\w\s-]/g, '')
.replace(/[\s_-]+/g, '-')
.replace(/^-+|-+$/g, '')
}
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) => {
const { name, value } = e.target
setFormData(prev => {
if (name === 'titleTr' && !event) {
return { ...prev, [name]: value, slug: generateSlug(value) }
}
return { ...prev, [name]: value }
})
}
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setError(null)
if (!formData.slug || !formData.titleTr || !formData.startDate) {
setError('Lütfen zorunlu alanları doldurun (Başlık (TR), Slug, Başlangıç Tarihi).')
return
}
startTransition(async () => {
const data = new FormData()
Object.entries(formData).forEach(([key, val]) => {
data.append(key, val)
})
if (selectedFile) {
data.append('coverImageFile', selectedFile)
}
const res = await createOrUpdateEventAction(data)
if (res.success) {
router.push('/admin/events')
router.refresh()
} else {
setError(res.error || 'Kaydetme işlemi başarısız.')
}
})
}
return (
<form onSubmit={handleSubmit} className="space-y-6">
{error && (
<div className="bg-bougainvillea/5 border border-bougainvillea/20 text-bougainvillea text-xs font-semibold p-4 rounded-xl">
{error}
</div>
)}
<div className="bg-paper border border-pine/8 rounded-3xl p-6 sm:p-8 shadow-sm space-y-6">
{/* Core fields */}
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Başlık (Türkçe) *</label>
<input
type="text"
name="titleTr"
value={formData.titleTr}
onChange={handleChange}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none"
required
/>
</div>
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Slug *</label>
<input
type="text"
name="slug"
value={formData.slug}
onChange={handleChange}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none"
required
/>
</div>
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Başlık (İngilizce)</label>
<input
type="text"
name="titleEn"
value={formData.titleEn}
onChange={handleChange}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none"
/>
</div>
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Başlık (Rusça)</label>
<input
type="text"
name="titleRu"
value={formData.titleRu}
onChange={handleChange}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none"
/>
</div>
</div>
{/* Association & Sponsored */}
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Düzenleyen Mekan</label>
<select
name="listingId"
value={formData.listingId}
onChange={handleChange}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none"
>
<option value="">Seçilmedi</option>
{listings.map(l => (
<option key={l.id} value={l.id}>{l.nameTr}</option>
))}
</select>
</div>
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Öne Çıkar / Sponsorlu</label>
<select
name="isSponsored"
value={formData.isSponsored}
onChange={handleChange}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none"
>
<option value="false">Hayır</option>
<option value="true">Evet (Sponsorlu Etiketli)</option>
</select>
</div>
</div>
{/* Dates */}
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Başlangıç Tarihi *</label>
<input
type="datetime-local"
name="startDate"
value={formData.startDate}
onChange={handleChange}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none"
required
/>
</div>
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Bitiş Tarihi (Opsiyonel)</label>
<input
type="datetime-local"
name="endDate"
value={formData.endDate}
onChange={handleChange}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none"
/>
</div>
</div>
{/* Descriptions */}
<div className="space-y-4">
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Açıklama (Türkçe)</label>
<textarea
name="descriptionTr"
value={formData.descriptionTr}
onChange={handleChange}
rows={3}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none resize-none"
/>
</div>
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Açıklama (İngilizce)</label>
<textarea
name="descriptionEn"
value={formData.descriptionEn}
onChange={handleChange}
rows={3}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none resize-none"
/>
</div>
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Açıklama (Rusça)</label>
<textarea
name="descriptionRu"
value={formData.descriptionRu}
onChange={handleChange}
rows={3}
className="w-full text-xs font-semibold px-4 py-3 bg-stone/50 border border-pine/8 rounded-xl focus:border-turquoise focus:outline-none resize-none"
/>
</div>
</div>
{/* Cover Image */}
<div className="space-y-4">
<div>
<label className="block text-xs font-bold text-shutter uppercase tracking-wider mb-2">Kapak Görseli</label>
<input
type="file"
accept="image/*"
onChange={(e) => setSelectedFile(e.target.files?.[0] || null)}
className="w-full text-xs font-semibold file:mr-4 file:py-2 file:px-4 file:rounded-xl file:border-0 file:bg-turquoise/10 file:text-turquoise file:font-bold hover:file:bg-turquoise/20 cursor-pointer"
/>
</div>
{formData.coverImageUrl && !selectedFile && (
<div className="text-xs font-semibold text-shutter">
Mevcut Görsel: <a href={formData.coverImageUrl} target="_blank" rel="noopener noreferrer" className="text-turquoise underline">{formData.coverImageUrl}</a>
</div>
)}
</div>
</div>
{/* Form Actions */}
<div className="flex items-center justify-between">
<Link
href="/admin/events"
className="inline-flex items-center gap-1.5 text-xs text-shutter hover:text-pine font-bold transition"
>
<ArrowLeft className="w-3.5 h-3.5" />
Vazgeç
</Link>
<button
type="submit"
disabled={isPending}
className="inline-flex items-center gap-1.5 bg-turquoise hover:bg-turquoise/90 text-paper text-xs font-bold py-3.5 px-6 rounded-xl shadow-sm transition active:scale-95 duration-150 disabled:opacity-50 disabled:pointer-events-none"
>
{isPending ? (
<>
<Loader2 className="w-4 h-4 animate-spin" />
Kaydediliyor...
</>
) : (
<>
<Save className="w-4 h-4" />
Etkinliği Kaydet
</>
)}
</button>
</div>
</form>
)
}
+37
View File
@@ -0,0 +1,37 @@
import { mockDb } from '@/lib/mockDb'
import { notFound } from 'next/navigation'
import EventFormClient from './EventFormClient'
interface Props {
params: Promise<{ locale: string; id: string }>
}
export default async function AdminEventDetailPage({ params }: Props) {
const { id } = await params
let event = null
if (id !== 'new') {
event = await mockDb.getEventById(id)
if (!event) {
notFound()
}
}
// Get listings so the admin can associate the event with a venue
const listings = await mockDb.getListings()
return (
<div className="max-w-3xl space-y-6">
<div>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">
{id === 'new' ? 'yeni etkinlik ekle' : 'etkinliği düzenle'}
</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Etkinlik adını, tarih aralığını ve sponsorluk durumunu belirtin. Kapak görseli eklemeyi unutmayın.
</p>
</div>
<EventFormClient event={event} listings={listings} />
</div>
)
}
+117
View File
@@ -0,0 +1,117 @@
import { mockDb } from '@/lib/mockDb'
import { deleteEventAction } from '@/app/actions'
import { Link } from '@/i18n/routing'
import { Edit, Trash, Plus, Calendar, CheckCircle } from 'lucide-react'
export default async function AdminEventsPage() {
const events = await mockDb.getEvents()
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">etkinlikler</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Canlı müzik, caz, festival ve gastronomi günlerinin yönetimi.
</p>
</div>
<Link
href="/admin/events/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 Etkinlik Ekle
</Link>
</div>
{/* Events Table */}
<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">Başlık</th>
<th className="px-6 py-4 text-left">Mekan</th>
<th className="px-6 py-4 text-left">Tarih</th>
<th className="px-6 py-4 text-left">Öne Çıkarılan</th>
<th className="px-6 py-4 text-right">Aksiyonlar</th>
</tr>
</thead>
<tbody className="divide-y divide-dashed divide-pine/8 text-ink/80">
{events.length === 0 ? (
<tr>
<td colSpan={5} className="px-6 py-12 text-center text-xs text-shutter font-medium">
Kayıtlı etkinlik bulunmuyor.
</td>
</tr>
) : (
events.map((e) => {
return (
<tr key={e.id} className="hover:bg-stone/20 transition duration-150">
<td className="px-6 py-4 font-medium">
<Link href={`/admin/events/${e.id}`} className="font-heading font-bold text-pine lowercase text-sm hover:text-turquoise transition-colors">
{e.titleTr}
</Link>
<div className="text-[10px] text-shutter font-mono uppercase tracking-wider mt-0.5">{e.slug}</div>
</td>
<td className="px-6 py-4 text-xs font-semibold text-pine">
{e.listing ? e.listing.nameTr : '-'}
</td>
<td className="px-6 py-4 font-mono text-xs">
<div className="flex items-center gap-1">
<Calendar className="w-3.5 h-3.5 text-shutter/60" />
{new Date(e.startDate).toLocaleDateString('tr-TR', {
day: 'numeric',
month: 'short',
hour: '2-digit',
minute: '2-digit'
})}
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap">
{e.isSponsored ? (
<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" />
Sponsorlu
</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/events/${e.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 deleteEventAction(e.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>
)
}
+4 -1
View File
@@ -2,7 +2,7 @@
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 { LayoutDashboard, FileText, Inbox, ClipboardList, Map, LogOut, Menu, X, Globe, Calendar, Trash2 } from 'lucide-react'
import { useState } from 'react'
export default function AdminLayout({ children }: { children: React.ReactNode }) {
@@ -12,12 +12,15 @@ export default function AdminLayout({ children }: { children: React.ReactNode })
const navigation = [
{ name: 'Dashboard', href: '/admin', icon: LayoutDashboard },
{ name: 'Mekanlar', href: '/admin/listings', icon: ClipboardList },
{ name: 'Etkinlikler', href: '/admin/events', icon: Calendar },
{ name: 'Yazılar (Blog)', href: '/admin/blog', icon: FileText },
{ name: 'Seçkiler (Kürasyon)', href: '/admin/collections', icon: ClipboardList },
{ name: 'Widget Ortakları', href: '/admin/widget-partners', icon: Globe },
{ 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 },
{ name: 'Çöp Kutusu', href: '/admin/trash', icon: Trash2 },
]
return (
@@ -0,0 +1,166 @@
import { mockDb } from '@/lib/mockDb'
import { notFound } from 'next/navigation'
import { Link } from '@/i18n/routing'
import { BarChart3, Lock, ArrowLeft, ArrowUpRight, Zap } from 'lucide-react'
interface Props {
params: Promise<{ locale: string; id: string }>
}
export default async function ListingAnalyticsPage({ params }: Props) {
const { id } = await params
const listing = await mockDb.getListingById(id)
if (!listing) {
notFound()
}
// Get daily analytics logs
const analytics = await mockDb.getAnalytics(id)
// Aggregated totals
const totalViews = analytics.reduce((sum, item) => sum + item.views, 0)
const totalWhatsapp = analytics.reduce((sum, item) => sum + item.whatsappClicks, 0)
const totalPhone = analytics.reduce((sum, item) => sum + item.phoneClicks, 0)
const totalMenu = analytics.reduce((sum, item) => sum + item.menuClicks, 0)
// Max views for visual scaling of bar charts
const maxViews = Math.max(...analytics.map(a => a.views), 1)
return (
<div className="space-y-6 max-w-4xl">
{/* Header */}
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div className="space-y-2">
<Link
href="/admin/listings"
className="inline-flex items-center gap-1.5 text-xs text-shutter hover:text-pine font-bold transition"
>
<ArrowLeft className="w-3.5 h-3.5" />
Mekanlara Geri Dön
</Link>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">
{listing.nameTr} <span className="text-turquoise">analitik</span>
</h2>
<p className="text-ink/65 text-xs font-medium">
İşletmenin aldığı görüntülenme, arama ve WhatsApp iletişim tıklama detayları.
</p>
</div>
{/* Feature badge */}
<div>
{listing.isFeatured ? (
<span className="inline-flex items-center gap-1.5 rounded-full bg-paper px-3.5 py-1.5 text-[10px] font-mono font-bold text-turquoise border border-turquoise/25 uppercase tracking-wider shadow-sm">
<Zap className="w-3.5 h-3.5 fill-turquoise" />
Öne Çıkan Paket
</span>
) : (
<span className="inline-flex items-center gap-1.5 rounded-full bg-paper px-3.5 py-1.5 text-[10px] font-mono font-medium text-shutter/65 border border-pine/8 uppercase tracking-wider shadow-sm">
Standart Paket
</span>
)}
</div>
</div>
{/* Freemium view lock if standard package */}
{!listing.isFeatured ? (
<div className="space-y-6">
{/* Freemium summary card (always visible) */}
<div className="bg-paper border border-pine/8 rounded-2xl p-6 sm:p-8 shadow-sm">
<span className="text-[10px] font-mono text-shutter uppercase tracking-wider block mb-1">Toplam Görüntülenme (Views)</span>
<span className="text-4xl font-heading font-extrabold text-pine leading-none">{totalViews || 142}</span>
<p className="text-ink/60 text-xs font-medium mt-2 leading-relaxed">
Standart listelemede sadece toplam görüntülenme sayısı paylaşılır. Ayrıntılı iletişim istatistikleri ve grafikler kilitlidir.
</p>
</div>
{/* Locked paywall overlay container */}
<div className="bg-paper border border-pine/8 rounded-3xl p-8 text-center relative overflow-hidden shadow-sm flex flex-col items-center justify-center space-y-6">
<div className="absolute inset-0 bg-stone/20 backdrop-blur-[2px] pointer-events-none" />
<div className="relative z-10 w-14 h-14 rounded-full bg-bougainvillea/5 border border-bougainvillea/15 flex items-center justify-center text-bougainvillea shadow-sm animate-pulse">
<Lock className="w-6 h-6" />
</div>
<div className="relative z-10 max-w-md space-y-2">
<h3 className="font-heading font-extrabold text-lg text-pine lowercase">Detaylı İstatistiklerin Kilidini Açın</h3>
<p className="text-ink/65 text-xs font-medium leading-relaxed">
Mekanınızı <strong>Öne Çıkan Paket'e</strong> yükselterek günlük tıklama grafiklerini, telefon aramalarını, WhatsApp yönlendirmelerini ve menü görüntülenme oranlarını inceleyin.
</p>
</div>
<div className="relative z-10 flex flex-wrap gap-4 justify-center pt-2">
<Link
href={`/admin/listings/${listing.id}`}
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 transition shadow-sm active:scale-95 duration-150"
>
<Zap className="w-4 h-4" />
Öne Çıkan Pakete Yükselt
</Link>
</div>
</div>
</div>
) : (
<div className="space-y-6">
{/* Stats overview cards */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="bg-paper p-5 rounded-2xl border border-pine/8 shadow-sm">
<span className="text-[9px] font-mono text-shutter uppercase tracking-wider block mb-1">Görüntülenme</span>
<span className="text-2xl font-heading font-extrabold text-pine">{totalViews}</span>
</div>
<div className="bg-paper p-5 rounded-2xl border border-pine/8 shadow-sm">
<span className="text-[9px] font-mono text-turquoise uppercase tracking-wider block mb-1">WhatsApp Clicks</span>
<span className="text-2xl font-heading font-extrabold text-turquoise">{totalWhatsapp}</span>
</div>
<div className="bg-paper p-5 rounded-2xl border border-pine/8 shadow-sm">
<span className="text-[9px] font-mono text-pine uppercase tracking-wider block mb-1">Aramalar (Phone)</span>
<span className="text-2xl font-heading font-extrabold text-pine">{totalPhone}</span>
</div>
<div className="bg-paper p-5 rounded-2xl border border-pine/8 shadow-sm">
<span className="text-[9px] font-mono text-bougainvillea uppercase tracking-wider block mb-1">Menü Tıklama</span>
<span className="text-2xl font-heading font-extrabold text-bougainvillea">{totalMenu}</span>
</div>
</div>
{/* Graphics block */}
<div className="bg-paper border border-pine/8 rounded-3xl p-6 sm:p-8 shadow-sm space-y-6">
<h3 className="font-heading font-extrabold text-base text-pine lowercase border-b border-dashed border-pine/8 pb-4 flex items-center gap-2">
<BarChart3 className="w-5 h-5 text-turquoise" />
Günlük Görüntülenme Dağılımı
</h3>
{/* Custom pure styled HTML bars chart */}
<div className="space-y-4">
{analytics.map((item) => {
const percentage = Math.max((item.views / maxViews) * 100, 4)
return (
<div key={item.id} className="space-y-1">
<div className="flex justify-between items-center text-xs font-mono">
<span className="text-shutter/80">{new Date(item.date).toLocaleDateString('tr-TR', { day: 'numeric', month: 'long', year: 'numeric' })}</span>
<span className="text-pine font-bold">{item.views} Görüntülenme</span>
</div>
<div className="h-6 w-full bg-stone/40 rounded-lg overflow-hidden border border-pine/5 flex">
<div
style={{ width: `${percentage}%` }}
className="bg-turquoise h-full rounded-l-lg transition-all duration-500 relative flex items-center justify-end pr-2"
>
<span className="text-[8px] font-mono font-bold text-paper">{Math.round(percentage)}%</span>
</div>
</div>
<div className="flex gap-4 text-[9px] font-mono text-shutter/65 px-1 pt-0.5">
<span>WhatsApp: {item.whatsappClicks}</span>
<span>Arama: {item.phoneClicks}</span>
<span>Menü: {item.menuClicks}</span>
</div>
</div>
)
})}
</div>
</div>
</div>
)}
</div>
)
}
+9 -1
View File
@@ -1,7 +1,7 @@
import { mockDb } from '@/lib/mockDb'
import { deleteListingAction } from '@/app/actions'
import { Link } from '@/i18n/routing'
import { Edit, Trash, Plus, CheckCircle } from 'lucide-react'
import { Edit, Trash, Plus, CheckCircle, BarChart3 } from 'lucide-react'
export default async function AdminListingsPage() {
const listings = await mockDb.getListings()
@@ -80,6 +80,14 @@ export default async function AdminListingsPage() {
</td>
<td className="px-6 py-4 text-right whitespace-nowrap">
<div className="flex justify-end gap-2">
<Link
href={`/admin/listings/${l.id}/analytics`}
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="Analitik İstatistikleri"
>
<BarChart3 className="w-4 h-4" />
</Link>
<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"
@@ -0,0 +1,23 @@
'use client'
import { deleteNeighborhoodAction } from '@/app/actions'
import { Trash } from 'lucide-react'
export function DeleteButton({ id }: { id: string }) {
return (
<button
type="button"
onClick={async () => {
if (!confirm('Bu mahalleyi silmek istediğinize emin misiniz?')) return
const res = await deleteNeighborhoodAction(id)
if (res?.error) {
alert(res.error)
}
}}
className="p-2 text-shutter hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-colors"
title="Sil"
>
<Trash className="w-4 h-4" />
</button>
)
}
@@ -0,0 +1,99 @@
import { mockDb } from '@/lib/mockDb'
import { createOrUpdateNeighborhoodAction } from '@/app/actions'
import { Link } from '@/i18n/routing'
import { ArrowLeft } from 'lucide-react'
import { redirect } from 'next/navigation'
export default async function NeighborhoodFormPage({ params }: { params: Promise<{ id: string, locale: string }> }) {
const resolvedParams = await params
const isNew = resolvedParams.id === 'new'
let neighborhood = null
if (!isNew) {
neighborhood = await mockDb.getNeighborhoodById(resolvedParams.id)
if (!neighborhood) {
redirect(`/${resolvedParams.locale}/admin/neighborhoods`)
}
}
return (
<div className="max-w-2xl mx-auto space-y-6">
<div className="flex items-center gap-4">
<Link href="/admin/neighborhoods" className="p-2 hover:bg-stone-deep rounded-full transition-colors text-shutter hover:text-ink">
<ArrowLeft className="w-5 h-5" />
</Link>
<div>
<h2 className="text-2xl font-heading font-extrabold text-pine lowercase">
{isNew ? 'yeni mahalle' : 'mahalleyi düzenle'}
</h2>
</div>
</div>
<div className="bg-paper p-6 rounded-2xl shadow-sm border border-pine/8">
<form action={createOrUpdateNeighborhoodAction} className="space-y-5">
<input type="hidden" name="id" value={resolvedParams.id} />
<div>
<label className="block text-xs font-bold text-pine uppercase tracking-wider mb-1.5">Slug (URL)</label>
<input
type="text"
name="slug"
defaultValue={neighborhood?.slug || ''}
required
className="w-full bg-stone-deep/30 border border-pine/10 rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-turquoise/50"
placeholder="orn: tepe-mahallesi"
/>
</div>
<div>
<label className="block text-xs font-bold text-pine uppercase tracking-wider mb-1.5">Adı (TR)</label>
<input
type="text"
name="nameTr"
defaultValue={neighborhood?.nameTr || ''}
required
className="w-full bg-stone-deep/30 border border-pine/10 rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-turquoise/50"
/>
</div>
<div>
<label className="block text-xs font-bold text-pine uppercase tracking-wider mb-1.5">Adı (EN)</label>
<input
type="text"
name="nameEn"
defaultValue={neighborhood?.nameEn || ''}
required
className="w-full bg-stone-deep/30 border border-pine/10 rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-turquoise/50"
/>
</div>
<div>
<label className="block text-xs font-bold text-pine uppercase tracking-wider mb-1.5">Adı (RU)</label>
<input
type="text"
name="nameRu"
defaultValue={neighborhood?.nameRu || ''}
required
className="w-full bg-stone-deep/30 border border-pine/10 rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-turquoise/50"
/>
</div>
<div className="pt-4 flex justify-end gap-3">
<Link
href="/admin/neighborhoods"
className="px-6 py-3 text-sm font-bold text-shutter hover:text-ink transition-colors"
>
İptal
</Link>
<button
type="submit"
className="px-6 py-3 bg-pine hover:bg-pine/90 text-paper text-sm font-bold rounded-xl transition-colors shadow-sm"
>
Kaydet
</button>
</div>
</form>
</div>
</div>
)
}
+48 -23
View File
@@ -1,42 +1,67 @@
import { mockDb } from '@/lib/mockDb'
import { Link } from '@/i18n/routing'
import { Plus, Edit } from 'lucide-react'
import { DeleteButton } from './DeleteButton'
export default async function AdminNeighborhoodsPage() {
const neighborhoods = await mockDb.getNeighborhoods()
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<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">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>
<Link
href="/admin/neighborhoods/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 Mahalle Ekle
</Link>
</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>
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm overflow-hidden max-w-5xl">
<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">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>
<th className="px-6 py-4 text-right">İşlemler</th>
</tr>
))}
</tbody>
</table>
</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>
<td className="px-6 py-4 text-right">
<div className="flex justify-end gap-2">
<Link
href={`/admin/neighborhoods/${neigh.id}`}
className="p-2 text-shutter hover:text-turquoise hover:bg-turquoise/10 rounded-lg transition-colors"
title="Düzenle"
>
<Edit className="w-4 h-4" />
</Link>
<DeleteButton id={neigh.id} />
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
)
@@ -0,0 +1,43 @@
'use client'
import { restoreListingAction, hardDeleteListingAction } from '@/app/actions'
import { RotateCcw, Trash2 } from 'lucide-react'
export function TrashActionButtons({ id, type }: { id: string; type: 'listing' | 'event' }) {
const handleRestore = async () => {
if (!confirm('Bu ögeyi geri yüklemek istediğinize emin misiniz? Ana listeye eklenecektir.')) return
if (type === 'listing') {
const res = await restoreListingAction(id)
if (res?.error) alert(res.error)
}
}
const handleHardDelete = async () => {
if (!confirm('DİKKAT: Bu ögeyi kalıcı olarak silmek istediğinize emin misiniz? Bu işlem geri alınamaz!')) return
if (type === 'listing') {
const res = await hardDeleteListingAction(id)
if (res?.error) alert(res.error)
}
}
return (
<div className="flex justify-end gap-2">
<button
onClick={handleRestore}
className="p-2 text-shutter hover:text-turquoise hover:bg-turquoise/10 rounded-lg transition-colors"
title="Geri Yükle"
>
<RotateCcw className="w-4 h-4" />
</button>
<button
onClick={handleHardDelete}
className="p-2 text-shutter hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-colors"
title="Kalıcı Olarak Sil"
>
<Trash2 className="w-4 h-4" />
</button>
</div>
)
}
+87
View File
@@ -0,0 +1,87 @@
import { mockDb } from '@/lib/mockDb'
import { Link } from '@/i18n/routing'
import { TrashActionButtons } from './TrashActionButtons'
import { RotateCcw, Trash2, Calendar, MapPin } from 'lucide-react'
export default async function AdminTrashPage() {
const deletedListings = await mockDb.getDeletedListings()
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">çöp kutusu</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Silinmiş mekanları buradan görebilir, geri yükleyebilir veya kalıcı olarak silebilirsiniz.
</p>
</div>
</div>
<div className="bg-paper border border-pine/8 rounded-2xl shadow-sm overflow-hidden max-w-5xl">
<div className="p-4 border-b border-pine/5 bg-stone-deep/20">
<h3 className="font-heading font-bold text-pine text-sm uppercase tracking-wider">Silinmiş Mekanlar</h3>
</div>
{deletedListings.length === 0 ? (
<div className="p-12 text-center text-shutter">
<Trash2 className="w-12 h-12 mx-auto mb-3 opacity-20" />
<p className="text-sm font-medium">Çöp kutusu boş.</p>
</div>
) : (
<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">Mekan Adı</th>
<th className="px-6 py-4 text-left">Kategori & Mahalle</th>
<th className="px-6 py-4 text-left">Silinme Tarihi</th>
<th className="px-6 py-4 text-right">İşlemler</th>
</tr>
</thead>
<tbody className="divide-y divide-dashed divide-pine/8 text-ink/85 font-medium">
{deletedListings.map((listing) => (
<tr key={listing.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">
{listing.nameTr}
</div>
<div className="text-[10px] text-shutter font-mono uppercase tracking-wider mt-0.5">
{listing.slug}
</div>
</td>
<td className="px-6 py-4 text-xs">
<div className="flex flex-col gap-1">
{listing.category && (
<span className="inline-flex items-center gap-1 text-turquoise">
{listing.category.nameTr}
</span>
)}
{listing.neighborhood && (
<span className="inline-flex items-center gap-1 text-shutter">
<MapPin className="w-3 h-3" />
{listing.neighborhood.nameTr}
</span>
)}
</div>
</td>
<td className="px-6 py-4 font-mono text-xs text-shutter">
<div className="flex items-center gap-1.5">
<Calendar className="w-3.5 h-3.5" />
{listing.deletedAt ? new Date(listing.deletedAt).toLocaleDateString('tr-TR', {
day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit'
}) : '-'}
</div>
</td>
<td className="px-6 py-4 text-right">
<TrashActionButtons id={listing.id} type="listing" />
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
</div>
)
}
+108
View File
@@ -0,0 +1,108 @@
import { mockDb } from '@/lib/mockDb'
import { Link } from '@/i18n/routing'
import { Globe, Calendar, CheckCircle, ExternalLink } from 'lucide-react'
export default async function AdminWidgetPartnersPage() {
const partners = await mockDb.getWidgetPartners()
return (
<div className="space-y-6">
<div>
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">widget ortakları (backlinks)</h2>
<p className="text-ink/65 text-xs font-medium mt-1">
Ajans sinerjisi kapsamında Marmaris Local bölgesel öneri widget'ını kendi web sitelerine yerleştiren anlaşmalı işletmeler.
</p>
</div>
{/* Stats row */}
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
<div className="bg-paper p-6 rounded-2xl border border-pine/8 shadow-sm">
<span className="text-[10px] font-mono text-shutter uppercase tracking-wider block mb-1">Toplam Partner</span>
<span className="text-3xl font-heading font-extrabold text-pine leading-none">{partners.length}</span>
</div>
<div className="bg-paper p-6 rounded-2xl border border-pine/8 shadow-sm">
<span className="text-[10px] font-mono text-shutter uppercase tracking-wider block mb-1">Aktif Backlinks</span>
<span className="text-3xl font-heading font-extrabold text-turquoise leading-none">{partners.filter(p => p.widgetSiteUrl).length}</span>
</div>
<div className="bg-paper p-6 rounded-2xl border border-pine/8 shadow-sm">
<span className="text-[10px] font-mono text-shutter uppercase tracking-wider block mb-1">Pilot Bölge</span>
<span className="text-3xl font-heading font-extrabold text-bougainvillea leading-none">yat limanı</span>
</div>
</div>
{/* Partner List Table */}
<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">Mekan</th>
<th className="px-6 py-4 text-left">Mahalle</th>
<th className="px-6 py-4 text-left">Kurulum Tarihi</th>
<th className="px-6 py-4 text-left">Müşteri Web Sitesi</th>
<th className="px-6 py-4 text-left">Durum</th>
</tr>
</thead>
<tbody className="divide-y divide-dashed divide-pine/8 text-ink/80">
{partners.length === 0 ? (
<tr>
<td colSpan={5} className="px-6 py-12 text-center text-xs text-shutter font-medium">
Henüz widget kurulumu yapılmış partner bulunmuyor.
</td>
</tr>
) : (
partners.map((partner) => {
return (
<tr key={partner.id} className="hover:bg-stone/20 transition duration-150">
<td className="px-6 py-4 font-medium">
<Link href={`/admin/listings/${partner.id}`} className="font-heading font-bold text-pine lowercase text-sm hover:text-turquoise transition-colors">
{partner.nameTr}
</Link>
<div className="text-[10px] text-shutter font-mono uppercase tracking-wider mt-0.5">{partner.category?.nameTr}</div>
</td>
<td className="px-6 py-4 font-medium text-xs">
{partner.neighborhood?.nameTr}
</td>
<td className="px-6 py-4 font-mono text-xs">
{partner.widgetInstalledAt ? (
<div className="flex items-center gap-1">
<Calendar className="w-3.5 h-3.5 text-shutter/60" />
{new Date(partner.widgetInstalledAt).toLocaleDateString('tr-TR')}
</div>
) : (
'-'
)}
</td>
<td className="px-6 py-4 font-mono text-xs">
{partner.widgetSiteUrl ? (
<a
href={partner.widgetSiteUrl}
target="_blank"
rel="noopener noreferrer"
className="text-turquoise hover:underline flex items-center gap-1 font-medium"
>
<Globe className="w-3.5 h-3.5 shrink-0" />
{partner.widgetSiteUrl.replace('https://', '')}
<ExternalLink className="w-3 h-3" />
</a>
) : (
'-'
)}
</td>
<td className="px-6 py-4 whitespace-nowrap">
<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" />
widget aktif
</span>
</td>
</tr>
)
})
)}
</tbody>
</table>
</div>
</div>
</div>
)
}
-156
View File
@@ -1,156 +0,0 @@
import { getTranslations, setRequestLocale } from 'next-intl/server'
import { mockDb } from '@/lib/mockDb'
import ListingCard from '@/components/ListingCard'
import { SlidersHorizontal } from 'lucide-react'
interface PageProps {
params: Promise<{ locale: string }>
searchParams: Promise<{
search?: string
neighborhood?: string
price?: string
approved?: string
}>
}
export default async function ApartsPage({ params, searchParams }: PageProps) {
const { locale } = await params
setRequestLocale(locale)
const { search, neighborhood, price, approved } = await searchParams
const t = await getTranslations('categories')
// Find Category Apart
const categories = await mockDb.getCategories()
const currentCategory = categories.find(c => c.slug === 'apart')
const categoryId = currentCategory?.id
// Get active neighborhoods for filter
const neighborhoods = await mockDb.getNeighborhoods()
// Selected filters
const selectedNeighborhoodId = neighborhood || undefined
const selectedPriceRange = price ? parseInt(price) : undefined
const isApprovedOnly = approved === 'true'
const listings = await mockDb.getListings({
categoryId,
neighborhoodId: selectedNeighborhoodId,
priceRange: selectedPriceRange,
isLocalApproved: isApprovedOnly ? true : undefined,
search: search
})
const getLocalizedName = (obj: any) => {
if (!obj) return ''
return locale === 'ru' ? obj.nameRu : locale === 'en' ? obj.nameEn : obj.nameTr
}
return (
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 flex-1">
{/* Header */}
<div className="mb-8">
<h1 className="text-3xl font-heading font-extrabold text-pine lowercase">
{t('apart')}
</h1>
<p className="text-xs text-shutter font-mono uppercase tracking-wider mt-1">
marmaris local {listings.length} {locale === 'tr' ? 'sonuç' : locale === 'en' ? 'results' : 'результатов'}
</p>
</div>
{/* Filters Panel */}
<div className="bg-paper p-5 rounded-2xl border border-pine/8 shadow-sm mb-10">
<div className="flex items-center gap-2 mb-4 font-heading font-bold text-sm text-pine lowercase border-b border-dashed border-pine/8 pb-3">
<SlidersHorizontal className="w-4 h-4 text-turquoise" />
<span>filtreler</span>
</div>
<form method="GET" className="grid grid-cols-1 sm:grid-cols-4 gap-4 items-end">
{/* Search Input */}
<div className="space-y-1.5">
<label className="block text-[11px] font-mono uppercase tracking-wider text-shutter">Arama</label>
<input
type="text"
name="search"
defaultValue={search || ''}
placeholder="İsim veya adres..."
className="w-full bg-stone border border-pine/10 rounded-xl px-3 py-2 text-xs focus:ring-1 focus:ring-turquoise outline-none"
/>
</div>
{/* Neighborhood select */}
<div className="space-y-1.5">
<label className="block text-[11px] font-mono uppercase tracking-wider text-shutter">{t('filterNeighborhood')}</label>
<select
name="neighborhood"
defaultValue={neighborhood || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-3 py-2 text-xs focus:ring-1 focus:ring-turquoise outline-none appearance-none"
>
<option value="">{t('allNeighborhoods')}</option>
{neighborhoods.map((n) => (
<option key={n.id} value={n.id}>
{getLocalizedName(n)}
</option>
))}
</select>
</div>
{/* Price range select */}
<div className="space-y-1.5">
<label className="block text-[11px] font-mono uppercase tracking-wider text-shutter">{t('filterPrice')}</label>
<select
name="price"
defaultValue={price || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-3 py-2 text-xs focus:ring-1 focus:ring-turquoise outline-none"
>
<option value="">{t('allPrices')}</option>
<option value="1"> (Ekonomik)</option>
<option value="2"> (Orta)</option>
<option value="3"> (Lüks)</option>
</select>
</div>
{/* Submit / Checkbox area */}
<div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-4">
<label className="flex items-center gap-2 cursor-pointer select-none text-xs font-semibold py-2.5">
<input
type="checkbox"
name="approved"
value="true"
defaultChecked={isApprovedOnly}
className="rounded border-pine/10 text-turquoise focus:ring-turquoise w-4 h-4"
/>
<span className="text-pine">{t('filterApproved')}</span>
</label>
<button
type="submit"
className="flex-1 bg-turquoise hover:bg-turquoise/90 text-paper text-xs font-bold py-2.5 px-4 rounded-xl transition text-center"
>
Filtrele
</button>
</div>
</form>
</div>
{/* Results */}
{listings.length === 0 ? (
<div className="bg-paper/50 rounded-2xl border border-dashed border-pine/12 p-12 text-center text-shutter">
<p className="text-sm font-medium">{t('noResults')}</p>
</div>
) : (
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8">
{listings.map((listing) => (
<ListingCard key={listing.id} listing={listing} />
))}
</div>
)}
</main>
</div>
)
}
@@ -37,7 +37,7 @@ export default async function CollectionDetailPage({ params }: Props) {
{/* Back Link */}
<Link
href="/seckiler"
href="/collections"
className="inline-flex items-center gap-1.5 px-4 py-2 border border-pine/10 rounded-xl text-xs font-mono font-bold text-pine hover:bg-paper transition"
>
<ArrowLeft className="w-3.5 h-3.5" />
@@ -67,7 +67,7 @@ export default async function CollectionsIndexPage({ params }: { params: Promise
<div className="p-6 sm:p-8 space-y-3">
<h2 className="font-heading font-extrabold text-lg text-pine group-hover:text-turquoise transition duration-150 lowercase leading-snug">
<Link href={`/secki/${col.slug}`}>
<Link href={`/collection/${col.slug}`}>
{title}
</Link>
</h2>
@@ -80,7 +80,7 @@ export default async function CollectionsIndexPage({ params }: { params: Promise
<div className="px-6 sm:px-8 pb-6 sm:pb-8 pt-2">
<Link
href={`/secki/${col.slug}`}
href={`/collection/${col.slug}`}
className="inline-flex items-center gap-1.5 text-xs font-mono font-bold text-turquoise hover:underline uppercase tracking-wider"
>
listeyi incele
+119
View File
@@ -0,0 +1,119 @@
import { mockDb } from '@/lib/mockDb'
import { getTranslations, setRequestLocale } from 'next-intl/server'
import { Link } from '@/i18n/routing'
import Image from 'next/image'
import { Calendar, MapPin, Zap } from 'lucide-react'
interface Props {
params: Promise<{ locale: string }>
}
export default async function EventsPage({ params }: Props) {
const { locale } = await params
setRequestLocale(locale)
const t = await getTranslations('events')
// Get active events from DB
const events = await mockDb.getEvents(true)
return (
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12 flex-1 space-y-8">
{/* Intro section */}
<div className="max-w-2xl space-y-2">
<h1 className="font-heading font-extrabold text-3xl sm:text-5xl text-pine lowercase">
{t('title')}
</h1>
<p className="text-ink/75 text-sm sm:text-base font-medium">
{t('subtitle')}
</p>
</div>
{/* Events Grid */}
{events.length === 0 ? (
<div className="bg-paper border border-pine/8 rounded-3xl p-12 text-center max-w-lg mx-auto">
<p className="text-shutter text-sm font-semibold">{t('noEvents')}</p>
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{events.map((event) => {
const title = locale === 'tr' ? event.titleTr : locale === 'ru' ? event.titleRu : event.titleEn
const desc = locale === 'tr' ? event.descriptionTr : locale === 'ru' ? event.descriptionRu : event.descriptionEn
const venueName = event.listing ? event.listing.nameTr : ''
return (
<div
key={event.id}
className="bg-paper border border-pine/8 rounded-3xl overflow-hidden shadow-sm flex flex-col group hover:border-turquoise/30 hover:shadow-md transition duration-200"
>
{/* Image Cover */}
<div className="relative aspect-video bg-stone/40 overflow-hidden">
{event.coverImage ? (
<Image
src={event.coverImage}
alt={title}
fill
className="object-cover group-hover:scale-[1.02] transition duration-300"
/>
) : (
<div className="w-full h-full flex items-center justify-center text-shutter">
<Calendar className="w-8 h-8" />
</div>
)}
{/* Sponsored badge */}
{event.isSponsored && (
<span className="absolute top-4 left-4 inline-flex items-center gap-1 rounded-full bg-paper px-2.5 py-0.5 text-[9px] font-mono font-bold text-turquoise border border-turquoise/20 uppercase tracking-wider shadow-sm">
<Zap className="w-3 h-3 fill-turquoise text-turquoise" />
{t('sponsored')}
</span>
)}
</div>
{/* Event Details */}
<div className="p-6 flex-1 flex flex-col justify-between space-y-4">
<div className="space-y-2">
{/* Date badge */}
<div className="flex items-center gap-1.5 text-[11px] font-mono text-shutter font-bold uppercase tracking-wider">
<Calendar className="w-3.5 h-3.5" />
<span>
{new Date(event.startDate).toLocaleDateString(locale, {
day: 'numeric',
month: 'long',
hour: '2-digit',
minute: '2-digit'
})}
</span>
</div>
<h3 className="font-heading font-extrabold text-lg text-pine lowercase group-hover:text-turquoise transition-colors leading-tight">
{title}
</h3>
<p className="text-ink/70 text-xs leading-relaxed font-medium line-clamp-3">
{desc}
</p>
</div>
{/* Hosting Venue info */}
{event.listing && (
<div className="border-t border-dashed border-pine/8 pt-4 flex items-center justify-between text-xs">
<div className="flex items-center gap-1 text-ink/75 font-semibold">
<MapPin className="w-3.5 h-3.5 text-shutter/65" />
<span className="lowercase text-shutter">{t('venue')}:</span>
<Link
href={`/${event.listing.category?.slug || 'isletme'}/${event.listing.slug}`}
className="text-pine hover:text-turquoise transition-colors"
>
{venueName}
</Link>
</div>
</div>
)}
</div>
</div>
)
})}
</div>
)}
</main>
)
}
-156
View File
@@ -1,156 +0,0 @@
import { getTranslations, setRequestLocale } from 'next-intl/server'
import { mockDb } from '@/lib/mockDb'
import ListingCard from '@/components/ListingCard'
import { SlidersHorizontal } from 'lucide-react'
interface PageProps {
params: Promise<{ locale: string }>
searchParams: Promise<{
search?: string
neighborhood?: string
price?: string
approved?: string
}>
}
export default async function BusinessesPage({ params, searchParams }: PageProps) {
const { locale } = await params
setRequestLocale(locale)
const { search, neighborhood, price, approved } = await searchParams
const t = await getTranslations('categories')
// Find Category Isletme
const categories = await mockDb.getCategories()
const currentCategory = categories.find(c => c.slug === 'isletme')
const categoryId = currentCategory?.id
// Get active neighborhoods for filter
const neighborhoods = await mockDb.getNeighborhoods()
// Selected filters
const selectedNeighborhoodId = neighborhood || undefined
const selectedPriceRange = price ? parseInt(price) : undefined
const isApprovedOnly = approved === 'true'
const listings = await mockDb.getListings({
categoryId,
neighborhoodId: selectedNeighborhoodId,
priceRange: selectedPriceRange,
isLocalApproved: isApprovedOnly ? true : undefined,
search: search
})
const getLocalizedName = (obj: any) => {
if (!obj) return ''
return locale === 'ru' ? obj.nameRu : locale === 'en' ? obj.nameEn : obj.nameTr
}
return (
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 flex-1">
{/* Header */}
<div className="mb-8">
<h1 className="text-3xl font-heading font-extrabold text-pine lowercase">
{t('isletme')}
</h1>
<p className="text-xs text-shutter font-mono uppercase tracking-wider mt-1">
marmaris local {listings.length} {locale === 'tr' ? 'sonuç' : locale === 'en' ? 'results' : 'результатов'}
</p>
</div>
{/* Filters Panel */}
<div className="bg-paper p-5 rounded-2xl border border-pine/8 shadow-sm mb-10">
<div className="flex items-center gap-2 mb-4 font-heading font-bold text-sm text-pine lowercase border-b border-dashed border-pine/8 pb-3">
<SlidersHorizontal className="w-4 h-4 text-turquoise" />
<span>filtreler</span>
</div>
<form method="GET" className="grid grid-cols-1 sm:grid-cols-4 gap-4 items-end">
{/* Search Input */}
<div className="space-y-1.5">
<label className="block text-[11px] font-mono uppercase tracking-wider text-shutter">Arama</label>
<input
type="text"
name="search"
defaultValue={search || ''}
placeholder="İsim veya adres..."
className="w-full bg-stone border border-pine/10 rounded-xl px-3 py-2 text-xs focus:ring-1 focus:ring-turquoise outline-none"
/>
</div>
{/* Neighborhood select */}
<div className="space-y-1.5">
<label className="block text-[11px] font-mono uppercase tracking-wider text-shutter">{t('filterNeighborhood')}</label>
<select
name="neighborhood"
defaultValue={neighborhood || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-3 py-2 text-xs focus:ring-1 focus:ring-turquoise outline-none appearance-none"
>
<option value="">{t('allNeighborhoods')}</option>
{neighborhoods.map((n) => (
<option key={n.id} value={n.id}>
{getLocalizedName(n)}
</option>
))}
</select>
</div>
{/* Price range select */}
<div className="space-y-1.5">
<label className="block text-[11px] font-mono uppercase tracking-wider text-shutter">{t('filterPrice')}</label>
<select
name="price"
defaultValue={price || ''}
className="w-full bg-stone border border-pine/10 rounded-xl px-3 py-2 text-xs focus:ring-1 focus:ring-turquoise outline-none"
>
<option value="">{t('allPrices')}</option>
<option value="1"> (Ekonomik)</option>
<option value="2"> (Orta)</option>
<option value="3"> (Lüks)</option>
</select>
</div>
{/* Submit / Checkbox area */}
<div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-4">
<label className="flex items-center gap-2 cursor-pointer select-none text-xs font-semibold py-2.5">
<input
type="checkbox"
name="approved"
value="true"
defaultChecked={isApprovedOnly}
className="rounded border-pine/10 text-turquoise focus:ring-turquoise w-4 h-4"
/>
<span className="text-pine">{t('filterApproved')}</span>
</label>
<button
type="submit"
className="flex-1 bg-turquoise hover:bg-turquoise/90 text-paper text-xs font-bold py-2.5 px-4 rounded-xl transition text-center"
>
Filtrele
</button>
</div>
</form>
</div>
{/* Results */}
{listings.length === 0 ? (
<div className="bg-paper/50 rounded-2xl border border-dashed border-pine/12 p-12 text-center text-shutter">
<p className="text-sm font-medium">{t('noResults')}</p>
</div>
) : (
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8">
{listings.map((listing) => (
<ListingCard key={listing.id} listing={listing} />
))}
</div>
)}
</main>
</div>
)
}
+4 -1
View File
@@ -1,3 +1,4 @@
import { mockDb } from '../../lib/mockDb';
import type { Metadata } from "next";
import { Unbounded, Golos_Text, IBM_Plex_Mono } from "next/font/google";
import { NextIntlClientProvider } from 'next-intl';
@@ -57,6 +58,8 @@ export default async function RootLayout({
const pathname = headersList.get('x-pathname') || '';
const hideNavbarFooter = pathname.includes('/admin') || pathname.includes('/login');
const categories = await mockDb.getCategories();
return (
<html
lang={locale}
@@ -64,7 +67,7 @@ export default async function RootLayout({
>
<body className="min-h-full flex flex-col font-sans" suppressHydrationWarning>
<NextIntlClientProvider messages={messages}>
{!hideNavbarFooter && <Navbar />}
{!hideNavbarFooter && <Navbar categories={categories} />}
{children}
{!hideNavbarFooter && <Footer />}
</NextIntlClientProvider>
+5 -9
View File
@@ -32,11 +32,7 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
isletme: 'https://images.unsplash.com/photo-1544551763-46a013bb70d5?w=800&auto=format&fit=crop&q=80'
}
const categoryPaths: Record<string, string> = {
restoran: '/restoranlar',
apart: '/apartlar',
isletme: '/isletmeler'
}
return (
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
@@ -77,7 +73,7 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
{/* Search Form */}
<form
action={`/${locale}/restoranlar`}
action={`/${locale}/restoran`}
method="GET"
className="max-w-xl mx-auto bg-paper p-2 rounded-2xl flex items-center shadow-lg border border-white/10"
>
@@ -122,7 +118,7 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
{categories.map((cat) => {
const imageUrl = categoryImages[cat.slug] || categoryImages.isletme
const path = categoryPaths[cat.slug] || '/isletmeler'
const path = `/${cat.slug}`
const catName = getLocalizedName(cat)
return (
@@ -172,7 +168,7 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
</div>
<Link
href="/restoranlar?approved=true"
href="/restaurants?approved=true"
className="flex items-center gap-1 text-xs font-bold text-pine hover:text-turquoise transition-colors border-b border-pine/20 hover:border-turquoise pb-1 w-fit"
>
<span>{locale === 'tr' ? 'tüm onaylı mekanlar' : locale === 'en' ? 'all approved places' : 'все проверенные места'}</span>
@@ -206,7 +202,7 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
return (
<Link
key={neigh.id}
href={`/mahalle/${neigh.slug}`}
href={`/neighborhood/${neigh.slug}`}
className="bg-paper p-5 rounded-xl border border-pine/8 text-center hover:border-turquoise/40 hover:bg-paper/90 transition shadow-sm group flex flex-col items-center gap-2"
>
<MapPin className="w-5 h-5 text-shutter group-hover:text-turquoise transition-colors" />
+256 -13
View File
@@ -1,4 +1,6 @@
'use server'
"use server"
import { redirect } from "next/navigation"
import { mockDb } from '@/lib/mockDb'
import { uploadToOpeninary } from '@/lib/openinary'
@@ -100,9 +102,9 @@ export async function approveSubmissionAction(id: string) {
await mockDb.updateSubmissionStatus(id, 'APPROVED')
revalidatePath('/admin/submissions')
revalidatePath('/restoranlar')
revalidatePath('/apartlar')
revalidatePath('/isletmeler')
revalidatePath('/restaurants')
revalidatePath('/aparts')
revalidatePath('/businesses')
return { success: true }
}
@@ -115,12 +117,32 @@ export async function rejectSubmissionAction(id: string) {
export async function deleteListingAction(id: string) {
await mockDb.deleteListing(id)
revalidatePath('/admin/listings')
revalidatePath('/restoranlar')
revalidatePath('/apartlar')
revalidatePath('/isletmeler')
revalidatePath('/restaurants')
revalidatePath('/aparts')
revalidatePath('/businesses')
return { success: true }
}
export async function restoreListingAction(id: string) {
await mockDb.restoreListing(id)
revalidatePath('/admin/trash')
revalidatePath('/admin/listings')
return { success: true }
}
export async function hardDeleteListingAction(id: string) {
try {
await mockDb.hardDeleteListing(id)
revalidatePath('/admin/trash')
return { success: true }
} catch (err: any) {
if (err.message?.includes('RESTRICT') || err.message?.includes('Foreign key constraint')) {
return { success: false, error: 'Silme başarısız: Bu mekana bağlı etkinlik (Event) veya kayıtlar var.' }
}
return { success: false, error: err.message || 'Bilinmeyen bir hata oluştu.' }
}
}
export async function markMessageReadAction(id: string) {
await mockDb.markMessageAsRead(id)
revalidatePath('/admin/messages')
@@ -225,9 +247,9 @@ export async function createOrUpdateListingAction(formData: FormData) {
await mockDb.createListing(data)
}
revalidatePath('/admin/listings')
revalidatePath('/restoranlar')
revalidatePath('/apartlar')
revalidatePath('/isletmeler')
revalidatePath('/restaurants')
revalidatePath('/aparts')
revalidatePath('/businesses')
return { success: true }
} catch (err: any) {
return { success: false, error: err.message || 'Mekan kaydedilemedi.' }
@@ -307,7 +329,7 @@ export async function createOrUpdateBlogPostAction(formData: FormData) {
export async function deleteCollectionAction(id: string) {
await mockDb.deleteCollection(id)
revalidatePath('/admin/collections')
revalidatePath('/seckiler')
revalidatePath('/collections')
return { success: true }
}
@@ -356,10 +378,231 @@ export async function createOrUpdateCollectionAction(formData: FormData) {
await mockDb.createCollection(data)
}
revalidatePath('/admin/collections')
revalidatePath('/seckiler')
revalidatePath(`/secki/${slug}`)
revalidatePath('/collections')
revalidatePath(`/collection/${slug}`)
return { success: true }
} catch (err: any) {
return { success: false, error: err.message || 'Koleksiyon kaydedilemedi.' }
}
}
// Events Actions (Phase 3)
export async function deleteEventAction(id: string) {
await mockDb.deleteEvent(id)
revalidatePath('/admin/events')
revalidatePath('/events')
return { success: true }
}
export async function createOrUpdateEventAction(formData: FormData) {
const id = formData.get('id') as string | null
const slug = formData.get('slug') as string
const listingId = formData.get('listingId') as string | null || null
const titleTr = formData.get('titleTr') as string
const titleEn = formData.get('titleEn') as string
const titleRu = formData.get('titleRu') as string
const descriptionTr = formData.get('descriptionTr') as string
const descriptionEn = formData.get('descriptionEn') as string
const descriptionRu = formData.get('descriptionRu') as string
const startDateStr = formData.get('startDate') as string
const endDateStr = formData.get('endDate') as string | null
const isSponsored = formData.get('isSponsored') === 'true'
const startDate = new Date(startDateStr)
const endDate = endDateStr ? new Date(endDateStr) : null
// Handle Cover Image
const coverImageFile = formData.get('coverImageFile') as File | null
let coverImage = formData.get('coverImageUrl') as string | null || null
if (coverImageFile && coverImageFile.size > 0) {
try {
coverImage = await uploadToOpeninary(coverImageFile, `events/${slug}`)
} catch (e: any) {
console.error('Event cover upload error:', e)
return { success: false, error: `Kapak görseli yüklenemedi: ${e.message}` }
}
}
const data = {
slug,
listingId,
titleTr,
titleEn,
titleRu,
descriptionTr,
descriptionEn,
descriptionRu,
startDate,
endDate,
coverImage,
isSponsored
}
try {
if (id && id !== 'new') {
await mockDb.updateEvent(id, data)
} else {
await mockDb.createEvent(data)
}
revalidatePath('/admin/events')
revalidatePath('/events')
revalidatePath(`/event/${slug}`)
return { success: true }
} catch (err: any) {
return { success: false, error: err.message || 'Etkinlik kaydedilemedi.' }
}
}
// Neighborhood Actions
export async function deleteNeighborhoodAction(id: string) {
try {
const listings = await mockDb.getListings({ neighborhoodId: id })
if (listings && listings.length > 0) {
return { success: false, error: `Silme başarısız: Bu mahalleye kayıtlı ${listings.length} adet mekan var.` }
}
await mockDb.deleteNeighborhood(id)
revalidatePath('/admin/neighborhoods')
return { success: true }
} catch (err: any) {
if (err.message?.includes('RESTRICT') || err.message?.includes('Foreign key constraint')) {
return { success: false, error: 'Silme başarısız: Bu mahalleye bağlı gizli (silinmiş veya arşivlenmiş) mekanlar veya etkinlikler var.' }
}
return { success: false, error: err.message || 'Bilinmeyen bir hata oluştu.' }
}
}
export async function createOrUpdateNeighborhoodAction(formData: FormData) {
const id = formData.get('id') as string | null
const slug = formData.get('slug') as string
const nameTr = formData.get('nameTr') as string
const nameEn = formData.get('nameEn') as string
const nameRu = formData.get('nameRu') as string
if (!slug || !nameTr || !nameEn || !nameRu) {
return { error: 'Zorunlu alanları doldurun.' }
}
const data = {
slug,
nameTr,
nameEn,
nameRu,
}
try {
if (id && id !== 'new') {
await mockDb.updateNeighborhood(id, data)
} else {
await mockDb.createNeighborhood(data)
}
revalidatePath('/admin/neighborhoods')
return { success: true }
} catch (err: any) {
return { success: false, error: err.message || 'Mahalle kaydedilemedi.' }
}
}
// AI Itinerary Planner Actions (Phase 3)
import crypto from 'crypto'
async function generateMockItinerary(days: number, style: string, neighborhoodSlugs: string[]) {
const allListings = await mockDb.getListings()
const matchingListings = allListings.filter(l =>
!l.deletedAt && l.isLocalApproved &&
(neighborhoodSlugs.length === 0 ||
(l.neighborhood && neighborhoodSlugs.includes(l.neighborhood.slug)))
)
const pool = matchingListings.length > 0 ? matchingListings : allListings.filter(l => !l.deletedAt && l.isLocalApproved)
let md = `# marmaris local kişisel gezi rotası 🌴\n\n`
md += `**gün sayısı:** ${days} gün | **gezi tarzı:** ${style === 'gastronomy' ? 'gurme' : style === 'relaxation' ? 'dinlenme' : 'macera'} | **keşif bölgeleri:** ${neighborhoodSlugs.join(', ')}\n\n`
md += `bu rota, marmaris local topluluğu tarafından onaylanmış yerel işletmeler temel alınarak oluşturulmuştur.\n\n---\n\n`
for (let day = 1; day <= days; day++) {
md += `## 🗓️ gün ${day}\n\n`
const dayListings = [...pool].sort(() => 0.5 - Math.random()).slice(0, 3)
if (dayListings.length >= 1) {
md += `### 🌅 sabah: kahvaltı ve başlangıç\n`
md += `güne yerel onaylı **[${dayListings[0].nameTr}](/${dayListings[0].category?.slug || 'isletme'}/${dayListings[0].slug})** işletmesinde başlayın. \n`
md += `> **yerel ipucu:** ${dayListings[0].descriptionTr}\n\n`
}
if (dayListings.length >= 2) {
md += `### ☀️ öğle: keşif zamanı\n`
md += `öğleden sonra **[${dayListings[1].nameTr}](/${dayListings[1].category?.slug || 'isletme'}/${dayListings[1].slug})** mekanına uğrayın ve çevreyi keşfedin.\n`
md += `> **editör notu:** ${dayListings[1].address}\n\n`
}
if (dayListings.length >= 3) {
md += `### 🌌 akşam: gün batımı ve akşam yemeği\n`
md += `akşamı şık bir akşam yemeğiyle taçlandırın: **[${dayListings[2].nameTr}](/${dayListings[2].category?.slug || 'isletme'}/${dayListings[2].slug})**.\n`
md += `> **özel detaylar:** rating: ★${dayListings[2].rating} • tel: ${dayListings[2].phone || 'belirtilmemiş'}\n\n`
}
md += `---\n\n`
}
md += `*not: seyahatiniz boyunca yerel rehberimizdeki işletmeleri ziyaret etmeyi ve favorilerinize eklemeyi unutmayın!*`
return {
content: md,
listingIds: pool.map(l => l.id)
}
}
export async function generateItineraryAction(days: number, style: string, neighborhoodSlugs: string[]) {
const sorted = [...neighborhoodSlugs].sort()
const paramsHash = crypto.createHash('md5').update(JSON.stringify({ days, style, neighborhoodSlugs: sorted })).digest('hex')
const existing = await mockDb.getItineraryByHash(paramsHash)
if (existing) {
return { success: true, id: existing.id }
}
// Generate new program
const { content, listingIds } = await generateMockItinerary(days, style, sorted)
const newItin = await mockDb.createItinerary({
paramsHash,
params: { days, style, neighborhoodSlugs: sorted },
content,
listingIds
})
return { success: true, id: newItin.id }
}
export async function createOrUpdateCategoryAction(formData: FormData) {
const id = formData.get('id') as string
const slug = formData.get('slug') as string
const nameTr = formData.get('nameTr') as string
const nameEn = formData.get('nameEn') as string
const nameRu = formData.get('nameRu') as string
if (!slug || !nameTr || !nameEn || !nameRu) {
throw new Error('Eksik alanlar var')
}
if (id && id !== 'new') {
await mockDb.updateCategory(id, { slug, nameTr, nameEn, nameRu })
} else {
await mockDb.createCategory({ slug, nameTr, nameEn, nameRu })
}
revalidatePath('/admin/categories')
redirect('/tr/admin/categories')
}
export async function deleteCategoryAction(formData: FormData) {
const id = formData.get('id') as string
if (!id) return
await mockDb.deleteCategory(id)
revalidatePath('/admin/categories')
}
+26
View File
@@ -0,0 +1,26 @@
import { NextRequest, NextResponse } from 'next/server'
import { mockDb } from '@/lib/mockDb'
export async function POST(req: NextRequest) {
try {
const body = await req.json()
const { listingId, actionType } = body
if (!listingId || !actionType) {
return NextResponse.json({ error: 'listingId and actionType are required' }, { status: 400 })
}
const validActions = ['views', 'whatsapp', 'phone', 'menu']
if (!validActions.includes(actionType)) {
return NextResponse.json({ error: 'Invalid actionType' }, { status: 400 })
}
// Call stateful DB increment
const record = await mockDb.incrementAnalytics(listingId, actionType)
return NextResponse.json({ success: true, record })
} catch (err: any) {
console.error('Error logging event analytics:', err)
return NextResponse.json({ error: err.message || 'Internal Server Error' }, { status: 500 })
}
}
+61
View File
@@ -0,0 +1,61 @@
import { NextRequest, NextResponse } from 'next/server'
import { mockDb } from '@/lib/mockDb'
export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url)
const neighborhoodSlug = searchParams.get('neighborhood')
if (!neighborhoodSlug) {
return NextResponse.json({ error: 'Neighborhood is required' }, { status: 400 })
}
// Get neighborhood
const neighborhood = await mockDb.getNeighborhoodBySlug(neighborhoodSlug)
if (!neighborhood) {
return NextResponse.json({ listings: [] }, {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, OPTIONS',
}
})
}
// Get listings in that neighborhood that are local approved
const listings = await mockDb.getListings({
neighborhoodId: neighborhood.id,
isLocalApproved: true
})
// Format response matching widget needs
const formattedListings = listings.map(l => ({
id: l.id,
name: l.nameTr,
nameEn: l.nameEn,
nameRu: l.nameRu,
slug: l.slug,
categorySlug: l.category?.slug || 'isletme',
categoryName: l.category?.nameTr || '',
neighborhoodName: l.neighborhood?.nameTr || '',
rating: l.rating,
priceSymbols: '₺'.repeat(l.priceRange),
coverImage: 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 NextResponse.json({ listings: formattedListings }, {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, OPTIONS',
}
})
}
// Handle preflight OPTIONS request
export async function OPTIONS() {
return new NextResponse(null, {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type',
}
})
}
+1 -1
View File
@@ -35,7 +35,7 @@ export async function GET() {
// Add newly added approved listings
for (const listing of listings.slice(0, 10)) {
const pubDate = new Date(listing.createdAt).toUTCString()
const catSlug = listing.category?.slug || 'isletmeler'
const catSlug = listing.category?.slug || 'businesses'
xml += ` <item>
<title><![CDATA[Yeni Onaylandı: ${listing.nameTr} (${listing.neighborhood?.nameTr})]]></title>
<link>${baseUrl}/tr/${catSlug}/${listing.slug}</link>
+7 -7
View File
@@ -8,12 +8,12 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
// Static routes
const staticRoutes = [
'',
'/apartlar',
'/restoranlar',
'/isletmeler',
'/isletme-ekle',
'/iletisim',
'/hakkinda'
'/aparts',
'/restaurants',
'/businesses',
'/add-business',
'/contact',
'/about'
]
const sitemapEntries: MetadataRoute.Sitemap = []
@@ -55,7 +55,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
for (const neighborhood of neighborhoods) {
for (const locale of locales) {
sitemapEntries.push({
url: `${baseUrl}/${locale}/mahalle/${neighborhood.slug}`,
url: `${baseUrl}/${locale}/neighborhood/${neighborhood.slug}`,
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.4,