import { useCallback, useMemo } from "react";
import { appNavigationItems } from "../../../features/layout/navigation";
import type { AppPageLayoutProps } from "../types";

export function useAppPageLayoutModel({ controller }: AppPageLayoutProps) {
  const {
    runDemoScan,
    canShowOverlay,
  } = controller;

  const renderNavigation = useMemo(
    () =>
      appNavigationItems.map((item) => ({
        ...item,
        disabled: item.id === "overlay" && !canShowOverlay,
        disabledReason: item.id === "overlay" && !canShowOverlay ? "Overlay benoetigt die Electron-Bridge." : undefined,
      })),
    [canShowOverlay],
  );

  const handleDemoScan = useCallback(() => {
    void runDemoScan();
  }, [runDemoScan]);

  return {
    renderNavigation,
    handleDemoScan,
  };
}
