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

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

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

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

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

        // Route configuration
        routes: {
          buildBreadcrumbs: (staffId, attachmentId) => [
            {
              label: "Dashboard",
              href: "/admin/dashboard",
              icon: ChartBarIcon,
            },
            {
              label: "Staff",
              icon: UserCircleIcon,
              href: "/admin/staff",
            },
            {
              label: "Detail",
              href: `/admin/staff/${staffId}`,
            },
            {
              label: "Attachments",
              href: `/admin/staff/${staffId}/attachments`,
            },
            {
              label: "Attachment Detail",
              icon: DocumentTextIcon,
              current: true,
            },
          ],

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

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

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

function AdminStaffDetailAttachmentDetailPage() {
  return (
    <UIXThemeProvider>
      <AdminStaffDetailAttachmentDetailPageContent />
    </UIXThemeProvider>
  );
}

export default AdminStaffDetailAttachmentDetailPage;
