import { memo } from 'react'; import { useTranslation } from 'react-i18next'; import styles from './drag-preview.module.css'; import { useItemImageUrl } from '/@/renderer/components/item-image/item-image'; import { Icon } from '/@/shared/components/icon/icon'; import { LibraryItem } from '/@/shared/types/domain-types'; import { DragData } from '/@/shared/types/drag-and-drop'; interface DragPreviewProps { data: DragData; } const getItemName = (item: unknown): string => { if (item && typeof item === 'object') { if ('name' in item && typeof item.name === 'string') { return item.name; } if ('title' in item && typeof item.title === 'string') { return item.title; } } return 'Item'; }; export const DragPreview = memo(({ data }: DragPreviewProps) => { const items = data.item || []; const { t } = useTranslation(); const itemCount = items.length; const firstItem = items[0]; const itemName = firstItem ? getItemName(firstItem) : 'Item'; const itemImage = useItemImageUrl({ id: (firstItem as { imageId: string })?.imageId, itemType: data.itemType || LibraryItem.SONG, type: 'table', }); const isMultiple = itemCount > 1; return (