import { useParams } from "react-router-dom";
import { Alert, AlertDescription } from "@/components/ui/alert";
import {
	GrafanaAddonPage,
	PrometheusAddonPage,
	SshTasksAddonPage,
} from "../addons";

const ADDON_PAGES: Record<string, React.ComponentType> = {
	grafana: GrafanaAddonPage,
	prometheus: PrometheusAddonPage,
	"ssh-tasks": SshTasksAddonPage,
};

export function AddonPage() {
	const { addonId } = useParams<{ addonId: string }>();
	const Page = addonId ? ADDON_PAGES[addonId] : undefined;

	if (!Page) {
		return (
			<Alert>
				<AlertDescription>Addon "{addonId}" is not installed.</AlertDescription>
			</Alert>
		);
	}

	return <Page />;
}
