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

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

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

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

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

        // Route configuration
        routes: {
          buildBreadcrumbs: (speakerId, attachmentId) => [
            {
              label: "Dashboard",
              href: "/admin/dashboard",
              icon: ChartBarIcon,
            },
            {
              label: "Speakers",
              icon: MicrophoneIcon,
              href: "/admin/speakers",
            },
            {
              label: "Detail",
              href: `/admin/speaker/${speakerId}`,
            },
            {
              label: "Attachments",
              href: `/admin/speaker/${speakerId}/attachments`,
            },
            {
              label: "Attachment Detail",
              icon: DocumentTextIcon,
              current: true,
            },
          ],

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

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

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

function AdminSpeakerDetailAttachmentDetailPage() {
  return (
    <UIXThemeProvider>
      <AdminSpeakerDetailAttachmentDetailPageContent />
    </UIXThemeProvider>
  );
}

export default AdminSpeakerDetailAttachmentDetailPage;
