gitscope
← marzneshin / v0.3.0 / dashboard/src/features/nodes/tables/nodes-status-badge.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/features/nodes/tables/nodes-status-badge.tsx · TypeScript
Blame Raw
 1import { FC } from 'react';
 2import { Badge, Label } from '@marzneshin/components';
 3import { StatusType } from '@marzneshin/types';
 4import { NodesStatus } from '..';
 5
 6interface NodesStatusBadgeProps {
 7    status: StatusType;
 8}
 9
10export const NodesStatusBadge: FC<NodesStatusBadgeProps> = ({ status }) => {
11    const { label, icon: Icon } = status;
12
13    let badgeVariant: 'outline' | 'destructive' | undefined | null;
14    switch (label) {
15        case NodesStatus.healthy.label:
16            badgeVariant = undefined;
17            break;
18        case NodesStatus.unhealthy.label:
19            badgeVariant = "destructive";
20            break;
21        case NodesStatus.disabled.label:
22            badgeVariant = "outline";
23            break;
24        case "none":
25            return null;
26    }
27
28    return (
29        <Badge variant={badgeVariant} className="h-6">
30            {Icon && <Icon className="mr-1 w-5 h-4" />} <Label className="capitalize">{label}</Label>
31        </Badge>
32    );
33};
34
35export default NodesStatusBadge;