import { getProjectByIdAdmin, getServicesAdmin, getPartnersAdmin } from '../../../actions';
import ProjectForm from '../new/ProjectForm';
import Link from 'next/link';
import { ArrowLeft } from 'lucide-react';
import { notFound } from 'next/navigation';

export default async function EditProjectPage({ params }: { params: Promise<{ id: string }> }) {
    const { id } = await params;
    const project = await getProjectByIdAdmin(Number(id));
    const services = await getServicesAdmin();
    const partners = await getPartnersAdmin();

    if (!project) {
        notFound();
    }

    return (
        <div className="space-y-8 max-w-5xl">
            <div className="flex items-center gap-4">
                <Link href="/admin/projects" className="p-2 bg-white/5 hover:bg-white/10 rounded-xl transition-colors group">
                    <ArrowLeft className="w-5 h-5 text-white/40 group-hover:text-white" />
                </Link>
                <div>
                    <h1 className="text-3xl font-black uppercase tracking-widest text-white mb-2">Projeyi Düzenle</h1>
                    <p className="text-white/40">{project.title} projesini güncelliyorsunuz.</p>
                </div>
            </div>

            <ProjectForm initialData={project} services={services} partners={partners} />
        </div>
    );
}
