49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { mockDb } from '@/lib/mockDb'
|
||
import BlogForm from './BlogForm'
|
||
import { notFound } from 'next/navigation'
|
||
|
||
interface Props {
|
||
params: Promise<{ locale: string; id: string }>
|
||
}
|
||
|
||
export default async function AdminBlogEditPage({ params }: Props) {
|
||
const { id } = await params
|
||
let post = null
|
||
|
||
if (id !== 'new') {
|
||
post = await mockDb.getBlogPostById(id)
|
||
if (!post) {
|
||
notFound()
|
||
}
|
||
}
|
||
|
||
// Fetch listings to link them to the blog post
|
||
const listings = await mockDb.getListings()
|
||
const listingOptions = listings.map(l => ({
|
||
value: l.id,
|
||
label: `${l.nameTr} (${l.neighborhood?.nameTr})`
|
||
}))
|
||
|
||
return (
|
||
<div className="space-y-6 max-w-5xl">
|
||
<div>
|
||
<h2 className="text-3xl font-heading font-extrabold text-pine lowercase">
|
||
{id === 'new' ? 'yeni blog yazısı' : 'yazıyı düzenle'}
|
||
</h2>
|
||
<p className="text-ink/65 text-xs font-medium mt-1">
|
||
{id === 'new'
|
||
? 'Yeni bir rehber veya gastronomi tanıtım yazısı oluşturun.'
|
||
: 'Mevcut blog yazısı içeriğini güncelleyin.'}
|
||
</p>
|
||
</div>
|
||
|
||
<div className="bg-paper border border-pine/8 rounded-3xl shadow-sm p-6 sm:p-8">
|
||
<BlogForm
|
||
post={post}
|
||
listingOptions={listingOptions}
|
||
/>
|
||
</div>
|
||
</div>
|
||
)
|
||
}
|