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

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

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

  // Configuration for EntityAttachmentDetailPage
  const config = useMemo(() => ({
    entityType: "in-school",
    entityIdParam: "isid", // InSchool uses 'isid' for event 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: AcademicCapIcon,
          href: "/admin/events"
        },
        {
          label: "In-School",
          icon: AcademicCapIcon,
          href: "/admin/event/in-school"
        },
        {
          label: "Detail",
          href: `/admin/event/in-school/${eventId}`
        },
        {
          label: "Attachments",
          href: `/admin/event/in-school/${eventId}/attachments`
        },
        {
          label: "Attachment Detail",
          icon: DocumentTextIcon,
          current: true
        }
      ],

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

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

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

function AdminInSchoolDetailAttachmentDetailPage() {
  return (
    <UIXThemeProvider>
      <AdminInSchoolDetailAttachmentDetailPageContent />
    </UIXThemeProvider>
  );
}

export default AdminInSchoolDetailAttachmentDetailPage;
