Files
marmarislocal/app/[locale]/contact/ContactForm.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

128 lines
4.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client'
import { useState } from 'react'
import { submitContactMessageAction } from '@/app/actions'
import HoneypotField from '@/components/HoneypotField'
interface Translations {
name: string
email: string
subject: string
message: string
submit: string
sending: string
success: string
}
interface FormProps {
translations: Translations
}
export default function ContactForm({ translations }: FormProps) {
const [success, setSuccess] = useState(false)
const [error, setError] = useState('')
const [loading, setLoading] = useState(false)
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
setLoading(true)
setError('')
const formData = new FormData(e.currentTarget)
try {
const res = await submitContactMessageAction(formData)
if (res.error) {
setError(res.error)
} else {
setSuccess(true)
e.currentTarget.reset()
}
} catch (err) {
setError('Bir hata oluştu. Lütfen tekrar deneyin.')
} finally {
setLoading(false)
}
}
if (success) {
return (
<div className="bg-turquoise/10 border border-turquoise/20 text-turquoise p-6 rounded-2xl text-center space-y-3">
<h3 className="font-heading font-bold text-lg lowercase">teşekkürler!</h3>
<p className="text-sm font-medium">{translations.success}</p>
</div>
)
}
return (
<form onSubmit={handleSubmit} className="space-y-6">
{error && (
<div className="bg-bougainvillea/10 border border-bougainvillea/20 text-bougainvillea p-4 rounded-xl text-xs font-semibold">
{error}
</div>
)}
<HoneypotField />
{/* Name */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">{translations.name} *</label>
<input
type="text"
name="name"
required
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink placeholder:text-ink/30"
placeholder="Adınız Soyadınız"
/>
</div>
{/* Email */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">{translations.email} *</label>
<input
type="email"
name="email"
required
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink placeholder:text-ink/30"
placeholder="eposta@adresiniz.com"
/>
</div>
{/* Subject */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">{translations.subject} *</label>
<select
name="subject"
required
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink appearance-none"
>
<option value="">Konu seçin...</option>
<option value="Genel">Genel Sorular</option>
<option value="İşbirliği">İşbirliği</option>
<option value="Hata Bildirimi">Hata Bildirimi</option>
<option value="Diğer">Diğer</option>
</select>
</div>
{/* Message */}
<div className="space-y-1.5">
<label className="block text-xs font-mono uppercase tracking-wider text-shutter">{translations.message} *</label>
<textarea
name="message"
required
rows={5}
className="w-full bg-stone border border-pine/10 rounded-xl px-4 py-3 text-sm focus:ring-1 focus:ring-turquoise outline-none text-ink placeholder:text-ink/30"
placeholder="Mesajınızı buraya yazın..."
/>
</div>
<button
type="submit"
disabled={loading}
className="w-full bg-turquoise hover:bg-turquoise/90 disabled:opacity-75 disabled:cursor-not-allowed text-paper font-bold text-sm py-4.5 px-4 rounded-xl transition duration-300 shadow-sm"
>
{loading ? translations.sending : translations.submit}
</button>
</form>
)
}