import { For, Show } from "solid-js"; import type { ModuleCatalog } from "@/api/client"; import { Badge } from "@/components/ui/badge"; import { moduleLabel, packageLabel } from "@/lib/module-labels"; import { useT } from "@/stores/preferences-context"; /** * The deployment catalog grouped by package, each module marked on/off for one * school. Read-only without `onToggle` (a school admin's view); with it, every * module row becomes a switch (the builder's switchboard). */ export function ModuleCatalogGrid(props: { catalog: ModuleCatalog; enabled: readonly string[]; onToggle?: (module: string, next: boolean) => void; onTogglePackage?: (pkg: string, next: boolean) => void; disabled?: boolean; /** One column regardless of viewport — for narrow hosts like a SidePanel. */ stacked?: boolean; }) { const t = useT(); const isOn = (module: string) => props.enabled.includes(module); const requiresOf = (module: string) => props.catalog.modules.find((entry) => entry.module === module)?.requires ?? []; return (
{(pkg) => { const onCount = () => pkg.modules.filter(isOn).length; return (

{packageLabel(pkg.package, t)}

{t("modules.enabledCount", { on: String(onCount()), total: String(pkg.modules.length) })}

{(toggle) => (
)}
    {(module) => (
  • {moduleLabel(module, t)}

    0}>

    {t("modules.requires")}: {requiresOf(module).map((name) => moduleLabel(name, t)).join(", ")}

    {isOn(module) ? t("modules.on") : t("modules.off")} } > {(toggle) => ( )}
  • )}
); }}
); }