mirror of
https://github.com/prowler-cloud/prowler.git
synced 2025-12-19 05:17:47 +00:00
31 lines
744 B
TypeScript
31 lines
744 B
TypeScript
"use client";
|
|
|
|
import { createContext, useContext } from "react";
|
|
|
|
import { FindingProps } from "@/types";
|
|
|
|
interface FindingsSelectionContextValue {
|
|
selectedFindingIds: string[];
|
|
selectedFindings: FindingProps[];
|
|
clearSelection: () => void;
|
|
isSelected: (id: string) => boolean;
|
|
}
|
|
|
|
export const FindingsSelectionContext =
|
|
createContext<FindingsSelectionContextValue>({
|
|
selectedFindingIds: [],
|
|
selectedFindings: [],
|
|
clearSelection: () => {},
|
|
isSelected: () => false,
|
|
});
|
|
|
|
export function useFindingsSelection() {
|
|
const context = useContext(FindingsSelectionContext);
|
|
if (!context) {
|
|
throw new Error(
|
|
"useFindingsSelection must be used within a FindingsSelectionProvider",
|
|
);
|
|
}
|
|
return context;
|
|
}
|