import cs from 'classnames'; import './styles/index.scss'; import { IconLoading, useUIKit } from '@tencentcloud/uikit-base-component-react'; import { PlaceholderLoadError } from './PlaceholderLoadError'; import { PlaceholderEmptyList } from './PlaceholderEmptyList'; export const PlaceHolderTypes = { LOADING: 'LOADING', NO_CONVERSATIONS: 'NO_CONVERSATIONS', WRONG: 'WRONG', } as const; export interface PlaceHolderProps { className?: string | undefined; type: keyof typeof PlaceHolderTypes; iconSize?: number | undefined; searchString?: string | undefined; retry?: (() => void) | undefined; } export function PlaceHolder({ className = '', type, iconSize = 42, searchString = '', retry, }: PlaceHolderProps) { const { t } = useUIKit(); const PlaceHolderStringTypes = { [PlaceHolderTypes.LOADING]: '', [PlaceHolderTypes.NO_CONVERSATIONS]: t('TUIConversation.No conversation'), [PlaceHolderTypes.WRONG]: t('TUIConversation.Something was wrong'), }; return (
{ type === PlaceHolderTypes.LOADING && ( ) } { (type === PlaceHolderTypes.NO_CONVERSATIONS) && ( ) } { (type === PlaceHolderTypes.WRONG) && ( ) }
{ PlaceHolderStringTypes[type] && (
{searchString ? `${PlaceHolderStringTypes[type]} '${searchString}' ` : PlaceHolderStringTypes[type]}
) } {type === PlaceHolderTypes.WRONG && retry && (
)}
); }