// File Path: monorepo/web/frontend/src/pages/Admin/Event/Conference/Detail/Attachment/Detail/Page.jsx

import React, { useMemo, memo } from "react";
import {
  CalendarIcon,
  PaperClipIcon,
  DocumentTextIcon,
  ChartBarIcon,
} from "@heroicons/react/24/outline";
import { useAttachmentManager } from "../../../../../../../services/Services";
import {
  UIXThemeProvider,
  EntityAttachmentDetailPage,
} from "../../../../../../../components/UIX";

const AdminConferenceDetailAttachmentDetailPageContent = memo(
  function AdminConferenceDetailAttachmentDetailPageContent() {
    const attachmentManager = useAttachmentManager();

    // Configuration for EntityAttachmentDetailPage
    const config = useMemo(
      () => ({
        entityType: "conference",
        entityIdParam: "cid", // Conference uses 'cid' for conference ID
        attachmentIdParam: "atid", // and 'atid' for attachment ID

        // Data operations
        onAttachmentFetch: async (attachmentId, onUnauthorized) => {
          return await attachmentManager.getAttachmentDetail(
            attachmentId,
            onUnauthorized,
          );
        },

        // Route configuration
        routes: {
          buildBreadcrumbs: (eventId, attachmentId) => [
            {
              label: "Dashboard",
              href: "/admin/dashboard",
              icon: ChartBarIcon,
            },
            {
              label: "Events",
              icon: CalendarIcon,
              href: "/admin/events",
            },
            {
              label: "Conference",
              href: "/admin/event/conference",
            },
            {
              label: "Detail",
              href: `/admin/event/conference/${eventId}`,
            },
            {
              label: "Attachments",
              href: `/admin/event/conference/${eventId}/attachments`,
            },
            {
              label: "Attachment Detail",
              icon: DocumentTextIcon,
              current: true,
            },
          ],

          backPath: `/admin/event/conference/{entityId}/attachments`,
          editPath: `/admin/event/conference/{entityId}/attachment/{attachmentId}/update`,
          deletePath: `/admin/event/conference/{entityId}/attachment/{attachmentId}/delete`,
        },

        // Header configuration
        header: {
          pageTitle: "Conference Event - Attachment Detail",
          pageIcon: PaperClipIcon,
          itemIcon: CalendarIcon,
          itemType: "Conference Event",
          backLabel: "Back to Attachments",
        },
      }),
      [attachmentManager],
    );

    return <EntityAttachmentDetailPage config={config} />;
  },
);

function AdminConferenceDetailAttachmentDetailPage() {
  return (
    <UIXThemeProvider>
      <AdminConferenceDetailAttachmentDetailPageContent />
    </UIXThemeProvider>
  );
}

export default AdminConferenceDetailAttachmentDetailPage;
