import { type ReactNode } from 'react'
import { useTranslation } from 'react-i18next'
import { cn } from '@/lib/utils'
import { Skeleton } from '@/components/ui/skeleton'
interface PanelWrapperProps {
title: ReactNode
description?: ReactNode
loading?: boolean
empty?: boolean
emptyMessage?: string
height?: string
className?: string
contentClassName?: string
headerActions?: ReactNode
children?: ReactNode
}
function PanelHeader(props: {
title: ReactNode
description?: ReactNode
actions?: ReactNode
}) {
const heading = (
{props.title}
{props.description != null && (
{props.description}
)}
)
return (
{props.actions != null ? (
{heading}
{props.actions}
) : (
heading
)}
)
}
export function PanelWrapper(props: PanelWrapperProps) {
const { t } = useTranslation()
const resolvedEmptyMessage = props.emptyMessage ?? t('No data available')
const height = props.height ?? 'h-64'
const frameClassName = cn(
'overflow-hidden rounded-2xl border bg-card shadow-xs',
props.className
)
if (props.loading) {
return (
)
}
if (props.empty) {
return (
)
}
return (
)
}