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

import React, { useCallback, memo } from "react";
import {
  BriefcaseIcon,
  ArchiveBoxXMarkIcon,
} from "@heroicons/react/24/outline";
import { useStaffManager } from "../../../../../../services/Services";
import { EntityActionConfirmationPage } from "../../../../../../components/business/views";
import { UIXThemeProvider } from "../../../../../../components/UIX";

const AdminStaffDetailMoreUnarchivePageContent = memo(function AdminStaffDetailMoreUnarchivePageContent() {
  const staffManager = useStaffManager();

  const getStaffDetailWithManager = useCallback(async (staffId, onUnauthorized) => {
    return new Promise((resolve, reject) => {
      staffManager.getStaffDetailWithCallbacks(
        staffId,
        (staffData) => resolve(staffData),
        (error) => reject(error),
        () => {},
        onUnauthorized
      );
    });
  }, [staffManager]);

  const handleUnarchiveAction = useCallback(async (staffId, onUnauthorized) => {
    await staffManager.unarchiveStaff(staffId, onUnauthorized);
  }, [staffManager]);

  return (
    <EntityActionConfirmationPage
      entityIcon={BriefcaseIcon}
      entityType="Staff Member"
      entityTypePlural="Staff"
      basePath="/admin/staff"
      entityParamName="aid"
      entityManager={staffManager}
      getEntityDetail={getStaffDetailWithManager}
      actionIcon={ArchiveBoxXMarkIcon}
      actionName="Unarchive"
      actionDescription="Unarchive Staff Member - Restore to Active Status"
      actionWarningPoints={[
        "The staff member will be restored to active status",
        "They will regain access to their account",
        "All permissions and assignments will be reactivated"
      ]}
      actionButtonText="Confirm and Unarchive"
      actionButtonVariant="primary"
      onActionExecute={handleUnarchiveAction}
      successMessage="Staff member has been successfully unarchived"
      redirectPath="/admin/staff"
    />
  );
});

function AdminStaffDetailMoreUnarchivePage() {
  return (
    <UIXThemeProvider>
      <AdminStaffDetailMoreUnarchivePageContent />
    </UIXThemeProvider>
  );
}

export default AdminStaffDetailMoreUnarchivePage;
