import { useMemo } from "react"; import { useParams, useNavigate } from "react-router-dom"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { useServiceInstances } from "../hooks/useServices"; import type { ServiceInstance } from "../types"; import { SectionCard } from "../components/SectionCard"; import { getServiceBinding } from "../integrations/registry"; import { OVERVIEW_TAB, serviceContentTabs, type ContentTab, } from "./service-tabs"; export function ServicePage() { const { serviceType = "", serviceId = "" } = useParams<{ serviceType: string; serviceId: string; }>(); const { data: services = [] } = useServiceInstances(serviceType || undefined); const navigate = useNavigate(); const instance = useMemo( () => services.find((s) => s.id === serviceId), [services, serviceId], ); const binding = getServiceBinding(serviceType); const contentTabs = useMemo( () => serviceContentTabs(serviceType), [serviceType], ); const siblings = useMemo( () => services.filter((s) => s.service_type === serviceType && s.enabled), [services, serviceType], ); const showInstanceTabs = siblings.length > 1; const allTabs: ContentTab[] = [OVERVIEW_TAB, ...contentTabs]; if (!binding) { return ( Unknown service type: {serviceType} ); } if (!instance) { return ( Service not found. ); } const widgetsContent = binding.widgets.length > 0 ? (
{binding.widgets.map((w) => (
{w.name}
{w.description}
{w.kind}
))}

Add these to the dashboard from the dashboard's edit dialog.

) : (

No widget kinds for this service type.

); return (
{/* Header */}

{instance.name}

{binding.description}

{binding.name}
{/* Instance tabs (only when >1 enabled sibling) */} {showInstanceTabs ? ( {siblings.map((sibling: ServiceInstance) => ( navigate(`/services/${serviceType}/${sibling.id}`) } > {sibling.name} ))} ) : null} {/* Content tabs */} Overview {contentTabs.map((tab) => ( {tab.label} ))} Widgets {allTabs.map((tab) => { const TabComponent = tab.Component; return ( ); })} {widgetsContent}
); }