import { getTranslations } from 'next-intl/server'
import { mockDb } from '@/lib/mockDb'
import { notFound } from 'next/navigation'
import WidgetPartnerForm from './WidgetPartnerForm'

export const dynamic = 'force-dynamic'

interface Props {
  params: Promise<{ id: string; locale: string }>
}

export default async function EditWidgetPartnerPage({ params }: Props) {
  const { id } = await params
  const isNew = id === 'new'
  
  let partner = null
  if (!isNew) {
    partner = (await mockDb.getWidgetPartners()).find(p => p.id === id)
    if (!partner) notFound()
  }

  return (
    <div className="max-w-3xl mx-auto py-10 space-y-6">
      <div className="flex flex-col gap-1 mb-8">
        <h2 className="text-3xl font-heading font-extrabold text-pine lowercase">
          {isNew ? 'yeni partner ekle' : 'partneri düzenle'}
        </h2>
        <p className="text-ink/65 text-xs font-medium">
          Widget partneri bilgilerini buradan {isNew ? 'ekleyebilirsiniz' : 'düzenleyebilirsiniz'}.
        </p>
      </div>

      <WidgetPartnerForm initialData={partner} />
    </div>
  )
}
