"use client";

import Link from "next/link";
import { useParams } from "next/navigation";
import { Button } from "@/components/admin/controls";
import { getCommercialAdminResource } from "@/modules/commercial/admin/resources";
import { AdminRegistryManager } from "@/modules/commercial/features/admin-registry";
import { AdminRecommendationSimulator } from "@/modules/commercial/features/admin-recommendations";

export default function AdminCommercialResourcePage() {
  const params = useParams();
  const key = String(params.resource || "");
  const resource = getCommercialAdminResource(key);

  if (!resource) {
    return (
      <div className="space-y-4">
        <p className="text-sm text-gray-600">
          این بخش هنوز عنوان نمایشی و تنظیمات مدیریتی کامل ندارد.
        </p>
        <Link href="/admin/commercial">
          <Button variant="outline">بازگشت به پرتال تجاری</Button>
        </Link>
      </div>
    );
  }

  return (
    <div className="space-y-8">
      <AdminRegistryManager resource={resource} />
      {resource.key === "recommendation-rules" ? <AdminRecommendationSimulator /> : null}
    </div>
  );
}
