import React from "react";
import { useSkillSetManager } from "../../../../../services/Services";
import { SettingsDeleteView } from "../../../../../components/business/views";
import { AcademicCapIcon, DocumentTextIcon, InformationCircleIcon } from "@heroicons/react/24/outline";

function SettingSkillSetDeletePage() {
  const skillSetManager = useSkillSetManager();

  // Custom entity transformer to use subCategory as name
  const transformEntityData = (entityData) => {
    if (!entityData) return entityData;

    return {
      ...entityData,
      // Use subCategory as the display name
      name: entityData.name || entityData.text || entityData.subCategory || 'Unknown'
    };
  };

  // Create a wrapper around the skill set manager to transform data
  const skillSetManagerWrapper = {
    ...skillSetManager,
    getSkillSetDetail: async (id, onUnauthorized) => {
      const data = await skillSetManager.getSkillSetDetail(id, onUnauthorized);
      return transformEntityData(data);
    },
    deleteSkillSet: async (id, onUnauthorized) => {
      return await skillSetManager.deleteSkillSet(id, onUnauthorized);
    }
  };

  // Define impact warnings
  const impactWarnings = [
    {
      icon: AcademicCapIcon,
      text: "Any facilitators with this skill set assignment"
    },
    {
      icon: DocumentTextIcon,
      text: "Historical records referencing this skill set will still exist but may show as 'Deleted'"
    },
    {
      icon: InformationCircleIcon,
      text: "You will not be able to recover this skill set once deleted"
    }
  ];

  // Define alternative text
  const alternativeText = "Consider setting the skill set to 'Inactive' instead of deleting it to preserve historical data.";

  return (
    <SettingsDeleteView
      entityType="skillSet"
      entityTypePlural="Skill Sets"
      entityIcon={AcademicCapIcon}
      entityManager={skillSetManagerWrapper}
      basePath="/admin/settings/skill-set"
      listPath="/admin/settings/skill-sets"
      title="Delete Skill Set"
      subtitle="Permanent deletion confirmation"
      impactWarnings={impactWarnings}
      alternativeText={alternativeText}
      requiresConfirmation={true}
    />
  );
}

export default SettingSkillSetDeletePage;