import { useState } from 'react'; import { useCurrentUser } from '@/react/hooks/useUser'; import { Chart } from '../types'; import { useHelmChartList, useHelmRepositories, } from '../queries/useHelmChartList'; import { HelmTemplatesList } from './HelmTemplatesList'; import { HelmTemplatesSelectedItem } from './HelmTemplatesSelectedItem'; import { HelmInstallForm } from './HelmInstallForm'; interface Props { onSelectHelmChart: (chartName: string) => void; namespace?: string; name?: string; } export function HelmTemplates({ onSelectHelmChart, namespace, name }: Props) { const [selectedChart, setSelectedChart] = useState(null); const { user } = useCurrentUser(); const helmReposQuery = useHelmRepositories(user.Id); const chartListQuery = useHelmChartList(user.Id, helmReposQuery.data ?? []); function clearHelmChart() { setSelectedChart(null); onSelectHelmChart(''); } function handleChartSelection(chart: Chart) { setSelectedChart(chart); onSelectHelmChart(chart.name); } return (
{selectedChart ? ( <> ) : ( )}
); }