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

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

function AdminEventFieldTripAddStep3Page() {
  const authManager = useAuthManager();
  const offsiteEventWizardStorage = useOffsiteEventWizardStorage();
  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 field trips - memoized to prevent re-renders
  const eventTypeConfig = useMemo(
    () => ({
      labels: {
        eventTypeName: "Field Trip",
      },
      routes: {
        list: "/admin/events/field-trips",
        step1: "/admin/events/field-trips/add/step-1",
        step2: "/admin/events/field-trips/add/step-2",
        step3: "/admin/events/field-trips/add/step-3",
        step4: "/admin/events/field-trips/add/step-4",
      },
      icons: {
        wizard: TruckIcon,
      },
    }),
    [],
  );

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

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

export default AdminEventFieldTripAddStep3Page;
