import type { Dispatch, SetStateAction } from "react";
import { NetworkAdminClubList } from "@/components/network-admin-club-list";
import { NetworkAdminCreateClubSection } from "@/components/network-admin-create-club-section";
import {
  emptyClubForm,
  emptyMachineForm,
  emptyVenueForm,
  type Club,
  type ClubFormState,
  type MachineFormState,
  venueStatusOptions,
  type VenueFormState,
} from "@/components/network-admin-client-config";
import { networkAdminShellStyles } from "@/components/network-admin-shell-styles";
import { NetworkAdminStats } from "@/components/network-admin-stats";

type NetworkAdminShellProps = {
  clubs: Club[];
  setClubs: Dispatch<SetStateAction<Club[]>>;
  busy: boolean;
  message: string | null;
  messageTone: "success" | "error";
  runMutation: (task: () => Promise<void>, successMessage: string) => Promise<void>;
  clubForm: ClubFormState;
  setClubForm: Dispatch<SetStateAction<ClubFormState>>;
  venueForms: Record<string, VenueFormState>;
  setVenueForms: Dispatch<SetStateAction<Record<string, VenueFormState>>>;
  machineForms: Record<string, MachineFormState>;
  setMachineForms: Dispatch<SetStateAction<Record<string, MachineFormState>>>;
};

export function NetworkAdminShell({
  clubs,
  setClubs,
  busy,
  message,
  messageTone,
  runMutation,
  clubForm,
  setClubForm,
  venueForms,
  setVenueForms,
  machineForms,
  setMachineForms,
}: NetworkAdminShellProps) {
  return (
    <div className="space-y-6">
      <NetworkAdminStats clubs={clubs} cardClassName={networkAdminShellStyles.statCard} />

      <NetworkAdminCreateClubSection
        busy={busy}
        message={message}
        messageTone={messageTone}
        clubForm={clubForm}
        setClubForm={setClubForm}
        emptyClubForm={emptyClubForm}
        cardClassName={networkAdminShellStyles.sectionCard}
        runMutation={runMutation}
      />

      <NetworkAdminClubList
        clubs={clubs}
        busy={busy}
        setClubs={setClubs}
        venueForms={venueForms}
        setVenueForms={setVenueForms}
        emptyVenueForm={emptyVenueForm}
        machineForms={machineForms}
        setMachineForms={setMachineForms}
        emptyMachineForm={emptyMachineForm}
        venueStatusOptions={venueStatusOptions}
        selectClassName={networkAdminShellStyles.select}
        articleCardClassName={networkAdminShellStyles.articleCard}
        mutedPanelClassName={networkAdminShellStyles.mutedPanel}
        insetPanelClassName={networkAdminShellStyles.insetPanel}
        wellClassName={networkAdminShellStyles.well}
        runMutation={runMutation}
      />
    </div>
  );
}
