// File Path: monorepo/web/frontend/src/pages/Admin/Event/Conference/Add/Step2Page.jsx

import React, { useMemo } from "react";
import { useNavigate } from "react-router";
import {
  useAuthManager,
  useEventWizardStorage,
} from "../../../../../services/Services";
import EventStep3Component from "../../../../../components/business/events/EventStep3Component";
import { PlusIcon, BriefcaseIcon, HomeIcon } from "@heroicons/react/24/outline";

function AdminEventConferenceAddStep2Page() {
  const authManager = useAuthManager();
  const eventWizardStorage = useEventWizardStorage();
  const navigate = useNavigate();

  // Steps configuration for UIX StepWizard - memoized to prevent re-renders
  const steps = useMemo(() => [
    {
      id: "step1",
      title: "Setup",
      isCompleted: true,
    },
    {
      id: "step2",
      title: "Event Type",
      isCompleted: false,
    },
    {
      id: "step3",
      title: "Details",
      isCompleted: false,
    },
    {
      id: "step4",
      title: "Review",
      isCompleted: false,
    },
  ], []);

  // Event type configuration for conferences - memoized to prevent re-renders
  const eventTypeConfig = useMemo(() => ({
    labels: {
      eventTypeName: "Conference",
    },
    routes: {
      list: "/admin/events/conferences",
      step1: "/admin/events/conferences/add/step-1",
      step2: "/admin/events/conferences/add/step-2",
      step3: "/admin/events/conferences/add/step-3",
      step4: "/admin/events/conferences/add/step-4",
    },
    icons: {
      wizard: BriefcaseIcon,
    },
  }), []);

  // Wrapper for Conference storage to match the generic interface - memoized to prevent re-renders
  const wrappedStorage = useMemo(() => ({
    getWizardData: () => eventWizardStorage.getEventWizard(),
    saveWizardData: (data) => eventWizardStorage.saveEventWizard(data),
    clearWizardData: () => eventWizardStorage.clearEventWizard(),
  }), []);

  return (
    <EventStep3Component
      // Required props
      wizardStorage={wrappedStorage}
      eventTypeConfig={eventTypeConfig}
      // Feature flags for conferences
      enableSHSM={true}
      enablePartners={true}
      enableLocation={true}
      enableListingUrl={true}
      enableFacilitatorTimeFrames={true}
      // Custom field labels and configs for conferences
      customLabels={{
        attendeeCapacity: "Attendee Capacity",
        attendeeCapacityHelper:
          "Enter the total attendee capacity for this event",
        facilitatorTimeFrames: "Facilitator/Speaker Time Frames",
        facilitatorTimeFramesHelper:
          "Select when facilitators/speakers will be needed",
      }}
      // Default values specific to conferences
      defaultValues={{
        facilitatorAM: true,
        facilitatorPM: true,
      }}
      // Step wizard configuration (override defaults)
      defaultSteps={steps}
    />
  );
}

export default AdminEventConferenceAddStep2Page;
