Files
marmarislocal/app/[locale]/plan/[id]/page.tsx
T
AyrisAIandClaude Sonnet 5 1b8cfeda95 feat: harden admin security, add AI trip planner, map view, and SEO/notification improvements
Security:
- requireAdmin() session check added to every admin-only server action
  (previously relied only on middleware path matching, which Next.js
  Server Actions don't reliably respect)
- Real Prisma + bcrypt admin auth, replacing hardcoded credentials; split
  into an Edge-safe auth.config.ts (used by proxy.ts) and the full
  Prisma-backed auth.ts (route handler, server actions, server components)
- Removed hardcoded fallback secret on the Instagram sync cron endpoint
- Honeypot field + per-IP rate limiting on contact/business-submission
  forms and the analytics events endpoint

Features:
- AI trip planner (/plan-olustur, /plan/[id]) backed by DeepSeek, grounded
  to only recommend isLocalApproved listings, with a deterministic
  link-injection fallback for anything the model doesn't format as markdown
- Interactive Leaflet/OpenStreetMap view on category listing pages
- Telegram notifications for new contact messages and business submissions

SEO:
- Brand-consistent favicon/apple-icon/PWA icons and default Open Graph/
  Twitter share images, generated via next/og (replacing default Next.js
  placeholders)
- BreadcrumbList structured data on category and listing detail pages
- Fixed two remaining raw <img> tags to use next/image

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-24 00:01:06 +03:00

87 lines
3.1 KiB
TypeScript

import { getTranslations, setRequestLocale } from 'next-intl/server'
import { mockDb } from '@/lib/mockDb'
import { Link } from '@/i18n/routing'
import { notFound } from 'next/navigation'
import { renderMarkdownToHtml } from '@/lib/markdown'
import ListingCard from '@/components/ListingCard'
import { ArrowLeft, Sparkles } from 'lucide-react'
import type { Metadata } from 'next'
import { basicMetadata } from '@/lib/seo'
interface Props {
params: Promise<{ locale: string; id: string }>
}
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { locale, id } = await params
const itinerary = await mockDb.getItineraryById(id)
if (!itinerary) return {}
const t = await getTranslations({ locale, namespace: 'planner' })
const p = itinerary.params as { days?: number }
const title = `${p.days ?? ''}${locale === 'tr' ? ' günlük' : locale === 'ru' ? '-дневный' : '-day'} ${t('title')} — Marmaris Local`
const description = itinerary.content.replace(/[#*_>[\]()]/g, '').slice(0, 150)
return basicMetadata(title, description, locale)
}
export default async function PlanResultPage({ params }: Props) {
const { locale, id } = await params
setRequestLocale(locale)
const itinerary = await mockDb.getItineraryById(id)
if (!itinerary) {
notFound()
}
const t = await getTranslations('planner')
const htmlContent = renderMarkdownToHtml(itinerary.content)
const relatedListings: any[] = []
for (const listingId of itinerary.listingIds.slice(0, 6)) {
const listing = await mockDb.getListingById(listingId)
if (listing) relatedListings.push(listing)
}
return (
<div className="bg-stone min-h-screen py-10 px-4 sm:px-6 lg:px-8 font-sans">
<div className="max-w-3xl mx-auto space-y-8">
<div className="flex flex-wrap items-center justify-between gap-3">
<Link
href="/plan-olustur"
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" />
{t('generate')}
</Link>
</div>
<article className="bg-paper border border-pine/8 rounded-3xl overflow-hidden shadow-sm p-6 sm:p-10 space-y-6">
<div className="flex items-center gap-2 text-xs font-mono uppercase tracking-wider text-turquoise">
<Sparkles className="w-4 h-4" />
{t('title')}
</div>
<div
className="markdown-content space-y-4"
dangerouslySetInnerHTML={{ __html: htmlContent }}
/>
</article>
{relatedListings.length > 0 && (
<div className="space-y-6 pt-6">
<h3 className="text-xl font-heading font-extrabold text-pine lowercase border-b border-dashed border-pine/8 pb-3">
{t('placesInPlan')}
</h3>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-6">
{relatedListings.map((listing) => (
<ListingCard key={listing.id} listing={listing} />
))}
</div>
</div>
)}
</div>
</div>
)
}