DataTableColumnStatusCode.tsx46 lines · main
| 1 | import { Minus } from 'lucide-react' |
| 2 | import { cn } from 'ui' |
| 3 | |
| 4 | export const DataTableColumnStatusCode = ({ |
| 5 | value, |
| 6 | level, |
| 7 | className, |
| 8 | }: { |
| 9 | value?: number | string |
| 10 | level?: string |
| 11 | className?: string |
| 12 | }) => { |
| 13 | const colorClassName = getStatusColor(level) |
| 14 | |
| 15 | function getStatusColor(value?: number | string): string { |
| 16 | switch (value) { |
| 17 | case '1': |
| 18 | case 'info': |
| 19 | return 'text-blue-500' |
| 20 | case '2': |
| 21 | case 'success': |
| 22 | return 'text-foreground' |
| 23 | case '4': |
| 24 | case 'warning': |
| 25 | case 'redirect': |
| 26 | return 'text-warning' |
| 27 | case '5': |
| 28 | case 'error': |
| 29 | return 'text-destructive' |
| 30 | default: |
| 31 | return 'text-foreground' |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | if (!value) { |
| 36 | return <Minus className="h-4 w-4 text-muted-foreground/50" /> |
| 37 | } |
| 38 | |
| 39 | return ( |
| 40 | <div className={cn('flex items-center relative', className)}> |
| 41 | <div className={cn('flex items-center justify-center relative font-mono', colorClassName)}> |
| 42 | {value} |
| 43 | </div> |
| 44 | </div> |
| 45 | ) |
| 46 | } |