Files
prowler/components/ui/table/StatusBadge.tsx
T
Sophia Dao 7ab46d61b5 Findings page Severity component (#35)
* feat(findings): Severity and Status badge WIP

* feat(findings): Status and Severity badge changes

* Fix font color for dark mode
2024-08-09 09:16:55 -05:00

45 lines
983 B
TypeScript

import { Chip } from "@nextui-org/react";
import React from "react";
type Status =
| "completed"
| "pending"
| "cancelled"
| "fail"
| "success"
| "muted";
const statusColorMap: Record<
Status,
| "text-white bg-green-600"
| "bg-yellow-200"
| "text-white bg-red-600"
| "bg-gray-300"
> = {
completed: "text-white bg-green-600",
pending: "bg-yellow-200",
cancelled: "text-white bg-red-600",
fail: "text-white bg-red-600",
success: "text-white bg-green-600",
muted: "bg-gray-300",
};
const getStatusColor: (status: Status) => string = (status) =>
// eslint-disable-next-line security/detect-object-injection
statusColorMap[status];
export const StatusBadge = ({ status }: { status: Status }) => {
return (
<Chip
classNames={{
base: `capitalize border-none gap-1 text-gray-600 ${getStatusColor(status)}`,
content: "font-semibold",
}}
size="sm"
variant="solid"
>
{status}
</Chip>
);
};