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

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

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

    // Configuration for EntityAttachmentDetailPage
    const config = useMemo(
      () => ({
        entityType: "event-order",
        entityIdParam: "eoid", // Event Order uses 'eoid' for event order ID
        attachmentIdParam: "atid", // and 'atid' for attachment ID

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

        // Route configuration
        routes: {
          buildBreadcrumbs: (eoid, attachmentId) => [
            {
              label: "Dashboard",
              href: "/admin/dashboard",
              icon: ChartBarIcon,
            },
            {
              label: "Event Orders",
              icon: TicketIcon,
              href: "/admin/event-orders",
            },
            {
              label: "Detail",
              href: `/admin/event-order/${eoid}`,
            },
            {
              label: "Attachments",
              href: `/admin/event-order/${eoid}/attachments`,
            },
            {
              label: "Attachment Detail",
              icon: DocumentTextIcon,
              current: true,
            },
          ],

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

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

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

function AdminEventOrderDetailAttachmentDetailPage() {
  return (
    <UIXThemeProvider>
      <AdminEventOrderDetailAttachmentDetailPageContent />
    </UIXThemeProvider>
  );
}

export default AdminEventOrderDetailAttachmentDetailPage;
