DataTableColumnStatusCode.tsx 1009 B

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