2024-02-28 23:10:31 +03:00
|
|
|
import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind';
|
2024-02-28 21:02:05 +03:00
|
|
|
import React, { type FC } from 'react';
|
2024-01-31 04:18:12 +03:00
|
|
|
import Icon from '@mui/material/Icon';
|
2024-09-18 14:37:25 -04:00
|
|
|
import { getItemTypeIcon, getLibraryIcon } from 'utils/image';
|
2024-01-31 04:18:12 +03:00
|
|
|
import DefaultName from './DefaultName';
|
2024-03-03 01:31:35 +03:00
|
|
|
import type { ItemDto } from 'types/base/models/item-dto';
|
2024-01-31 04:18:12 +03:00
|
|
|
|
|
|
|
interface DefaultIconTextProps {
|
|
|
|
item: ItemDto;
|
|
|
|
defaultCardImageIcon?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const DefaultIconText: FC<DefaultIconTextProps> = ({
|
|
|
|
item,
|
|
|
|
defaultCardImageIcon
|
|
|
|
}) => {
|
2024-09-18 14:37:25 -04:00
|
|
|
let icon;
|
|
|
|
|
|
|
|
if (item.Type === BaseItemKind.CollectionFolder || item.CollectionType) {
|
|
|
|
icon = getLibraryIcon(item.CollectionType);
|
2024-01-31 04:18:12 +03:00
|
|
|
}
|
|
|
|
|
2024-09-18 14:37:25 -04:00
|
|
|
if (!icon) {
|
|
|
|
icon = getItemTypeIcon(item.Type, defaultCardImageIcon);
|
2024-01-31 04:18:12 +03:00
|
|
|
}
|
|
|
|
|
2024-09-18 14:37:25 -04:00
|
|
|
if (icon) {
|
2024-01-31 04:18:12 +03:00
|
|
|
return (
|
|
|
|
<Icon
|
|
|
|
className='cardImageIcon'
|
|
|
|
sx={{ color: 'inherit', fontSize: '5em' }}
|
|
|
|
aria-hidden='true'
|
|
|
|
>
|
2024-09-18 14:37:25 -04:00
|
|
|
{icon}
|
2024-01-31 04:18:12 +03:00
|
|
|
</Icon>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <DefaultName item={item} />;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default DefaultIconText;
|