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

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

function AdminEventVirtualAddStep3Page() {
  const authManager = useAuthManager();
  const virtualEventWizardStorage = useVirtualEventWizardStorage();
  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 virtual events - memoized to prevent re-renders
  const eventTypeConfig = useMemo(
    () => ({
      labels: {
        eventTypeName: "Virtual Event",
      },
      routes: {
        list: "/admin/events/virtuals",
        step1: "/admin/events/virtuals/add/step-1",
        step2: "/admin/events/virtuals/add/step-2",
        step3: "/admin/events/virtuals/add/step-3",
        step4: "/admin/events/virtuals/add/step-4",
      },
      icons: {
        wizard: VideoCameraIcon,
      },
    }),
    [],
  );

  // Create storage adapter to match EventStep3Component interface - memoized to prevent re-renders
  const storageAdapter = useMemo(
    () => ({
      getWizardData: () => virtualEventWizardStorage.getVirtualEventWizard(),
      saveWizardData: (data) =>
        virtualEventWizardStorage.saveVirtualEventWizard(data),
      clearWizardData: () =>
        virtualEventWizardStorage.clearVirtualEventWizard(),
    }),
    [],
  );

  return (
    <EventStep3Component
      // Required props
      wizardStorage={storageAdapter}
      eventTypeConfig={eventTypeConfig}
      // Feature flags for virtual events
      enableSHSM={true}
      enablePartners={true}
      enableLocation={true}
      enableListingUrl={true}
      enableFacilitatorTimeFrames={true}
      // Custom field labels and configs for virtual events
      customLabels={{
        attendeeCapacity: "Attendee Capacity",
        attendeeCapacityHelper:
          "Enter the maximum number of attendees for this virtual event",
      }}
      // Default values specific to virtual events
      defaultValues={{
        facilitatorAM: true,
        facilitatorPM: true,
      }}
      // Step wizard configuration (override defaults)
      defaultSteps={steps}
    />
  );
}

export default AdminEventVirtualAddStep3Page;
