empty-state.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import type { ReactNode } from 'react'
  2. import { Database, type LucideIcon } from 'lucide-react'
  3. import { useTranslation } from 'react-i18next'
  4. import { cn } from '@/lib/utils'
  5. import {
  6. Empty,
  7. EmptyContent,
  8. EmptyDescription,
  9. EmptyHeader,
  10. EmptyMedia,
  11. EmptyTitle,
  12. } from '@/components/ui/empty'
  13. import { FadeIn } from '@/components/page-transition'
  14. interface EmptyStateProps {
  15. icon?: LucideIcon
  16. title?: string
  17. description?: string
  18. action?: ReactNode
  19. className?: string
  20. bordered?: boolean
  21. }
  22. export function EmptyState(props: EmptyStateProps) {
  23. const { t } = useTranslation()
  24. const Icon = props.icon ?? Database
  25. return (
  26. <FadeIn>
  27. <Empty
  28. className={cn(
  29. 'min-h-[300px]',
  30. props.bordered && 'border',
  31. props.className
  32. )}
  33. >
  34. <EmptyHeader>
  35. <EmptyMedia variant='icon'>
  36. <Icon className='size-6' />
  37. </EmptyMedia>
  38. <EmptyTitle>{props.title ?? t('No Data')}</EmptyTitle>
  39. {props.description != null && (
  40. <EmptyDescription>{props.description}</EmptyDescription>
  41. )}
  42. </EmptyHeader>
  43. {props.action != null && <EmptyContent>{props.action}</EmptyContent>}
  44. </Empty>
  45. </FadeIn>
  46. )
  47. }