Files
prowler/ui/components/compliance/compliance-header/scan-selector.tsx
Alan Buscaglia 4d5676f00e feat: upgrade to React 19, Next.js 15, React Compiler, HeroUI and Tailwind 4 (#8748)
Co-authored-by: Alan Buscaglia <alanbuscaglia@MacBook-Pro.local>
Co-authored-by: alejandrobailo <alejandrobailo94@gmail.com>
Co-authored-by: César Arroba <cesar@prowler.com>
Co-authored-by: Alejandro Bailo <59607668+alejandrobailo@users.noreply.github.com>
2025-09-30 09:59:51 +02:00

58 lines
1.5 KiB
TypeScript

import { Select, SelectItem } from "@heroui/select";
import { ProviderType, ScanProps } from "@/types";
import { ComplianceScanInfo } from "./compliance-scan-info";
export interface SelectScanComplianceDataProps {
scans: (ScanProps & {
providerInfo: {
provider: ProviderType;
uid: string;
alias: string;
};
})[];
selectedScanId: string;
onSelectionChange: (selectedKey: string) => void;
}
export const ScanSelector = ({
scans,
selectedScanId,
onSelectionChange,
}: SelectScanComplianceDataProps) => {
return (
<Select
aria-label="Select a Scan"
placeholder="Select a scan"
classNames={{
trigger: "w-full min-w-[365px] rounded-lg",
popoverContent: "rounded-lg",
}}
size="lg"
labelPlacement="outside"
selectedKeys={new Set([selectedScanId])}
onSelectionChange={(keys) => {
const newSelectedId = Array.from(keys)[0] as string;
if (newSelectedId && newSelectedId !== selectedScanId) {
onSelectionChange(newSelectedId);
}
}}
renderValue={() => {
const selectedItem = scans.find((item) => item.id === selectedScanId);
return selectedItem ? (
<ComplianceScanInfo scan={selectedItem} />
) : (
"Select a scan"
);
}}
>
{scans.map((scan) => (
<SelectItem key={scan.id} textValue={scan.attributes.name || "- -"}>
<ComplianceScanInfo scan={scan} />
</SelectItem>
))}
</Select>
);
};