-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c41fd16
commit 43c30a7
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { getCheckNames } from "@flanksource-ui/api/services/topology"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useMemo } from "react"; | ||
import { Icon } from "../../../ui/Icons/Icon"; | ||
import FormikSelectDropdown from "./FormikSelectDropdown"; | ||
|
||
type FormikChecksDropdownProps = { | ||
name: string; | ||
label?: string; | ||
required?: boolean; | ||
hint?: string; | ||
filter?: { | ||
types: string[]; | ||
}; | ||
className?: string; | ||
}; | ||
|
||
export default function FormikChecksDropdown({ | ||
name, | ||
label, | ||
required = false, | ||
hint, | ||
filter, | ||
className = "flex flex-col space-y-2 py-2" | ||
}: FormikChecksDropdownProps) { | ||
const { isLoading, data: checks } = useQuery({ | ||
queryKey: ["checks", "check_names"], | ||
queryFn: () => getCheckNames() | ||
}); | ||
|
||
const options = useMemo( | ||
() => | ||
checks?.map((check) => ({ | ||
label: check.name, | ||
value: check.id, | ||
icon: <Icon name={check.type} className="h-5 w-5" /> | ||
})), | ||
[checks] | ||
); | ||
|
||
return ( | ||
<FormikSelectDropdown | ||
name={name} | ||
className={className} | ||
options={options} | ||
label={label} | ||
isLoading={isLoading} | ||
required={required} | ||
hint={hint} | ||
/> | ||
); | ||
} |