import { cn } from '@/lib/utils';
import { t } from 'i18next';
import { useIsDarkTheme } from '../theme-provider';
import { Plus } from 'lucide-react';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import SvgIcon from '../svg-icon';
import { EmptyCardData, EmptyCardType, EmptyType } from './constant';
import { EmptyCardProps, EmptyProps } from './interface';
const EmptyIcon = ({ name, width }: { name: string; width?: number }) => {
return ;
};
const Empty = (props: EmptyProps) => {
const { className, children, type, text, iconWidth } = props;
const isDarkTheme = useIsDarkTheme();
const name = useMemo(() => {
return isDarkTheme
? `empty/no-${type || EmptyType.Data}-dark`
: `empty/no-${type || EmptyType.Data}-bri`;
}, [isDarkTheme, type]);
return (
{!children && (
{text ||
(type === 'data' ? t('common.noData') : t('common.noResults'))}
)}
{children}
);
};
export default Empty;
export const EmptyCard = (props: EmptyCardProps) => {
const { icon, className, children, title, description, style, ...restProps } =
props;
return (
{icon}
{title && {title}
}
{description && (
{description}
)}
{children}
);
};
export const EmptyAppCard = (props: {
type: EmptyCardType;
onClick?: () => void;
showIcon?: boolean;
className?: string;
isSearch?: boolean;
size?: 'small' | 'large';
children?: React.ReactNode;
testId?: string;
tabIndex?: number;
}) => {
const { type, showIcon, className, isSearch, children, testId, tabIndex } =
props;
const { t } = useTranslation();
let defaultClass = '';
let style: React.CSSProperties | undefined;
const cardData = EmptyCardData[type];
const title = t(cardData.titleKey);
const notFound = t(cardData.notFoundKey);
switch (props.size) {
case 'small':
style = { width: '256px' };
defaultClass = 'mt-1';
break;
case 'large':
defaultClass = 'mt-5';
break;
default:
defaultClass = '';
break;
}
return (
{!isSearch && !children && (
)}
{children}
);
};