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

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

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

    // Configuration for EntityAttachmentDetailPage
    const config = useMemo(
      () => ({
        entityType: "virtual",
        entityIdParam: "vid", // Virtual uses 'vid' 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: HomeIcon,
            },
            {
              label: "Events",
              href: "/admin/events",
              icon: VideoCameraIcon,
            },
            {
              label: "Virtual",
              href: "/admin/event/virtuals",
              icon: VideoCameraIcon,
            },
            {
              label: "Detail",
              href: `/admin/event/virtual/${eventId}`,
            },
            {
              label: "Attachments",
              href: `/admin/event/virtual/${eventId}/attachments`,
            },
            {
              label: "Attachment Detail",
              icon: DocumentTextIcon,
              current: true,
            },
          ],

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

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

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

function AdminVirtualDetailAttachmentDetailPage() {
  return (
    <UIXThemeProvider>
      <AdminVirtualDetailAttachmentDetailPageContent />
    </UIXThemeProvider>
  );
}

export default AdminVirtualDetailAttachmentDetailPage;
